commit 60e9b006b514f1337f7ff2a41518f0ed72510d5f (HEAD, refs/remotes/origin/master) Author: Michael Albinus Date: Mon May 9 09:20:34 2016 +0200 Extend completion candidates in tramp.el * lisp/net/tramp.el (tramp-parse-default-user-host): New defun. (tramp-get-completion-function): Use it. diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index b179815..118da57 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -1712,9 +1712,11 @@ Example: (defun tramp-get-completion-function (method) "Returns a list of completion functions for METHOD. For definition of that list see `tramp-set-completion-function'." - (cons - ;; Hosts visited once shall be remembered. - `(tramp-parse-connection-properties ,method) + (append + `(;; Default settings are taken into account. + (tramp-parse-default-user-host ,method) + ;; Hosts visited once shall be remembered. + (tramp-parse-connection-properties ,method)) ;; The method related defaults. (cdr (assoc method tramp-completion-function-alist)))) @@ -2549,6 +2551,12 @@ PARTIAL-USER must match USER, PARTIAL-HOST must match HOST." (unless (zerop (+ (length user) (length host))) (tramp-completion-make-tramp-file-name method user host nil))) +(defun tramp-parse-default-user-host (method) + "Return a list of (user host) tuples allowed to access for METHOD. +This function is added always in `tramp-get-completion-function' +for all methods. Resulting data are derived from default settings." + `((,(tramp-find-user method nil nil) ,(tramp-find-host method nil nil)))) + ;; Generic function. (defun tramp-parse-group (regexp match-level skip-regexp) "Return a (user host) tuple allowed to access. commit 001d59c60465d30abec6575a767c6daa16f2f8db Author: Michael Albinus Date: Mon May 9 09:18:50 2016 +0200 Revert e2f785991d0c696fbb2bc2f331f888d979b8da82 for tramp.el * lisp/net/tramp.el (tramp-time-diff): Revert previous change due to backwards compatibility. diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 377b529..b179815 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -4124,7 +4124,8 @@ Invokes `password-read' if available, `read-passwd' else." (defun tramp-time-diff (t1 t2) "Return the difference between the two times, in seconds. T1 and T2 are time values (as returned by `current-time' for example)." - (float-time (time-subtract t1 t2))) + ;; Starting with Emacs 25.1, we could change this to use `time-subtract'. + (float-time (subtract-time t1 t2))) ;; Currently (as of Emacs 20.5), the function `shell-quote-argument' ;; does not deal well with newline characters. Newline is replaced by commit 80bea210ff14a64daa1d71765983aa3baa149555 Author: Dmitry Gutov Date: Mon May 9 03:41:49 2016 +0300 Emulate interactive mode * test/lisp/jit-lock-tests.el (jit-lock-tests--setup-buffer) (jit-lock-does-not-refontify-unnecessarily): Bind noninteractive to nil (bug#23278). diff --git a/test/lisp/jit-lock-tests.el b/test/lisp/jit-lock-tests.el index 26b9799..3d1db85 100644 --- a/test/lisp/jit-lock-tests.el +++ b/test/lisp/jit-lock-tests.el @@ -28,7 +28,8 @@ (defun jit-lock-tests--setup-buffer () (setq font-lock-defaults '(nil t)) - (font-lock-mode)) + (let (noninteractive) + (font-lock-mode))) (ert-deftest jit-lock-fontify-now-fontifies-a-new-buffer () (ert-with-test-buffer (:name "xxx") @@ -51,7 +52,8 @@ (ert-with-test-buffer (:name "xxx") (setq font-lock-defaults (list '(((lambda () (error "Don't call me")))) t)) - (font-lock-mode) + (let (noninteractive) + (font-lock-mode)) (insert "aaa") (with-silent-modifications (put-text-property (point-min) (point-max) 'fontified t)) commit e2f785991d0c696fbb2bc2f331f888d979b8da82 Author: Paul Eggert Date: Sun May 8 12:46:00 2016 -0700 Simplify now that float-time etc. are built-in This was prompted by warnings about calls to now-obsolete functions. * lisp/calendar/time-date.el (encode-time-value): Use setq rather than a recursive call, to avoid a warning about calling this obsolete function. * lisp/calendar/time-date.el (encode-time-value) (with-decoded-time-value, time-to-seconds, time-to-number-of-days): * lisp/erc/erc.el (erc-emacs-time-to-erc-time): * lisp/net/rcirc.el (rcirc-float-time): * lisp/org/org-compat.el (org-float-time): Simplify now that time-add and float-time are now built-in. * lisp/calendar/time-date.el (time-add, time-subtract, time-less-p): * lisp/net/newst-backend.el (time-add): * lisp/org/org.el (time-subtract): Remove backward-compatibility definitions; they are now built-in. * lisp/calendar/timeclock.el (timeclock-time-to-seconds) (timeclock-seconds-to-time): * lisp/net/rcirc.el (rcirc-float-time): * lisp/org/org-compat.el (org-float-time): Now obsolete, since callers can just use float-time and seconds-to-time. All uses changed. * lisp/emacs-lisp/ert.el (ert-results-pop-to-timings): * lisp/gnus/gnus-art.el (article-lapsed-string): * lisp/gnus/gnus-diary.el (gnus-user-format-function-d): * lisp/gnus/gnus-group.el (gnus-group-timestamp-delta): * lisp/gnus/nndiary.el (nndiary-compute-reminders): * lisp/net/tramp.el (tramp-time-diff): * lisp/org/org-clock.el (org-clock-timestamps-change): Prefer the time-subtract builtin to the subtract-time alias. * lisp/files.el (dir-locals-find-file, dir-locals-read-from-dir): * test/lisp/character-fold-tests.el (character-fold--speed-test): Prefer the float-time builtin to the time-to-seconds alias. * lisp/org/org-agenda.el, lisp/org/org-clock.el, lisp/org/org-list.el: * lisp/org/org-timer.el, lisp/org/org.el: Adjust to org-float-time deprecation. diff --git a/lisp/calendar/time-date.el b/lisp/calendar/time-date.el index da3e2a2..a1d946e 100644 --- a/lisp/calendar/time-date.el +++ b/lisp/calendar/time-date.el @@ -126,16 +126,17 @@ type 2 is (HIGH LOW MICRO), and type 3 is (HIGH LOW MICRO PICO). For backward compatibility, if only four arguments are given, it is assumed that PICO was omitted and should be treated as zero." + (when (null type) + (setq type pico) + (setq pico 0)) (cond ((eq type 0) (cons high low)) ((eq type 1) (list high low)) ((eq type 2) (list high low micro)) - ((eq type 3) (list high low micro pico)) - ((null type) (encode-time-value high low micro 0 pico)))) + ((eq type 3) (list high low micro pico)))) -(when (and (fboundp 'time-add) (subrp (symbol-function 'time-add))) - (make-obsolete 'encode-time-value nil "25.1") - (make-obsolete 'with-decoded-time-value nil "25.1")) +(make-obsolete 'encode-time-value nil "25.1") +(make-obsolete 'with-decoded-time-value nil "25.1") (autoload 'parse-time-string "parse-time") (autoload 'timezone-make-date-arpa-standard "timezone") @@ -163,27 +164,8 @@ If DATE lacks timezone information, GMT is assumed." (apply 'signal err) (error "Invalid date: %s" date))))))))) -;; Bit of a mess. Emacs has float-time since at least 21.1. -;; This file is synced to Gnus, and XEmacs packages may have been written -;; using time-to-seconds from the Gnus library. -;;;###autoload(if (or (featurep 'emacs) -;;;###autoload (and (fboundp 'float-time) -;;;###autoload (subrp (symbol-function 'float-time)))) -;;;###autoload (defalias 'time-to-seconds 'float-time) -;;;###autoload (autoload 'time-to-seconds "time-date")) - -(eval-when-compile - (or (featurep 'emacs) - (and (fboundp 'float-time) - (subrp (symbol-function 'float-time))) - (defun time-to-seconds (&optional time) - "Convert optional value TIME to a floating point number. -TIME defaults to the current time." - (with-decoded-time-value ((high low micro pico _type - (or time (current-time)))) - (+ (* high 65536.0) - low - (/ (+ (* micro 1e6) pico) 1e12)))))) +;;;###autoload +(defalias 'time-to-seconds 'float-time) ;;;###autoload (defun seconds-to-time (seconds) @@ -209,68 +191,7 @@ TIME should be either a time value or a date-time string." (time-subtract nil time)) ;;;###autoload -(defalias 'subtract-time 'time-subtract) - -;; These autoloads do nothing in Emacs 25, where the functions are builtin. -;;;###autoload(autoload 'time-add "time-date") -;;;###autoload(autoload 'time-subtract "time-date") -;;;###autoload(autoload 'time-less-p "time-date") - -(eval-and-compile - (when (not (and (fboundp 'time-add) (subrp (symbol-function 'time-add)))) - - (defun time-add (t1 t2) - "Add two time values T1 and T2. One should represent a time difference." - (with-decoded-time-value ((high low micro pico type t1) - (high2 low2 micro2 pico2 type2 t2)) - (setq high (+ high high2) - low (+ low low2) - micro (+ micro micro2) - pico (+ pico pico2) - type (max type type2)) - (when (>= pico 1000000) - (setq micro (1+ micro) - pico (- pico 1000000))) - (when (>= micro 1000000) - (setq low (1+ low) - micro (- micro 1000000))) - (when (>= low 65536) - (setq high (1+ high) - low (- low 65536))) - (encode-time-value high low micro pico type))) - - (defun time-subtract (t1 t2) - "Subtract two time values, T1 minus T2. -Return the difference in the format of a time value." - (with-decoded-time-value ((high low micro pico type t1) - (high2 low2 micro2 pico2 type2 t2)) - (setq high (- high high2) - low (- low low2) - micro (- micro micro2) - pico (- pico pico2) - type (max type type2)) - (when (< pico 0) - (setq micro (1- micro) - pico (+ pico 1000000))) - (when (< micro 0) - (setq low (1- low) - micro (+ micro 1000000))) - (when (< low 0) - (setq high (1- high) - low (+ low 65536))) - (encode-time-value high low micro pico type))) - - (defun time-less-p (t1 t2) - "Return non-nil if time value T1 is earlier than time value T2." - (with-decoded-time-value ((high1 low1 micro1 pico1 _type1 t1) - (high2 low2 micro2 pico2 _type2 t2)) - (or (< high1 high2) - (and (= high1 high2) - (or (< low1 low2) - (and (= low1 low2) - (or (< micro1 micro2) - (and (= micro1 micro2) - (< pico1 pico2))))))))))) +(define-obsolete-function-alias 'subtract-time 'time-subtract "26.1") ;;;###autoload (defun date-to-day (date) @@ -324,12 +245,7 @@ The Gregorian date Sunday, December 31, 1bce is imaginary." (defun time-to-number-of-days (time) "Return the number of days represented by TIME. Returns a floating point number." - (/ (funcall (eval-when-compile - (if (or (featurep 'emacs) - (and (fboundp 'float-time) - (subrp (symbol-function 'float-time)))) - 'float-time - 'time-to-seconds)) time) (* 60 60 24))) + (/ (float-time time) (* 60 60 24))) ;;;###autoload (defun safe-date-to-time (date) diff --git a/lisp/calendar/timeclock.el b/lisp/calendar/timeclock.el index 2bdfd98..3d9e246 100644 --- a/lisp/calendar/timeclock.el +++ b/lisp/calendar/timeclock.el @@ -532,18 +532,17 @@ non-nil, the amount returned will be relative to past time worked." (message "%s" string) string))) -(defalias 'timeclock-time-to-seconds (if (fboundp 'float-time) 'float-time - 'time-to-seconds)) - -(defalias 'timeclock-seconds-to-time 'seconds-to-time) +(define-obsolete-function-alias 'timeclock-time-to-seconds 'float-time "26.1") +(define-obsolete-function-alias 'timeclock-seconds-to-time 'seconds-to-time + "26.1") ;; Should today-only be removed in favor of timeclock-relative? - gm (defsubst timeclock-when-to-leave (&optional today-only) "Return a time value representing the end of today's workday. If TODAY-ONLY is non-nil, the value returned will be relative only to the time worked today, and not to past time." - (timeclock-seconds-to-time - (- (timeclock-time-to-seconds) + (seconds-to-time + (- (float-time) (let ((discrep (timeclock-find-discrep))) (if discrep (if today-only @@ -686,9 +685,8 @@ being logged for. Normally only \"in\" events specify a project." "\n") (if (equal (downcase code) "o") (setq timeclock-last-period - (- (timeclock-time-to-seconds now) - (timeclock-time-to-seconds - (cadr timeclock-last-event))) + (- (float-time now) + (float-time (cadr timeclock-last-event))) timeclock-discrepancy (+ timeclock-discrepancy timeclock-last-period))) @@ -723,14 +721,14 @@ recorded to disk. If MOMENT is non-nil, use that as the current time. This is only provided for coherency when used by `timeclock-discrepancy'." (if (equal (car timeclock-last-event) "i") - (- (timeclock-time-to-seconds moment) - (timeclock-time-to-seconds (cadr timeclock-last-event))) + (- (float-time moment) + (float-time (cadr timeclock-last-event))) timeclock-last-period)) (defsubst timeclock-entry-length (entry) "Return the length of ENTRY in seconds." - (- (timeclock-time-to-seconds (cadr entry)) - (timeclock-time-to-seconds (car entry)))) + (- (float-time (cadr entry)) + (float-time (car entry)))) (defsubst timeclock-entry-begin (entry) "Return the start time of ENTRY." @@ -765,8 +763,8 @@ This is only provided for coherency when used by (defsubst timeclock-entry-list-span (entry-list) "Return the total time in seconds spanned by ENTRY-LIST." - (- (timeclock-time-to-seconds (timeclock-entry-list-end entry-list)) - (timeclock-time-to-seconds (timeclock-entry-list-begin entry-list)))) + (- (float-time (timeclock-entry-list-end entry-list)) + (float-time (timeclock-entry-list-begin entry-list)))) (defsubst timeclock-entry-list-break (entry-list) "Return the total break time (span - length) in ENTRY-LIST." @@ -1137,7 +1135,7 @@ discrepancy, today's discrepancy, and the time worked today." last-date-limited nil) (if beg (error "Error in format of timelog file!") - (setq beg (timeclock-time-to-seconds (cadr event)))))) + (setq beg (float-time (cadr event)))))) ((equal (downcase (car event)) "o") (if (and (nth 2 event) (> (length (nth 2 event)) 0)) @@ -1145,7 +1143,7 @@ discrepancy, today's discrepancy, and the time worked today." (if (not beg) (error "Error in format of timelog file!") (setq timeclock-last-period - (- (timeclock-time-to-seconds (cadr event)) beg) + (- (float-time (cadr event)) beg) accum (+ timeclock-last-period accum) beg nil)) (if (equal last-date todays-date) @@ -1225,8 +1223,8 @@ HTML-P is non-nil, HTML markup is added." (insert project "
\n") (insert project "*\n")) (let ((proj-data (cdr (assoc project (timeclock-project-alist log)))) - (two-weeks-ago (timeclock-seconds-to-time - (- (timeclock-time-to-seconds today) + (two-weeks-ago (seconds-to-time + (- (float-time today) (* 2 7 24 60 60)))) two-week-len today-len) (while proj-data @@ -1278,17 +1276,17 @@ HTML-P is non-nil, HTML markup is added." -1 year ") (let* ((day-list (timeclock-day-list)) - (thirty-days-ago (timeclock-seconds-to-time - (- (timeclock-time-to-seconds today) + (thirty-days-ago (seconds-to-time + (- (float-time today) (* 30 24 60 60)))) - (three-months-ago (timeclock-seconds-to-time - (- (timeclock-time-to-seconds today) + (three-months-ago (seconds-to-time + (- (float-time today) (* 90 24 60 60)))) - (six-months-ago (timeclock-seconds-to-time - (- (timeclock-time-to-seconds today) + (six-months-ago (seconds-to-time + (- (float-time today) (* 180 24 60 60)))) - (one-year-ago (timeclock-seconds-to-time - (- (timeclock-time-to-seconds today) + (one-year-ago (seconds-to-time + (- (float-time today) (* 365 24 60 60)))) (time-in (vector (list t) (list t) (list t) (list t) (list t))) (time-out (vector (list t) (list t) (list t) (list t) (list t))) @@ -1303,12 +1301,11 @@ HTML-P is non-nil, HTML markup is added." (unless (time-less-p (timeclock-day-begin day) (aref lengths i)) - (let ((base (timeclock-time-to-seconds + (let ((base (float-time (timeclock-day-base (timeclock-day-begin day))))) (nconc (aref time-in i) - (list (- (timeclock-time-to-seconds - (timeclock-day-begin day)) + (list (- (float-time (timeclock-day-begin day)) base))) (let ((span (timeclock-day-span day)) (len (timeclock-day-length day)) @@ -1320,8 +1317,7 @@ HTML-P is non-nil, HTML markup is added." (when (and (> span 0) (> (/ (float len) (float span)) 0.70)) (nconc (aref time-out i) - (list (- (timeclock-time-to-seconds - (timeclock-day-end day)) + (list (- (float-time (timeclock-day-end day)) base))) (nconc (aref breaks i) (list (- span len)))) (if req diff --git a/lisp/emacs-lisp/ert.el b/lisp/emacs-lisp/ert.el index 7a914da..3d1b060 100644 --- a/lisp/emacs-lisp/ert.el +++ b/lisp/emacs-lisp/ert.el @@ -2460,7 +2460,7 @@ To be used in the ERT results buffer." stats) for end-time across (ert--stats-test-end-times stats) collect (list test - (float-time (subtract-time + (float-time (time-subtract end-time start-time)))))) (setq data (sort data (lambda (a b) (> (cl-second a) (cl-second b))))) diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index b20a6c9..8501e2c 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -6007,10 +6007,8 @@ Returns a list of the form (HIGH LOW), compatible with Emacs time format." (list (truncate (/ n 65536)) (truncate (mod n 65536))))) -(defalias 'erc-emacs-time-to-erc-time - (if (featurep 'xemacs) 'time-to-seconds 'float-time)) - -(defalias 'erc-current-time 'erc-emacs-time-to-erc-time) +(defalias 'erc-emacs-time-to-erc-time 'float-time) +(defalias 'erc-current-time 'float-time) (defun erc-time-diff (t1 t2) "Return the time difference in seconds between T1 and T2." diff --git a/lisp/files.el b/lisp/files.el index 21f7bdc..b737c10 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -3817,8 +3817,10 @@ This function returns either: ;; The entry MTIME should match the most recent ;; MTIME among matching files. (and cached-files - (= (time-to-seconds (nth 2 dir-elt)) - (apply #'max (mapcar (lambda (f) (time-to-seconds (nth 5 (file-attributes f)))) + (= (float-time (nth 2 dir-elt)) + (apply #'max (mapcar (lambda (f) + (float-time + (nth 5 (file-attributes f)))) cached-files)))))) ;; This cache entry is OK. dir-elt @@ -3860,7 +3862,7 @@ Return the new class name, which is a symbol named DIR." (seconds-to-time (if success (apply #'max (mapcar (lambda (file) - (time-to-seconds (nth 5 (file-attributes file)))) + (float-time (nth 5 (file-attributes file)))) files)) ;; If there was a problem, use the values we could get but ;; don't let the cache prevent future reads. diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el index dea8d1f..c103e1c 100644 --- a/lisp/gnus/gnus-art.el +++ b/lisp/gnus/gnus-art.el @@ -3596,7 +3596,7 @@ possible values." ;; If the date is seriously mangled, the timezone functions are ;; liable to bug out, so we ignore all errors. (let* ((now (current-time)) - (real-time (subtract-time now time)) + (real-time (time-subtract now time)) (real-sec (and real-time (+ (* (float (car real-time)) 65536) (cadr real-time)))) diff --git a/lisp/gnus/gnus-diary.el b/lisp/gnus/gnus-diary.el index af278b4..12ca9fc 100644 --- a/lisp/gnus/gnus-diary.el +++ b/lisp/gnus/gnus-diary.el @@ -161,7 +161,7 @@ There are currently two built-in format functions: (sched (gnus-diary-header-schedule extras)) (occur (nndiary-next-occurence sched (current-time))) (now (current-time)) - (real-time (subtract-time occur now))) + (real-time (time-subtract occur now))) (if (null real-time) "?????" (let* ((sec (+ (* (float (car real-time)) 65536) (cadr real-time))) diff --git a/lisp/gnus/gnus-group.el b/lisp/gnus/gnus-group.el index 3de2609..53a4ca7 100644 --- a/lisp/gnus/gnus-group.el +++ b/lisp/gnus/gnus-group.el @@ -4530,7 +4530,7 @@ or `gnus-group-catchup-group-hook'." "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number." (let* ((time (or (gnus-group-timestamp group) (list 0 0))) - (delta (subtract-time (current-time) time))) + (delta (time-subtract (current-time) time))) (+ (* (nth 0 delta) 65536.0) (nth 1 delta)))) diff --git a/lisp/gnus/nndiary.el b/lisp/gnus/nndiary.el index 71229dd..ffe7881 100644 --- a/lisp/gnus/nndiary.el +++ b/lisp/gnus/nndiary.el @@ -1278,27 +1278,27 @@ all. This may very well take some time.") (while (setq reminder (pop reminders)) (push (cond ((eq (cdr reminder) 'minute) - (subtract-time + (time-subtract (apply 'encode-time 0 (nthcdr 1 date-elts)) (seconds-to-time (* (car reminder) 60.0)))) ((eq (cdr reminder) 'hour) - (subtract-time + (time-subtract (apply 'encode-time 0 0 (nthcdr 2 date-elts)) (seconds-to-time (* (car reminder) 3600.0)))) ((eq (cdr reminder) 'day) - (subtract-time + (time-subtract (apply 'encode-time 0 0 0 (nthcdr 3 date-elts)) (seconds-to-time (* (car reminder) 86400.0)))) ((eq (cdr reminder) 'week) - (subtract-time + (time-subtract (apply 'encode-time 0 0 0 monday (nthcdr 4 date-elts)) (seconds-to-time (* (car reminder) 604800.0)))) ((eq (cdr reminder) 'month) - (subtract-time + (time-subtract (apply 'encode-time 0 0 0 1 (nthcdr 4 date-elts)) (seconds-to-time (* (car reminder) 18748800.0)))) ((eq (cdr reminder) 'year) - (subtract-time + (time-subtract (apply 'encode-time 0 0 0 1 1 (nthcdr 5 date-elts)) (seconds-to-time (* (car reminder) 400861056.0))))) res)) diff --git a/lisp/net/newst-backend.el b/lisp/net/newst-backend.el index 2596e56..41b2172 100644 --- a/lisp/net/newst-backend.el +++ b/lisp/net/newst-backend.el @@ -442,13 +442,6 @@ buffers *newsticker-wget-* will not be closed." ;; FIXME It is bad practice to define compat functions with such generic names. -;; This is not needed in Emacs >= 22.1. -(unless (fboundp 'time-add) - (require 'time-date);;FIXME - (defun time-add (t1 t2) - (with-no-warnings ; don't warn about obsolete time-to-seconds in 23.2 - (seconds-to-time (+ (time-to-seconds t1) (time-to-seconds t2)))))) - (unless (fboundp 'match-string-no-properties) (defalias 'match-string-no-properties 'match-string)) diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el index f2c8c5d..66e6326 100644 --- a/lisp/net/rcirc.el +++ b/lisp/net/rcirc.el @@ -611,10 +611,7 @@ If ARG is non-nil, instead prompt for connection parameters." `(with-current-buffer rcirc-server-buffer ,@body)) -(defalias 'rcirc-float-time - (if (featurep 'xemacs) - 'time-to-seconds - 'float-time)) +(define-obsolete-function-alias 'rcirc-float-time 'float-time "26.1") (defun rcirc-prompt-for-encryption (server-plist) "Prompt the user for the encryption method to use. @@ -638,7 +635,7 @@ last ping." (rcirc-send-ctcp process rcirc-nick (format "KEEPALIVE %f" - (rcirc-float-time)))))) + (float-time)))))) (rcirc-process-list)) ;; no processes, clean up timer (when (timerp rcirc-keepalive-timer) @@ -647,7 +644,7 @@ last ping." (defun rcirc-handler-ctcp-KEEPALIVE (process _target _sender message) (with-rcirc-process-buffer process - (setq header-line-format (format "%f" (- (rcirc-float-time) + (setq header-line-format (format "%f" (- (float-time) (string-to-number message)))))) (defvar rcirc-debug-buffer "*rcirc debug*") @@ -2342,7 +2339,7 @@ With a prefix arg, prompt for new topic." (defun rcirc-ctcp-sender-PING (process target _request) "Send a CTCP PING message to TARGET." - (let ((timestamp (format "%.0f" (rcirc-float-time)))) + (let ((timestamp (format "%.0f" (float-time)))) (rcirc-send-ctcp process target "PING" timestamp))) (defun rcirc-cmd-me (args &optional process target) diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index aa335d3..377b529 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -4124,7 +4124,7 @@ Invokes `password-read' if available, `read-passwd' else." (defun tramp-time-diff (t1 t2) "Return the difference between the two times, in seconds. T1 and T2 are time values (as returned by `current-time' for example)." - (float-time (subtract-time t1 t2))) + (float-time (time-subtract t1 t2))) ;; Currently (as of Emacs 20.5), the function `shell-quote-argument' ;; does not deal well with newline characters. Newline is replaced by diff --git a/lisp/org/org-agenda.el b/lisp/org/org-agenda.el index e77b53a..fd5253a 100644 --- a/lisp/org/org-agenda.el +++ b/lisp/org/org-agenda.el @@ -3903,7 +3903,7 @@ functions do." (defvar org-agenda-markers nil "List of all currently active markers created by `org-agenda'.") -(defvar org-agenda-last-marker-time (org-float-time) +(defvar org-agenda-last-marker-time (float-time) "Creation time of the last agenda marker.") (defun org-agenda-new-marker (&optional pos) @@ -3911,7 +3911,7 @@ functions do." Org-mode keeps a list of these markers and resets them when they are no longer in use." (let ((m (copy-marker (or pos (point))))) - (setq org-agenda-last-marker-time (org-float-time)) + (setq org-agenda-last-marker-time (float-time)) (if org-agenda-buffer (with-current-buffer org-agenda-buffer (push m org-agenda-markers)) @@ -5231,7 +5231,7 @@ So the example above may also be written as The function expects the lisp variables `entry' and `date' to be provided by the caller, because this is how the calendar works. Don't use this function from a program - use `org-agenda-get-day-entries' instead." - (when (> (- (org-float-time) + (when (> (- (float-time) org-agenda-last-marker-time) 5) ;; I am not sure if this works with sticky agendas, because the marker @@ -5243,7 +5243,7 @@ function from a program - use `org-agenda-get-day-entries' instead." (let* ((files (if (and entry (stringp entry) (string-match "\\S-" entry)) (list entry) (org-agenda-files t))) - (time (org-float-time)) + (time (float-time)) file rtn results) (when (or (not org-diary-last-run-time) (> (- time @@ -5912,9 +5912,9 @@ See also the user option `org-agenda-clock-consistency-checks'." (throw 'next t)) (setq ts (match-string 1) te (match-string 3) - ts (org-float-time + ts (float-time (apply 'encode-time (org-parse-time-string ts))) - te (org-float-time + te (float-time (apply 'encode-time (org-parse-time-string te))) dt (- te ts)))) (cond diff --git a/lisp/org/org-clock.el b/lisp/org/org-clock.el index 9374f5f..1ec17f4 100644 --- a/lisp/org/org-clock.el +++ b/lisp/org/org-clock.el @@ -658,8 +658,8 @@ If not, show simply the clocked time like 01:50." The time returned includes the time spent on this task in previous clocking intervals." (let ((currently-clocked-time - (floor (- (org-float-time) - (org-float-time org-clock-start-time)) 60))) + (floor (- (float-time) + (float-time org-clock-start-time)) 60))) (+ currently-clocked-time (or org-clock-total-time 0)))) (defun org-clock-modify-effort-estimate (&optional value) @@ -978,7 +978,7 @@ to be CLOCKED OUT.")))) nil 45))) (and (not (memq char-pressed '(?i ?q))) char-pressed))))) (default - (floor (/ (org-float-time + (floor (/ (float-time (time-subtract (current-time) last-valid)) 60))) (keep (and (memq ch '(?k ?K)) @@ -987,8 +987,8 @@ to be CLOCKED OUT.")))) (and (memq ch '(?g ?G)) (read-number "Got back how many minutes ago? " default))) (subtractp (memq ch '(?s ?S))) - (barely-started-p (< (- (org-float-time last-valid) - (org-float-time (cdr clock))) 45)) + (barely-started-p (< (- (float-time last-valid) + (float-time (cdr clock))) 45)) (start-over (and subtractp barely-started-p))) (cond ((memq ch '(?j ?J)) @@ -1047,8 +1047,8 @@ If `only-dangling-p' is non-nil, only ask to resolve dangling (lambda (clock) (format "Dangling clock started %d mins ago" - (floor (- (org-float-time) - (org-float-time (cdr clock))) + (floor (- (float-time) + (float-time (cdr clock))) 60))))) (or last-valid (cdr clock))))))))))) @@ -1057,7 +1057,7 @@ If `only-dangling-p' is non-nil, only ask to resolve dangling "Return the current Emacs idle time in seconds, or nil if not idle." (let ((idle-time (current-idle-time))) (if idle-time - (org-float-time idle-time) + (float-time idle-time) 0))) (defun org-mac-idle-seconds () @@ -1109,7 +1109,7 @@ so long." (function (lambda (clock) (format "Clocked in & idle for %.1f mins" - (/ (org-float-time + (/ (float-time (time-subtract (current-time) org-clock-user-idle-start)) 60.0)))) @@ -1271,9 +1271,9 @@ make this the default behavior.)" (y-or-n-p (format "You stopped another clock %d mins ago; start this one from then? " - (/ (- (org-float-time + (/ (- (float-time (org-current-time org-clock-rounding-minutes t)) - (org-float-time leftover)) 60))) + (float-time leftover)) 60))) leftover) start-time (org-current-time org-clock-rounding-minutes t))) @@ -1517,8 +1517,8 @@ to, overriding the existing value of `org-clock-out-switch-to-state'." (delete-region (point) (point-at-eol)) (insert "--") (setq te (org-insert-time-stamp (or at-time now) 'with-hm 'inactive)) - (setq s (- (org-float-time (apply 'encode-time (org-parse-time-string te))) - (org-float-time (apply 'encode-time (org-parse-time-string ts)))) + (setq s (- (float-time (apply 'encode-time (org-parse-time-string te))) + (float-time (apply 'encode-time (org-parse-time-string ts)))) h (floor (/ s 3600)) s (- s (* 3600 h)) m (floor (/ s 60)) @@ -1630,13 +1630,13 @@ Optional argument N tells to change by that many units." (let ((ts (if updatets1 ts2 ts1)) (begts (if updatets1 begts1 begts2))) (setq tdiff - (subtract-time + (time-subtract (org-time-string-to-time org-last-changed-timestamp) (org-time-string-to-time ts))) (save-excursion (goto-char begts) (org-timestamp-change - (round (/ (org-float-time tdiff) + (round (/ (float-time tdiff) (cond ((eq org-ts-what 'minute) 60) ((eq org-ts-what 'hour) 3600) ((eq org-ts-what 'day) (* 24 3600)) @@ -1739,8 +1739,8 @@ PROPNAME lets you set a custom text property instead of :org-clock-minutes." time) (if (stringp tstart) (setq tstart (org-time-string-to-seconds tstart))) (if (stringp tend) (setq tend (org-time-string-to-seconds tend))) - (if (consp tstart) (setq tstart (org-float-time tstart))) - (if (consp tend) (setq tend (org-float-time tend))) + (if (consp tstart) (setq tstart (float-time tstart))) + (if (consp tend) (setq tend (float-time tend))) (remove-text-properties (point-min) (point-max) `(,(or propname :org-clock-minutes) t :org-clock-force-headline-inclusion t)) @@ -1752,9 +1752,9 @@ PROPNAME lets you set a custom text property instead of :org-clock-minutes." ;; Two time stamps (setq ts (match-string 2) te (match-string 3) - ts (org-float-time + ts (float-time (apply 'encode-time (org-parse-time-string ts))) - te (org-float-time + te (float-time (apply 'encode-time (org-parse-time-string te))) ts (if tstart (max ts tstart) ts) te (if tend (min te tend) te) @@ -1771,10 +1771,10 @@ PROPNAME lets you set a custom text property instead of :org-clock-minutes." (equal (marker-position org-clock-hd-marker) (point)) tstart tend - (>= (org-float-time org-clock-start-time) tstart) - (<= (org-float-time org-clock-start-time) tend)) - (let ((time (floor (- (org-float-time) - (org-float-time org-clock-start-time)) 60))) + (>= (float-time org-clock-start-time) tstart) + (<= (float-time org-clock-start-time) tend)) + (let ((time (floor (- (float-time) + (float-time org-clock-start-time)) 60))) (setq t1 (+ t1 time)))) (let* ((headline-forced (get-text-property (point) @@ -2584,17 +2584,17 @@ from the dynamic block definition." ((numberp ts) ;; If ts is a number, it's an absolute day number from org-agenda. (destructuring-bind (month day year) (calendar-gregorian-from-absolute ts) - (setq ts (org-float-time (encode-time 0 0 0 day month year))))) + (setq ts (float-time (encode-time 0 0 0 day month year))))) (ts - (setq ts (org-float-time + (setq ts (float-time (apply 'encode-time (org-parse-time-string ts)))))) (cond ((numberp te) ;; Likewise for te. (destructuring-bind (month day year) (calendar-gregorian-from-absolute te) - (setq te (org-float-time (encode-time 0 0 0 day month year))))) + (setq te (float-time (encode-time 0 0 0 day month year))))) (te - (setq te (org-float-time + (setq te (float-time (apply 'encode-time (org-parse-time-string te)))))) (setq tsb (if (eq step0 'week) @@ -2788,9 +2788,9 @@ Otherwise, return nil." (end-of-line 1) (setq ts (match-string 1) te (match-string 3)) - (setq s (- (org-float-time + (setq s (- (float-time (apply 'encode-time (org-parse-time-string te))) - (org-float-time + (float-time (apply 'encode-time (org-parse-time-string ts)))) neg (< s 0) s (abs s) diff --git a/lisp/org/org-compat.el b/lisp/org/org-compat.el index cf6aafc..9a79a4b 100644 --- a/lisp/org/org-compat.el +++ b/lisp/org/org-compat.el @@ -411,8 +411,7 @@ Pass BUFFER to the XEmacs version of `move-to-column'." (when focus-follows-mouse (set-mouse-position frame (1- (frame-width frame)) 0))))) -(defalias 'org-float-time - (if (featurep 'xemacs) 'time-to-seconds 'float-time)) +(define-obsolete-function-alias 'org-float-time 'float-time "26.1") ;; `user-error' is only available from 24.2.50 on (unless (fboundp 'user-error) diff --git a/lisp/org/org-list.el b/lisp/org/org-list.el index 2c1e377..e119fbf 100644 --- a/lisp/org/org-list.el +++ b/lisp/org/org-list.el @@ -2884,7 +2884,7 @@ ignores hidden links." (save-excursion (re-search-forward org-ts-regexp-both (point-at-eol) t))) (org-time-string-to-seconds (match-string 0))) - (t (org-float-time now)))) + (t (float-time now)))) ((= dcst ?x) (or (and (stringp (match-string 1)) (match-string 1)) "")) diff --git a/lisp/org/org-timer.el b/lisp/org/org-timer.el index 667f602..079bed4 100644 --- a/lisp/org/org-timer.el +++ b/lisp/org/org-timer.el @@ -123,7 +123,7 @@ the region 0:00:00." (setq delta (org-timer-hms-to-secs (org-timer-fix-incomplete s))))) (setq org-timer-start-time (seconds-to-time - (- (org-float-time) delta)))) + (- (float-time) delta)))) (org-timer-set-mode-line 'on) (message "Timer start time set to %s, current value is %s" (format-time-string "%T" org-timer-start-time) @@ -142,9 +142,9 @@ With prefix arg STOP, stop it entirely." (setq org-timer-start-time (seconds-to-time (- - (org-float-time) - (- (org-float-time org-timer-pause-time) - (org-float-time org-timer-start-time)))) + (float-time) + (- (float-time org-timer-pause-time) + (float-time org-timer-start-time)))) org-timer-pause-time nil) (org-timer-set-mode-line 'on) (run-hooks 'org-timer-continue-hook) @@ -194,10 +194,10 @@ it in the buffer." (defvar org-timer-timer-is-countdown nil) (defun org-timer-seconds () (if org-timer-timer-is-countdown - (- (org-float-time org-timer-start-time) - (org-float-time)) - (- (org-float-time org-timer-pause-time) - (org-float-time org-timer-start-time)))) + (- (float-time org-timer-start-time) + (float-time)) + (- (float-time org-timer-pause-time) + (float-time org-timer-start-time)))) ;;;###autoload (defun org-timer-change-times-in-region (beg end delta) diff --git a/lisp/org/org.el b/lisp/org/org.el index 1921a59..e2fbf7b 100644 --- a/lisp/org/org.el +++ b/lisp/org/org.el @@ -5280,7 +5280,6 @@ This variable is set by `org-before-change-function'. ;; Other stuff we need. (require 'time-date) -(unless (fboundp 'time-subtract) (defalias 'time-subtract 'subtract-time)) (require 'easymenu) (require 'overlay) @@ -5514,8 +5513,8 @@ the rounding returns a past time." (apply 'encode-time (append (list 0 (* r (floor (+ .5 (/ (float (nth 1 time)) r))))) (nthcdr 2 time)))) - (if (and past (< (org-float-time (time-subtract (current-time) res)) 0)) - (seconds-to-time (- (org-float-time res) (* r 60))) + (if (and past (< (float-time (time-subtract (current-time) res)) 0)) + (seconds-to-time (- (float-time res) (* r 60))) res)))) (defun org-today () @@ -8779,24 +8778,24 @@ links." (if (or (re-search-forward org-ts-regexp end t) (re-search-forward org-ts-regexp-both end t)) (org-time-string-to-seconds (match-string 0)) - (org-float-time now)))) + (float-time now)))) ((= dcst ?c) (let ((end (save-excursion (outline-next-heading) (point)))) (if (re-search-forward (concat "^[ \t]*\\[" org-ts-regexp1 "\\]") end t) (org-time-string-to-seconds (match-string 0)) - (org-float-time now)))) + (float-time now)))) ((= dcst ?s) (let ((end (save-excursion (outline-next-heading) (point)))) (if (re-search-forward org-scheduled-time-regexp end t) (org-time-string-to-seconds (match-string 1)) - (org-float-time now)))) + (float-time now)))) ((= dcst ?d) (let ((end (save-excursion (outline-next-heading) (point)))) (if (re-search-forward org-deadline-time-regexp end t) (org-time-string-to-seconds (match-string 1)) - (org-float-time now)))) + (float-time now)))) ((= dcst ?p) (if (re-search-forward org-priority-regexp (point-at-eol) t) (string-to-char (match-string 2)) @@ -8860,7 +8859,7 @@ If WITH-CASE is non-nil, the sorting will be case-sensitive." (lambda (x) (if (or (string-match org-ts-regexp x) (string-match org-ts-regexp-both x)) - (org-float-time + (float-time (org-time-string-to-time (match-string 0 x))) 0)) comparefun (if (= dcst sorting-type) '< '>))) @@ -16886,7 +16885,7 @@ Don't touch the rest." (defun org-time-stamp-to-now (timestamp-string &optional seconds) "Difference between TIMESTAMP-STRING and now in days. If SECONDS is non-nil, return the difference in seconds." - (let ((fdiff (if seconds 'org-float-time 'time-to-days))) + (let ((fdiff (if seconds 'float-time 'time-to-days))) (- (funcall fdiff (org-time-string-to-time timestamp-string)) (funcall fdiff (current-time))))) @@ -17041,8 +17040,8 @@ days in order to avoid rounding problems." (match-end (match-end 0)) (time1 (org-time-string-to-time ts1)) (time2 (org-time-string-to-time ts2)) - (t1 (org-float-time time1)) - (t2 (org-float-time time2)) + (t1 (float-time time1)) + (t2 (float-time time2)) (diff (abs (- t2 t1))) (negative (< (- t2 t1) 0)) ;; (ys (floor (* 365 24 60 60))) @@ -17107,7 +17106,7 @@ days in order to avoid rounding problems." (defun org-time-string-to-seconds (s) "Convert a timestamp string to a number of seconds." - (org-float-time (org-time-string-to-time s))) + (float-time (org-time-string-to-time s))) (defun org-time-string-to-absolute (s &optional daynr prefer show-all buffer pos) "Convert a time stamp to an absolute day number. diff --git a/test/lisp/character-fold-tests.el b/test/lisp/character-fold-tests.el index c611217..dc7e927 100644 --- a/test/lisp/character-fold-tests.el +++ b/test/lisp/character-fold-tests.el @@ -109,16 +109,14 @@ (character-fold-to-regexp string))) (with-temp-buffer (save-excursion (insert string)) - (let ((time (time-to-seconds (current-time)))) + (let ((time (float-time))) ;; Our initial implementation of case-folding in char-folding ;; created a lot of redundant paths in the regexp. Because of ;; that, if a really long string "almost" matches, the regexp ;; engine took a long time to realize that it doesn't match. (should-not (character-fold-search-forward (concat string "c") nil 'noerror)) ;; Ensure it took less than a second. - (should (< (- (time-to-seconds (current-time)) - time) - 1)))))) + (should (< (- (float-time) time) 1)))))) (provide 'character-fold-tests) ;;; character-fold-tests.el ends here commit 2eb6817ba971184cc109f8530f4b3b38f65650ea Author: Alan Mackenzie Date: Sun May 8 13:24:20 2016 +0000 Add :after-hook facility to define-derived-mode. This allow a form to be evaluated _after_ a major mode's hooks have been run. It is needed to solve some problems in CC Mode, including bug #16759 and bug #23476. * lisp/emacs-lisp/derived.el (define-derived-mode): introduce the new argument `:after-hook', and generate the requisite code for it. (derived-mode-make-docstring): Take account of the possibility of :after-hook. * lisp/subr.el (delayed-after-hook-forms): New variable. (run-mode-hooks): As the last thing evaluate the forms in delayed-after-hook-forms. * doc/lispref/modes.texi (Derived Modes): Document :after-hook. (Mode Hooks): Document the new feature in run-mode-hooks. * etc/NEWS: Note the new feature. diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi index 76e5174..7b76e6a 100644 --- a/doc/lispref/modes.texi +++ b/doc/lispref/modes.texi @@ -752,7 +752,8 @@ The new mode has its own abbrev table, kept in the variable @item The new mode has its own mode hook, @code{@var{variant}-hook}. It runs this hook, after running the hooks of its ancestor modes, with -@code{run-mode-hooks}, as the last thing it does. @xref{Mode Hooks}. +@code{run-mode-hooks}, as the last thing it does, apart from running +any @code{:after-hook} form it may have. @xref{Mode Hooks}. @end itemize In addition, you can specify how to override other aspects of @@ -776,8 +777,9 @@ about the mode's hook, followed by the mode's keymap, at the end of this documentation string. If you omit @var{docstring}, @code{define-derived-mode} generates a documentation string. -The @var{keyword-args} are pairs of keywords and values. The values -are evaluated. The following keywords are currently supported: +The @var{keyword-args} are pairs of keywords and values. The values, +except for @code{:after-hook}'s, are evaluated. The following +keywords are currently supported: @table @code @item :syntax-table @@ -801,6 +803,15 @@ this mode. (Not all major modes have one.) Only the (still experimental and unadvertised) command @code{customize-mode} currently uses this. @code{define-derived-mode} does @emph{not} automatically define the specified customization group. + +@item :after-hook +This optional keyword specifies a single Lisp form to evaluate as the +final act of the mode function, after the mode hooks have been run. +It should not be quoted. Since the form might be evaluated after the +mode function has terminated, it should not access any element of the +mode function's local state. An @code{:after-hook} form is useful for +setting up aspects of the mode which depend on the user's settings, +which in turn may have been changed in a mode hook. @end table Here is a hypothetical example: @@ -912,12 +923,15 @@ Major modes should run their mode hook using this function. It is similar to @code{run-hooks} (@pxref{Hooks}), but it also runs @code{change-major-mode-after-body-hook}, @code{hack-local-variables} (when the buffer is visiting a file) (@pxref{File Local Variables}), -and @code{after-change-major-mode-hook}. +and @code{after-change-major-mode-hook}. The last thing it does is to +evaluate any @code{:after-hook} forms declared by parent modes +(@pxref{Derived Modes}). When this function is called during the execution of a @code{delay-mode-hooks} form, it does not run the hooks or -@code{hack-local-variables} immediately. Instead, it arranges for the -next call to @code{run-mode-hooks} to run them. +@code{hack-local-variables} or evaluate the forms immediately. +Instead, it arranges for the next call to @code{run-mode-hooks} to run +them. @end defun @defmac delay-mode-hooks body@dots{} diff --git a/etc/NEWS b/etc/NEWS index 92d301e..22eb2ea 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -369,6 +369,12 @@ variable. ** New var syntax-ppss-table to control the syntax-table used in syntax-ppss. ++++ +** `define-derived-mode' can now specify an :after-hook form, which +gets evaluated after the new mode's hook has run. This can be used to +incorporate configuration changes made in the mode hook into the +mode's setup. + ** Autoload files can be generated without timestamps, by setting 'autoload-timestamps' to nil. FIXME As an experiment, nil is the current default. diff --git a/lisp/emacs-lisp/derived.el b/lisp/emacs-lisp/derived.el index a615f9a..0f7691a 100644 --- a/lisp/emacs-lisp/derived.el +++ b/lisp/emacs-lisp/derived.el @@ -137,6 +137,9 @@ BODY can start with a bunch of keyword arguments. The following keyword :abbrev-table TABLE Use TABLE instead of the default (CHILD-abbrev-table). A nil value means to simply use the same abbrev-table as the parent. +:after-hook FORM + A single lisp form which is evaluated after the mode hooks have been + run. It should not be quoted. Here is how you could define LaTeX-Thesis mode as a variant of LaTeX mode: @@ -184,7 +187,8 @@ See Info node `(elisp)Derived Modes' for more details." (declare-abbrev t) (declare-syntax t) (hook (derived-mode-hook-name child)) - (group nil)) + (group nil) + (after-hook nil)) ;; Process the keyword args. (while (keywordp (car body)) @@ -192,6 +196,7 @@ See Info node `(elisp)Derived Modes' for more details." (`:group (setq group (pop body))) (`:abbrev-table (setq abbrev (pop body)) (setq declare-abbrev nil)) (`:syntax-table (setq syntax (pop body)) (setq declare-syntax nil)) + (`:after-hook (setq after-hook (pop body))) (_ (pop body)))) (setq docstring (derived-mode-make-docstring @@ -272,7 +277,11 @@ No problems result if this variable is not bound. ,@body ) ;; Run the hooks, if any. - (run-mode-hooks ',hook))))) + (run-mode-hooks ',hook) + ,@(when after-hook + `((if delay-mode-hooks + (push ',after-hook delayed-after-hook-forms) + ,after-hook))))))) ;; PUBLIC: find the ultimate class of a derived mode. @@ -344,7 +353,7 @@ which more-or-less shadow%s %s's corresponding table%s." (format "`%s' " parent)) "might have run,\nthis mode ")) (format "runs the hook `%s'" hook) - ", as the final step\nduring initialization."))) + ", as the final or penultimate step\nduring initialization."))) (unless (string-match "\\\\[{[]" docstring) ;; And don't forget to put the mode's keymap. diff --git a/lisp/subr.el b/lisp/subr.el index 094710b..0fa6404 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1736,6 +1736,11 @@ if it is empty or a duplicate." (make-variable-buffer-local 'delayed-mode-hooks) (put 'delay-mode-hooks 'permanent-local t) +(defvar delayed-after-hook-forms nil + "List of delayed :after-hook forms waiting to be run. +These forms come from `define-derived-mode'.") +(make-variable-buffer-local 'delayed-after-hook-forms) + (defvar change-major-mode-after-body-hook nil "Normal hook run in major mode functions, before the mode hooks.") @@ -1751,9 +1756,12 @@ If the variable `delay-mode-hooks' is non-nil, does not do anything, just adds the HOOKS to the list `delayed-mode-hooks'. Otherwise, runs hooks in the sequence: `change-major-mode-after-body-hook', `delayed-mode-hooks' (in reverse order), HOOKS, then runs -`hack-local-variables' and finally runs the hook -`after-change-major-mode-hook'. Major mode functions should use -this instead of `run-hooks' when running their FOO-mode-hook." +`hack-local-variables', runs the hook `after-change-major-mode-hook', and +finally evaluates the forms in `delayed-after-hook-forms' (see +`define-derived-mode'). + +Major mode functions should use this instead of `run-hooks' when +running their FOO-mode-hook." (if delay-mode-hooks ;; Delaying case. (dolist (hook hooks) @@ -1765,7 +1773,10 @@ this instead of `run-hooks' when running their FOO-mode-hook." (if (buffer-file-name) (with-demoted-errors "File local-variables error: %s" (hack-local-variables 'no-mode))) - (run-hooks 'after-change-major-mode-hook))) + (run-hooks 'after-change-major-mode-hook) + (dolist (form (nreverse delayed-after-hook-forms)) + (eval form)) + (setq delayed-after-hook-forms nil))) (defmacro delay-mode-hooks (&rest body) "Execute BODY, but delay any `run-mode-hooks'. commit 344eb61ab3607827930354589174bb8d270241b9 Merge: 6ef5944 e8bda38 Author: Michael Albinus Date: Sun May 8 11:47:33 2016 +0200 Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs commit 6ef5944516e8fda4ad13a71a473e2e4e6dde08ba Author: Michael Albinus Date: Sun May 8 11:47:08 2016 +0200 Fix recursive load of tramp.elc * lisp/net/tramp.el (tramp-completion-file-name-handler): Check also for `tramp-completion-mode-p'. (tramp-completion-mode, tramp-completion-mode-p): Autoload them. diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 87ccae1..aa335d3 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -2110,7 +2110,7 @@ Falls back to normal file name handler if no Tramp file name handler exists." (let ((fn (assoc operation tramp-completion-file-name-handler-alist))) (if (and ;; When `tramp-mode' is not enabled, we don't do anything. - fn tramp-mode + fn tramp-mode (tramp-completion-mode-p) ;; For other syntaxes than `sep', the regexp matches many common ;; situations where the user doesn't actually want to use Tramp. ;; So to avoid autoloading Tramp after typing just "/s", we @@ -2217,6 +2217,7 @@ Falls back to normal file name handler if no Tramp file name handler exists." ;;; File name handler functions for completion mode: +;;;###autoload (defvar tramp-completion-mode nil "If non-nil, external packages signal that they are in file name completion. @@ -2236,8 +2237,8 @@ should never be set globally, the intention is to let-bind it.") ;; Tramp file name syntax. Maybe another variable should be introduced ;; overwriting this check in such cases. Or we change Tramp file name ;; syntax in order to avoid ambiguities. -;;;###tramp-autoload -(defun tramp-completion-mode-p () +;;;###autoload +(progn (defun tramp-completion-mode-p () "Check, whether method / user name / host name completion is active." (or ;; Signal from outside. `non-essential' has been introduced in Emacs 24. @@ -2250,7 +2251,7 @@ should never be set globally, the intention is to let-bind it.") (equal last-input-event ?\t) (and (not (event-modifiers last-input-event)) (or (equal last-input-event ?\?) - (equal last-input-event ?\ ))))))) + (equal last-input-event ?\ )))))))) (defun tramp-connectable-p (filename) "Check, whether it is possible to connect the remote host w/o side-effects. commit e8bda380bb491eba325e78827eb33c4a0abfbdda Author: Paul Eggert Date: Sat May 7 18:40:10 2016 -0700 Prefer grep -E/-F to egrep/fgrep POSIX marked egrep and fgrep as legacy apps in SUSv2 (1997) and withdrew them in SUSv3 (2001), and these days grep -E and grep -F are probably more portable. * lib-src/etags.c (main): * lisp/eshell/em-unix.el (eshell-grep, eshell/egrep) (eshell/fgrep): * lisp/cedet/semantic/symref.el (semantic-symref-find-text): * lisp/eshell/esh-var.el (eshell-apply-indices): * lisp/progmodes/ada-xref.el (ada-xref-search-with-egrep) (ada-find-in-src-path): * lisp/textmodes/ispell.el (ispell-grep-command): (ispell-lookup-words): Use or document grep -E and grep -F instead of egrep and fgrep. * lisp/textmodes/ispell.el (ispell-grep-options): Use -Ei on all platforms, not just MS-Windows. diff --git a/lib-src/etags.c b/lib-src/etags.c index 01e2302..e8b71e6 100644 --- a/lib-src/etags.c +++ b/lib-src/etags.c @@ -1343,7 +1343,7 @@ main (int argc, char **argv) { char *cmd = xmalloc (strlen (tagfile) + whatlen_max + - sizeof "mv..OTAGS;fgrep -v '\t\t' OTAGS >;rm OTAGS"); + sizeof "mv..OTAGS;grep -Fv '\t\t' OTAGS >;rm OTAGS"); for (i = 0; i < current_arg; ++i) { switch (argbuffer[i].arg_type) @@ -1356,7 +1356,7 @@ main (int argc, char **argv) } char *z = stpcpy (cmd, "mv "); z = stpcpy (z, tagfile); - z = stpcpy (z, " OTAGS;fgrep -v '\t"); + z = stpcpy (z, " OTAGS;grep -Fv '\t"); z = stpcpy (z, argbuffer[i].what); z = stpcpy (z, "\t' OTAGS >"); z = stpcpy (z, tagfile); diff --git a/lisp/cedet/semantic/symref.el b/lisp/cedet/semantic/symref.el index 516a4f3..8b3196a 100644 --- a/lisp/cedet/semantic/symref.el +++ b/lisp/cedet/semantic/symref.el @@ -271,7 +271,7 @@ Optional SCOPE specifies which file set to search. Defaults to `project'. Refers to `semantic-symref-tool', to determine the reference tool to use for the current buffer. Returns an object of class `semantic-symref-result'." - (interactive "sEgrep style Regexp: ") + (interactive "sGrep -E style Regexp: ") (let* ((inst (semantic-symref-instantiate :searchfor text :searchtype 'regexp diff --git a/lisp/eshell/em-unix.el b/lisp/eshell/em-unix.el index c27c18c..e40dbde 100644 --- a/lisp/eshell/em-unix.el +++ b/lisp/eshell/em-unix.el @@ -748,7 +748,12 @@ external command." (cmd (progn (set-text-properties 0 (length args) '(invisible t) args) - (format "%s -n %s" command args))) + (format "%s -n %s" + (pcase command + ("egrep" "grep -E") + ("fgrep" "grep -F") + (x x)) + args))) compilation-scroll-output) (grep cmd))))) @@ -757,11 +762,11 @@ external command." (eshell-grep "grep" args t)) (defun eshell/egrep (&rest args) - "Use Emacs grep facility instead of calling external egrep." + "Use Emacs grep facility instead of calling external grep -E." (eshell-grep "egrep" args t)) (defun eshell/fgrep (&rest args) - "Use Emacs grep facility instead of calling external fgrep." + "Use Emacs grep facility instead of calling external grep -F." (eshell-grep "fgrep" args t)) (defun eshell/agrep (&rest args) diff --git a/lisp/eshell/esh-var.el b/lisp/eshell/esh-var.el index 7213ad7..5915efb 100644 --- a/lisp/eshell/esh-var.el +++ b/lisp/eshell/esh-var.el @@ -530,7 +530,7 @@ Integers imply a direct index, and names, an associate lookup using For example, to retrieve the second element of a user's record in '/etc/passwd', the variable reference would look like: - ${egrep johnw /etc/passwd}[: 2]" + ${grep johnw /etc/passwd}[: 2]" (while indices (let ((refs (car indices))) (when (stringp value) diff --git a/lisp/progmodes/ada-xref.el b/lisp/progmodes/ada-xref.el index 8518163..b3248d3 100644 --- a/lisp/progmodes/ada-xref.el +++ b/lisp/progmodes/ada-xref.el @@ -174,7 +174,7 @@ If GVD is not the debugger used, nothing happens." :type 'boolean :group 'ada) (defcustom ada-xref-search-with-egrep t - "If non-nil, use egrep to find the possible declarations for an entity. + "If non-nil, use grep -E to find the possible declarations for an entity. This alternate method is used when the exact location was not found in the information provided by GNAT. However, it might be expensive if you have a lot of sources, since it will search in all the files in your project." @@ -2013,7 +2013,7 @@ This function should be used when the standard algorithm that parses the exist. This function attempts to find the possible declarations for the identifier anywhere in the object path. -This command requires the external `egrep' program to be available. +This command requires the external `grep' program to be available. This works well when one is using an external library and wants to find the declaration and documentation of the subprograms one is using." diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el index 284fea4..0ed6c68 100644 --- a/lisp/textmodes/ispell.el +++ b/lisp/textmodes/ispell.el @@ -396,19 +396,15 @@ Always stores Fcc copy of message when nil." (defcustom ispell-grep-command - ;; MS-Windows/MS-DOS have `egrep' as a Unix shell script, so they - ;; cannot invoke it. Use "grep -E" instead (see ispell-grep-options - ;; below). - (if (memq system-type '(windows-nt ms-dos)) "grep" "egrep") + "grep" "Name of the grep command for search processes." :type 'string :group 'ispell) (defcustom ispell-grep-options - (if (memq system-type '(windows-nt ms-dos)) "-Ei" "-i") + "-Ei" "String of options to use when running the program in `ispell-grep-command'. -Should probably be \"-i\" or \"-e\". -Some machines (like the NeXT) don't support \"-i\"." +Should probably be \"-Ei\"." :type 'string :group 'ispell) @@ -2678,8 +2674,8 @@ SPC: Accept word this time. (defun ispell-lookup-words (word &optional lookup-dict) "Look up WORD in optional word-list dictionary LOOKUP-DICT. A `*' serves as a wild card. If no wild cards, `look' is used if it exists. -Otherwise the variable `ispell-grep-command' contains the command used to -search for the words (usually egrep). +Otherwise the variable `ispell-grep-command' contains the command +\(usually \"grep\") used to search for the words. Optional second argument contains the dictionary to use; the default is `ispell-alternate-dictionary', overridden by `ispell-complete-word-dict' commit 4c175a6af5f7935582208e197105cf67aa1b12bd Author: Dmitry Gutov Date: Sun May 8 02:01:22 2016 +0300 Avoid unnecessary work if a chunk is empty * lisp/jit-lock.el (jit-lock-fontify-now): Avoid unnecessary work if a chunk is empty (bug#23278). diff --git a/lisp/jit-lock.el b/lisp/jit-lock.el index c49fa6e..0d9abbc 100644 --- a/lisp/jit-lock.el +++ b/lisp/jit-lock.el @@ -394,58 +394,62 @@ Defaults to the whole buffer. END can be out of bounds." (setq next (or (text-property-any start end 'fontified t) end)) - ;; Fontify the chunk, and mark it as fontified. - ;; We mark it first, to make sure that we don't indefinitely - ;; re-execute this fontification if an error occurs. - (put-text-property start next 'fontified t) - (pcase-let - ;; `tight' is the part we've fully refontified, and `loose' - ;; is the part we've partly refontified (some of the - ;; functions have refontified it but maybe not all). - ((`(,tight-beg ,tight-end ,loose-beg ,_loose-end) - (condition-case err - (jit-lock--run-functions start next) - ;; If the user quits (which shouldn't happen in normal - ;; on-the-fly jit-locking), make sure the fontification - ;; will be performed before displaying the block again. - (quit (put-text-property start next 'fontified nil) - (signal (car err) (cdr err)))))) - - ;; In case we fontified more than requested, take advantage of the - ;; good news. - (when (or (< tight-beg start) (> tight-end next)) - (put-text-property tight-beg tight-end 'fontified t)) - - ;; Make sure the contextual refontification doesn't re-refontify - ;; what's already been refontified. - (when (and jit-lock-context-unfontify-pos - (< jit-lock-context-unfontify-pos tight-end) - (>= jit-lock-context-unfontify-pos tight-beg) - ;; Don't move boundary forward if we have to - ;; refontify previous text. Otherwise, we risk moving - ;; it past the end of the multiline property and thus - ;; forget about this multiline region altogether. - (not (get-text-property tight-beg - 'jit-lock-defer-multiline))) - (setq jit-lock-context-unfontify-pos tight-end)) - - ;; The redisplay engine has already rendered the buffer up-to - ;; `orig-start' and won't notice if the above jit-lock-functions - ;; changed the appearance of any part of the buffer prior - ;; to that. So if `loose-beg' is before `orig-start', we need to - ;; cause a new redisplay cycle after this one so that the changes - ;; are properly reflected on screen. - ;; To make such repeated redisplay happen less often, we can - ;; eagerly extend the refontified region with - ;; jit-lock-after-change-extend-region-functions. - (when (< loose-beg orig-start) - (run-with-timer 0 nil #'jit-lock-force-redisplay - (copy-marker loose-beg) - (copy-marker orig-start))) - - ;; Find the start of the next chunk, if any. - (setq start - (text-property-any tight-end end 'fontified nil))))))))) + ;; Avoid unnecessary work if the chunk is empty (bug#23278). + (when (> next start) + ;; Fontify the chunk, and mark it as fontified. + ;; We mark it first, to make sure that we don't indefinitely + ;; re-execute this fontification if an error occurs. + (put-text-property start next 'fontified t) + (pcase-let + ;; `tight' is the part we've fully refontified, and `loose' + ;; is the part we've partly refontified (some of the + ;; functions have refontified it but maybe not all). + ((`(,tight-beg ,tight-end ,loose-beg ,_loose-end) + (condition-case err + (jit-lock--run-functions start next) + ;; If the user quits (which shouldn't happen in normal + ;; on-the-fly jit-locking), make sure the fontification + ;; will be performed before displaying the block again. + (quit (put-text-property start next 'fontified nil) + (signal (car err) (cdr err)))))) + + ;; In case we fontified more than requested, take advantage of the + ;; good news. + (when (or (< tight-beg start) (> tight-end next)) + (put-text-property tight-beg tight-end 'fontified t)) + + ;; Make sure the contextual refontification doesn't re-refontify + ;; what's already been refontified. + (when (and jit-lock-context-unfontify-pos + (< jit-lock-context-unfontify-pos tight-end) + (>= jit-lock-context-unfontify-pos tight-beg) + ;; Don't move boundary forward if we have to + ;; refontify previous text. Otherwise, we risk moving + ;; it past the end of the multiline property and thus + ;; forget about this multiline region altogether. + (not (get-text-property tight-beg + 'jit-lock-defer-multiline))) + (setq jit-lock-context-unfontify-pos tight-end)) + + ;; The redisplay engine has already rendered the buffer up-to + ;; `orig-start' and won't notice if the above jit-lock-functions + ;; changed the appearance of any part of the buffer prior + ;; to that. So if `loose-beg' is before `orig-start', we need to + ;; cause a new redisplay cycle after this one so that the changes + ;; are properly reflected on screen. + ;; To make such repeated redisplay happen less often, we can + ;; eagerly extend the refontified region with + ;; jit-lock-after-change-extend-region-functions. + (when (< loose-beg orig-start) + (run-with-timer 0 nil #'jit-lock-force-redisplay + (copy-marker loose-beg) + (copy-marker orig-start))) + + ;; Skip to the end of the fully refontified part. + (setq start tight-end))) + ;; Find the start of the next chunk, if any. + (setq start + (text-property-any start end 'fontified nil)))))))) (defun jit-lock-force-redisplay (start end) "Force the display engine to re-render START's buffer from START to END. commit 950c9a5d4a1cc09b8171b41fa7e1b2647fa98514 Author: Dmitry Gutov Date: Sun May 8 02:00:25 2016 +0300 * test/lisp/jit-lock-tests.el: New file. diff --git a/test/lisp/jit-lock-tests.el b/test/lisp/jit-lock-tests.el new file mode 100644 index 0000000..26b9799 --- /dev/null +++ b/test/lisp/jit-lock-tests.el @@ -0,0 +1,58 @@ +;;; jit-lock-tests.el --- tests for jit-lock + +;; Copyright (C) 2016 Free Software Foundation, Inc. + +;; Author: Dmitry Gutov + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . + +;;; Commentary: + +;;; Code: + +(require 'jit-lock) +(require 'ert-x) + +(defun jit-lock-tests--setup-buffer () + (setq font-lock-defaults '(nil t)) + (font-lock-mode)) + +(ert-deftest jit-lock-fontify-now-fontifies-a-new-buffer () + (ert-with-test-buffer (:name "xxx") + (jit-lock-tests--setup-buffer) + (insert "xyz") + (jit-lock-fontify-now (point-min) (point-max)) + (should-not (text-property-not-all (point-min) (point-max) 'fontified t)))) + +(ert-deftest jit-lock-fontify-mends-the-gaps () + (ert-with-test-buffer (:name "xxx") + (jit-lock-tests--setup-buffer) + (insert "aaabbbcccddd") + (with-silent-modifications + (put-text-property 1 4 'fontified t) + (put-text-property 7 10 'fontified t)) + (jit-lock-fontify-now (point-min) (point-max)) + (should-not (text-property-not-all (point-min) (point-max) 'fontified t)))) + +(ert-deftest jit-lock-does-not-refontify-unnecessarily () + (ert-with-test-buffer (:name "xxx") + (setq font-lock-defaults + (list '(((lambda () (error "Don't call me")))) t)) + (font-lock-mode) + (insert "aaa") + (with-silent-modifications + (put-text-property (point-min) (point-max) 'fontified t)) + (jit-lock-fontify-now (point-min) (point-max)))) commit 97776f295d652aff97be91431ad53db5618ad2a2 Author: Michael Albinus Date: Sat May 7 22:52:30 2016 +0200 Continue to fix Bug#10085 * lisp/net/tramp.el (tramp-completion-file-name-handler-alist) : Add handler. (tramp-completion-handle-expand-file-name): New defun. (tramp-handle-file-name-as-directory): Handle completion mode case. * test/lisp/net/tramp-tests.el (tramp-test06-directory-file-name): Fix test. (tramp-test24-file-name-completion): Extend test. diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 3da60e9..87ccae1 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -1010,7 +1010,9 @@ means to use always cached values for the directory contents." ;;;###autoload (defconst tramp-completion-file-name-handler-alist - '((file-name-all-completions . tramp-completion-handle-file-name-all-completions) + '((expand-file-name . tramp-completion-handle-expand-file-name) + (file-name-all-completions + . tramp-completion-handle-file-name-all-completions) (file-name-completion . tramp-completion-handle-file-name-completion)) "Alist of completion handler functions. Used for file names matching `tramp-file-name-regexp'. Operations @@ -2261,6 +2263,23 @@ not in completion mode." (p (tramp-get-connection-process v))) (and p (processp p) (memq (process-status p) '(run open)))))))) +;;;###autoload +(defun tramp-completion-handle-expand-file-name + (name &optional dir) + "Like `expand-file-name' for Tramp files." + (if (tramp-completion-mode-p) + (progn + ;; If DIR is not given, use `default-directory' or "/". + (setq dir (or dir default-directory "/")) + ;; Unless NAME is absolute, concat DIR and NAME. + (unless (file-name-absolute-p name) + (setq name (concat (file-name-as-directory dir) name))) + ;; Return NAME. + name) + + (tramp-completion-run-real-handler + 'expand-file-name (list name dir)))) + ;; Method, host name and user name completion. ;; `tramp-completion-dissect-file-name' returns a list of ;; tramp-file-name structures. For all of them we return possible completions. @@ -2817,13 +2836,17 @@ User is always nil." ;; `file-name-as-directory' would be sufficient except localname is ;; the empty string. (let ((v (tramp-dissect-file-name file t))) - ;; Run the command on the localname portion only. + ;; Run the command on the localname portion only unless we are in + ;; completion mode. (tramp-make-tramp-file-name (tramp-file-name-method v) (tramp-file-name-user v) (tramp-file-name-host v) - (tramp-run-real-handler - 'file-name-as-directory (list (or (tramp-file-name-localname v) ""))) + (if (and (tramp-completion-mode-p) + (zerop (length (tramp-file-name-localname v)))) + "" + (tramp-run-real-handler + 'file-name-as-directory (list (or (tramp-file-name-localname v) "")))) (tramp-file-name-hop v)))) (defun tramp-handle-file-name-completion diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index efb19e9..a85eed0 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -649,7 +649,9 @@ This checks also `file-name-as-directory', `file-name-directory', (setq file (format "/%s:" file)) (should (string-equal (directory-file-name file) file)) (should - (string-equal (file-name-as-directory file) (concat file "./"))) + (string-equal + (file-name-as-directory file) + (if (tramp-completion-mode-p) file (concat file "./")))) (should (string-equal (file-name-directory file) file)) (should (string-equal (file-name-nondirectory file) ""))))))) @@ -1367,25 +1369,52 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." "Check `file-name-completion' and `file-name-all-completions'." (skip-unless (tramp--test-enabled)) - (let ((tmp-name (tramp--test-make-temp-name))) - (unwind-protect - (progn - (make-directory tmp-name) - (should (file-directory-p tmp-name)) - (write-region "foo" nil (expand-file-name "foo" tmp-name)) - (write-region "bar" nil (expand-file-name "bold" tmp-name)) - (make-directory (expand-file-name "boz" tmp-name)) - (should (equal (file-name-completion "fo" tmp-name) "foo")) - (should (equal (file-name-completion "b" tmp-name) "bo")) - (should - (equal (file-name-completion "b" tmp-name 'file-directory-p) "boz/")) - (should (equal (file-name-all-completions "fo" tmp-name) '("foo"))) - (should - (equal (sort (file-name-all-completions "b" tmp-name) 'string-lessp) - '("bold" "boz/")))) + (dolist (n-e '(nil t)) + (let ((non-essential n-e) + (tmp-name (tramp--test-make-temp-name)) + (method (file-remote-p tramp-test-temporary-file-directory 'method)) + (host (file-remote-p tramp-test-temporary-file-directory 'host))) + + (unwind-protect + (progn + ;; Method and host name in completion mode. + (when (tramp-completion-mode-p) + (unless (zerop (length method)) + (should + (member + (format "%s:" method) + (file-name-all-completions (substring method 0 1) "/")))) + (unless (zerop (length host)) + (should + (member + (format "%s:" host) + (file-name-all-completions (substring host 0 1) "/")))) + (unless (or (zerop (length method)) (zerop (length host))) + (should + (member + (format "%s:" host) + (file-name-all-completions + (substring host 0 1) (format "/%s:" method)))))) + + ;; Local files. + (make-directory tmp-name) + (should (file-directory-p tmp-name)) + (write-region "foo" nil (expand-file-name "foo" tmp-name)) + (write-region "bar" nil (expand-file-name "bold" tmp-name)) + (make-directory (expand-file-name "boz" tmp-name)) + (should (equal (file-name-completion "fo" tmp-name) "foo")) + (should (equal (file-name-completion "b" tmp-name) "bo")) + (should + (equal + (file-name-completion "b" tmp-name 'file-directory-p) "boz/")) + (should (equal (file-name-all-completions "fo" tmp-name) '("foo"))) + (should + (equal + (sort (file-name-all-completions "b" tmp-name) 'string-lessp) + '("bold" "boz/")))) - ;; Cleanup. - (ignore-errors (delete-directory tmp-name 'recursive))))) + ;; Cleanup. + (ignore-errors (delete-directory tmp-name 'recursive)))))) (ert-deftest tramp-test25-load () "Check `load'." commit 2ac39b069919bf71e614202aa96194c86934988c Author: Alan Mackenzie Date: Sat May 7 20:28:18 2016 +0000 Revert change 8e4595a... due to annoyance it causes the development team. Change 8e4595a438fe85dd109756886cdeaeea2e665afb from 2016-04-30 17:28:24 +0000 was an enhancement to .dir-locals to allow correct fontification of certain macro constructs. * .dir-locals.el: Remove the two forms for C Mode dealing with noise macros. diff --git a/.dir-locals.el b/.dir-locals.el index 1aa71ff..9853d7b 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -1,10 +1,7 @@ ((nil . ((tab-width . 8) (sentence-end-double-space . t) (fill-column . 70))) - (c-mode . ((c-file-style . "GNU") - (c-noise-macro-with-parens-names . ("IF_LINT")) - (eval . (c-make-noise-macro-regexps)) - )) + (c-mode . ((c-file-style . "GNU"))) (objc-mode . ((c-file-style . "GNU"))) (log-edit-mode . ((log-edit-font-lock-gnu-style . t) (log-edit-setup-add-author . t))) commit 23a071d87d1338866bcc91b29bead290d0d3878b Author: Alan Mackenzie Date: Sat May 7 17:10:36 2016 +0000 * lisp/emacs-lisp/edebug.el (edebug-sit-on-break): Give it a version number. diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el index 07a846f..c283c16 100644 --- a/lisp/emacs-lisp/edebug.el +++ b/lisp/emacs-lisp/edebug.el @@ -236,7 +236,8 @@ If the result is non-nil, then break. Errors are ignored." (defcustom edebug-sit-on-break t "Whether or not to pause for `edebug-sit-for-seconds' on reaching a break." :type 'boolean - :group 'edebug) + :group 'edebug + :version "25.2") ;;; Form spec utilities. commit 29c9803c2a368b2f821a3fd7f7798e1632e6e29d Author: Simen Heggestøyl Date: Sat May 7 16:32:29 2016 +0200 Add tests for CSS mode completion * test/lisp/textmodes/css-mode-tests.el (css-test-property-values) (css-test-property-values-no-duplicates) (css-test-value-class-lookup): Use `seq-sort'. (css-mode-tests--completions): New helper function for retrieving CSS completions. (css-test-complete-bang-rule, scss-test-complete-bang-rule) (css-test-complete-property-value, css-test-complete-pseudo-class) (css-test-complete-pseudo-element, css-test-complete-at-rule) (scss-test-complete-at-rule, css-test-complete-property) (css-test-complete-selector, css-test-complete-nested-selector) (scss-test-complete-nested-selector): New tests. diff --git a/test/lisp/textmodes/css-mode-tests.el b/test/lisp/textmodes/css-mode-tests.el index 4c0a357..80d678a 100644 --- a/test/lisp/textmodes/css-mode-tests.el +++ b/test/lisp/textmodes/css-mode-tests.el @@ -31,22 +31,23 @@ (ert-deftest css-test-property-values () ;; The `float' property has a flat value list. (should - (equal (sort (css--property-values "float") #'string-lessp) + (equal (seq-sort #'string-lessp (css--property-values "float")) '("left" "none" "right"))) ;; The `list-style' property refers to several other properties. (should - (equal (sort (css--property-values "list-style") #'string-lessp) - (sort (seq-uniq - (append (css--property-values "list-style-type") - (css--property-values "list-style-position") - (css--property-values "list-style-image"))) - #'string-lessp))) + (equal (seq-sort #'string-lessp (css--property-values "list-style")) + (seq-sort + #'string-lessp + (seq-uniq + (append (css--property-values "list-style-type") + (css--property-values "list-style-position") + (css--property-values "list-style-image")))))) ;; The `position' property is tricky because it's also the name of a ;; value class. (should - (equal (sort (css--property-values "position") #'string-lessp) + (equal (seq-sort #'string-lessp (css--property-values "position")) '("absolute" "fixed" "relative" "static"))) ;; The `background-position' property should refer to the `position' @@ -71,13 +72,116 @@ ;; The `flex' property is prone to duplicate values; if they aren't ;; removed, it'll contain at least two instances of `auto'. (should - (equal (sort (css--property-values "flex") #'string-lessp) + (equal (seq-sort #'string-lessp (css--property-values "flex")) '("auto" "calc()" "content" "none")))) (ert-deftest css-test-value-class-lookup () (should - (equal (sort (css--value-class-lookup 'position) #'string-lessp) + (equal (seq-sort #'string-lessp (css--value-class-lookup 'position)) '("bottom" "calc()" "center" "left" "right" "top")))) +;;; Completion + +(defun css-mode-tests--completions () + (let ((data (css-completion-at-point))) + (all-completions (buffer-substring (nth 0 data) (nth 1 data)) + (nth 2 data)))) + +(ert-deftest css-test-complete-bang-rule () + (with-temp-buffer + (css-mode) + (insert "body { left: 0 !") + (let ((completions (css-mode-tests--completions))) + (should (member "important" completions)) + ;; Don't include SCSS bang-rules + (should-not (member "default" completions))))) + +(ert-deftest scss-test-complete-bang-rule () + (with-temp-buffer + (scss-mode) + (insert "body { left: 0 !") + (let ((completions (css-mode-tests--completions))) + (should (member "important" completions)) + (should (member "default" completions))))) + +(ert-deftest css-test-complete-property-value () + (with-temp-buffer + (css-mode) + (insert "body { position: ") + (let ((completions (css-mode-tests--completions))) + (should + (equal (seq-sort #'string-lessp completions) + '("absolute" "fixed" "inherit" "relative" "static")))))) + +(ert-deftest css-test-complete-pseudo-class () + (with-temp-buffer + (css-mode) + (insert "body:a") + (let ((completions (css-mode-tests--completions))) + (should (member "active" completions)) + (should-not (member "disabled" completions)) + ;; Don't include pseudo-elements + (should-not (member "after" completions))))) + +(ert-deftest css-test-complete-pseudo-element () + (with-temp-buffer + (css-mode) + (insert "body::a") + (let ((completions (css-mode-tests--completions))) + (should (member "after" completions)) + (should-not (member "disabled" completions)) + ;; Don't include pseudo-classes + (should-not (member "active" completions))))) + +(ert-deftest css-test-complete-at-rule () + (with-temp-buffer + (css-mode) + (insert "@m") + (let ((completions (css-mode-tests--completions))) + (should (member "media" completions)) + (should-not (member "keyframes" completions)) + ;; Don't include SCSS at-rules + (should-not (member "mixin" completions))))) + +(ert-deftest scss-test-complete-at-rule () + (with-temp-buffer + (scss-mode) + (insert "@m") + (let ((completions (css-mode-tests--completions))) + (should (member "media" completions)) + (should-not (member "keyframes" completions)) + (should (member "mixin" completions))))) + +(ert-deftest css-test-complete-property () + (with-temp-buffer + (css-mode) + (insert "body { f") + (let ((completions (css-mode-tests--completions))) + (should (member "filter" completions)) + (should-not (member "position" completions))))) + +(ert-deftest css-test-complete-selector () + (with-temp-buffer + (css-mode) + (insert "b") + (let ((completions (css-mode-tests--completions))) + (should (member "body" completions)) + (should-not (member "article" completions))))) + +(ert-deftest css-test-complete-nested-selector () + (with-temp-buffer + (css-mode) + (insert "body {") + (let ((completions (css-mode-tests--completions))) + (should-not (member "body" completions))))) + +(ert-deftest scss-test-complete-nested-selector () + (with-temp-buffer + (scss-mode) + (insert "body { b") + (let ((completions (css-mode-tests--completions))) + (should (member "body" completions)) + (should-not (member "article" completions))))) + (provide 'css-mode-tests) ;;; css-mode-tests.el ends here commit ed5282d239b4304bcc6274dd06e1ce2b5e575053 Author: Alan Mackenzie Date: Sat May 7 06:42:29 2016 +0000 Add an option in Edebug to prevent pauses after `h', 'f', and `o'. Requested by Paul Pogonyshev. Also add in documentation for Edebug config variables which was missing. * lisp/emacs-lisp/edebug.el (edebug-sit-on-break): New customizable option. (edebug--display-1): Test edebug-sit-on-break before pausing 1 second. * doc/lispref/edebug.texi (Jumping): Document the effect of the new option. (Edebug Options): Document the new option. Also add documentation for edebug-eval-macro-args, edebug-print-length, edebug-print-level, edebug-print-circle, edebug-sit-for-seconds. * etc/NEWS: Note the new feature. diff --git a/doc/lispref/edebug.texi b/doc/lispref/edebug.texi index 47fe02a..65ccb64 100644 --- a/doc/lispref/edebug.texi +++ b/doc/lispref/edebug.texi @@ -384,6 +384,11 @@ now, it returns from the function and then stops. In other words, this command does not exit the currently executing function unless you are positioned after the last sexp. +Normally, the @kbd{h}, @kbd{f}, and @kbd{o} commands display ``Break'' +and pause for @code{edebug-sit-for-seconds} before showing the result +of the form just evaluated. You can avoid this pause by setting +@code{edebug-sit-on-break} to @code{nil}. @xref{Edebug Options}. + The @kbd{i} command steps into the function or macro called by the list form after point, and stops at its first stop point. Note that the form need not be the one about to be evaluated. But if the form is a @@ -1543,6 +1548,14 @@ Use the command @kbd{M-x edebug-all-forms} to toggle the value of this option. @xref{Instrumenting}. @end defopt +@defopt edebug-eval-macro-args +When this is non-@code{nil}, all macro arguments will be instrumented +in the generated code. For any macro, an @code{edebug-form-spec} +overrides this option. So to specify exceptions for macros that have +some arguments evaluated and some not, use @code{def-edebug-spec} to +specify an @code{edebug-form-spec}. +@end defopt + @defopt edebug-save-windows If this is non-@code{nil}, Edebug saves and restores the window configuration. That takes some time, so if your program does not care @@ -1601,6 +1614,21 @@ debugged. @xref{Edebug Execution Modes}. @end defopt +@defopt edebug-print-length +If non-@code{nil}, the default value of @code{print-length} for +printing results in Edebug. @xref{Output Variables}. +@end defopt + +@defopt edebug-print-level +If non-@code{nil}, the default value of @code{print-level} for +printing results in Edebug. @xref{Output Variables}. +@end defopt + +@defopt edebug-print-circle +If non-@code{nil}, the default value of @code{print-circle} for +printing results in Edebug. @xref{Output Variables}. +@end defopt + @defopt edebug-unwrap-results If non-@code{nil}, Edebug tries to remove any of its own instrumentation when showing the results of expressions. This is @@ -1647,3 +1675,14 @@ If non-@code{nil}, an expression to test for at every stop point. If the result is non-@code{nil}, then break. Errors are ignored. @xref{Global Break Condition}. @end defopt + +@defopt edebug-sit-for-seconds +Number of seconds to pause when a breakpoint is reached and the execution +mode is trace or continue. @xref{Edebug Execution Modes}. +@end defopt + +@defopt edebug-sit-on-break +Whether or not to pause for @code{edebug-sit-for-seconds} on reaching +a breakpoint. Set to @code{nil} to prevent the pause, non-@code{nil} +to allow it. +@end defopt diff --git a/etc/NEWS b/etc/NEWS index 1d5d0d6..92d301e 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -203,6 +203,12 @@ this is controlled by the 'wdired-create-parent-directories' variable. *** 'W' is now bound to 'browse-url-of-dired-file', and is useful for viewing HTML files and the like. +** Ediff + +*** Ediff can be prevented from pausing 1 second after reaching a +breakpoint (e.g. with "f" and "o") by customizing the new option +`edebug-sit-on-break'. + ** eww +++ diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el index e8484fa..07a846f 100644 --- a/lisp/emacs-lisp/edebug.el +++ b/lisp/emacs-lisp/edebug.el @@ -233,6 +233,11 @@ If the result is non-nil, then break. Errors are ignored." :type 'number :group 'edebug) +(defcustom edebug-sit-on-break t + "Whether or not to pause for `edebug-sit-for-seconds' on reaching a break." + :type 'boolean + :group 'edebug) + ;;; Form spec utilities. (defun get-edebug-spec (symbol) @@ -2489,6 +2494,7 @@ MSG is printed after `::::} '." (progn ;; Display result of previous evaluation. (if (and edebug-break + edebug-sit-on-break (not (eq edebug-execution-mode 'Continue-fast))) (sit-for edebug-sit-for-seconds)) ; Show message. (edebug-previous-result))) commit bf7fc7a8047752b6b1cff65dc8b8e2bc8173f626 Author: Jorgen Schaefer Date: Sat May 7 12:22:48 2016 +0200 scheme.el: Turn literal tabs into \t * lisp/progmodes/scheme.el: The last change to turn tabs into spaces also caught some literal tabs in character classes. Fix this by adding \t to those classes. diff --git a/lisp/progmodes/scheme.el b/lisp/progmodes/scheme.el index 1cb71fa..66d9ed6 100644 --- a/lisp/progmodes/scheme.el +++ b/lisp/progmodes/scheme.el @@ -425,7 +425,7 @@ that variable's value is a string." (eval-when-compile (list ;; Similar to Scheme - (list "(\\(define\\(-\\w+\\)?\\)\\>[ ]*\\((?\\)\\(\\sw+\\)\\>" + (list "(\\(define\\(-\\w+\\)?\\)\\>[ \t]*\\((?\\)\\(\\sw+\\)\\>" '(1 font-lock-keyword-face) '(4 font-lock-function-name-face)) (cons @@ -437,10 +437,10 @@ that variable's value is a string." "\\)\\>") 1) ;; DSSSL syntax - '("(\\(element\\|mode\\|declare-\\w+\\)\\>[ ]*\\(\\sw+\\)" + '("(\\(element\\|mode\\|declare-\\w+\\)\\>[ \t]*\\(\\sw+\\)" (1 font-lock-keyword-face) (2 font-lock-type-face)) - '("(\\(element\\)\\>[ ]*(\\(\\S)+\\))" + '("(\\(element\\)\\>[ \t]*(\\(\\S)+\\))" (1 font-lock-keyword-face) (2 font-lock-type-face)) '("\\<\\sw+:\\>" . font-lock-constant-face) ; trailing `:' c.f. scheme