commit 72ac4461676c49b7c580c40c2df10e02411fd320 (HEAD, refs/remotes/origin/master) Author: Stefan Monnier Date: Fri Apr 23 18:51:40 2021 -0400 * lisp/subr.el (remove-hook): Improve last change Don't put a `hook--depth-alist` property if there isn't one already. diff --git a/lisp/subr.el b/lisp/subr.el index 6589faf239..40ca934117 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1920,9 +1920,9 @@ one will be removed." (when old-fun ;; Remove auxiliary depth info to avoid leaks (bug#46414) ;; and to avoid the list growing too long. - (put hook 'hook--depth-alist - (delq (assq old-fun (get hook 'hook--depth-alist)) - (get hook 'hook--depth-alist)))) + (let* ((depths (get hook 'hook--depth-alist)) + (di (assq old-fun depths))) + (when di (put hook 'hook--depth-alist (delq di depths))))) ;; If the function is on the global hook, we need to shadow it locally ;;(when (and local (member function (default-value hook)) ;; (not (member (cons 'not function) hook-value))) @@ -5018,7 +5018,7 @@ See also `with-eval-after-load'." (funcall func) (let ((lfn load-file-name) ;; Don't use letrec, because equal (in - ;; add/remove-hook) would get trapped in a cycle + ;; add/remove-hook) could get trapped in a cycle ;; (bug#46326). (fun (make-symbol "eval-after-load-helper"))) (fset fun (lambda (file) @@ -5607,7 +5607,7 @@ to deactivate this transient map, regardless of KEEP-PRED." (internal-pop-keymap map 'overriding-terminal-local-map) (remove-hook 'pre-command-hook clearfun) (when on-exit (funcall on-exit))))) - ;; Don't use letrec, because equal (in add/remove-hook) would get trapped + ;; Don't use letrec, because equal (in add/remove-hook) could get trapped ;; in a cycle. (bug#46326) (fset clearfun (lambda () commit 87d37e279f464d5e2124ca1fe3b05f8cfe20080a Author: Amin Bandali Date: Fri Apr 23 18:49:37 2021 -0400 Fix thinko introduced in the last ERC patch (bug#47788) * lisp/erc/erc-backend.el (erc-open-network-stream): Need to use apply to call open-network-stream with the supplied arguments because of the plist p of arguments. Thanks to neverwas for pointing it out. diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el index 67db572701..ea9f9a3261 100644 --- a/lisp/erc/erc-backend.el +++ b/lisp/erc/erc-backend.el @@ -515,7 +515,7 @@ The current buffer is given by BUFFER." (defun erc-open-network-stream (name buffer host service &rest parameters) "Like `open-network-stream', but does non-blocking IO." (let ((p (plist-put parameters :nowait t))) - (open-network-stream name buffer host service p))) + (apply #'open-network-stream name buffer host service p))) (defun erc-server-connect (server port buffer &optional client-certificate) "Perform the connection and login using the specified SERVER and PORT. commit 2868199564fd0319e0d324d075d6f91153931e51 Author: Stefan Monnier Date: Fri Apr 23 17:17:40 2021 -0400 * lisp/files.el (minibuffer-with-setup-hook): Fix bug#46326 diff --git a/lisp/files.el b/lisp/files.el index 7440c11a21..ee16abfd44 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -1648,13 +1648,14 @@ rather than FUN itself, to `minibuffer-setup-hook'." (when (eq (car-safe fun) :append) (setq append '(t) fun (cadr fun))) `(let ((,funsym ,fun) - ,hook) - (setq ,hook - (lambda () - ;; Clear out this hook so it does not interfere - ;; with any recursive minibuffer usage. - (remove-hook 'minibuffer-setup-hook ,hook) - (funcall ,funsym))) + ;; Use a symbol to make sure `add-hook' doesn't waste time + ;; in `equal'ity testing (bug#46326). + (,hook (make-symbol "minibuffer-setup"))) + (fset ,hook (lambda () + ;; Clear out this hook so it does not interfere + ;; with any recursive minibuffer usage. + (remove-hook 'minibuffer-setup-hook ,hook) + (funcall ,funsym))) (unwind-protect (progn (add-hook 'minibuffer-setup-hook ,hook ,@append) diff --git a/lisp/subr.el b/lisp/subr.el index d9fb404c80..6589faf239 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1918,7 +1918,8 @@ one will be removed." (when (setq old-fun (car (member function hook-value))) (setq hook-value (remq old-fun hook-value)))) (when old-fun - ;; Remove auxiliary depth info to avoid leaks. + ;; Remove auxiliary depth info to avoid leaks (bug#46414) + ;; and to avoid the list growing too long. (put hook 'hook--depth-alist (delq (assq old-fun (get hook 'hook--depth-alist)) (get hook 'hook--depth-alist)))) @@ -5017,7 +5018,8 @@ See also `with-eval-after-load'." (funcall func) (let ((lfn load-file-name) ;; Don't use letrec, because equal (in - ;; add/remove-hook) would get trapped in a cycle. + ;; add/remove-hook) would get trapped in a cycle + ;; (bug#46326). (fun (make-symbol "eval-after-load-helper"))) (fset fun (lambda (file) (when (equal file lfn) @@ -5606,7 +5608,7 @@ to deactivate this transient map, regardless of KEEP-PRED." (remove-hook 'pre-command-hook clearfun) (when on-exit (funcall on-exit))))) ;; Don't use letrec, because equal (in add/remove-hook) would get trapped - ;; in a cycle. + ;; in a cycle. (bug#46326) (fset clearfun (lambda () (with-demoted-errors "set-transient-map PCH: %S" commit db92e83797bf2f1af4e0b0383283a49968746b51 Author: Stefan Monnier Date: Fri Apr 23 16:50:12 2021 -0400 * lisp/subr.el (add-hook): Try and fix bug#46326 Use `eq` indexing on `hook--depth-alist`. (remove-hook): Remove old entries from `hook--depth-alist`. diff --git a/lisp/subr.el b/lisp/subr.el index c2be26a15f..d9fb404c80 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1830,12 +1830,13 @@ function, it is changed to a list of functions." (unless (member function hook-value) (when (stringp function) ;FIXME: Why? (setq function (purecopy function))) + ;; All those `equal' tests performed between functions can end up being + ;; costly since those functions may be large recursive and even cyclic + ;; structures, so we index `hook--depth-alist' with `eq'. (bug#46326) (when (or (get hook 'hook--depth-alist) (not (zerop depth))) ;; Note: The main purpose of the above `when' test is to avoid running ;; this `setf' before `gv' is loaded during bootstrap. - (setf (alist-get function (get hook 'hook--depth-alist) - 0 'remove #'equal) - depth)) + (push (cons function depth) (get hook 'hook--depth-alist))) (setq hook-value (if (< 0 depth) (append hook-value (list function)) @@ -1845,8 +1846,8 @@ function, it is changed to a list of functions." (setq hook-value (sort (if (< 0 depth) hook-value (copy-sequence hook-value)) (lambda (f1 f2) - (< (alist-get f1 depth-alist 0 nil #'equal) - (alist-get f2 depth-alist 0 nil #'equal)))))))) + (< (alist-get f1 depth-alist 0 nil #'eq) + (alist-get f2 depth-alist 0 nil #'eq)))))))) ;; Set the actual variable (if local (progn @@ -1907,11 +1908,20 @@ one will be removed." (not (and (consp (symbol-value hook)) (memq t (symbol-value hook))))) (setq local t)) - (let ((hook-value (if local (symbol-value hook) (default-value hook)))) + (let ((hook-value (if local (symbol-value hook) (default-value hook))) + (old-fun nil)) ;; Remove the function, for both the list and the non-list cases. (if (or (not (listp hook-value)) (eq (car hook-value) 'lambda)) - (if (equal hook-value function) (setq hook-value nil)) - (setq hook-value (delete function (copy-sequence hook-value)))) + (when (equal hook-value function) + (setq old-fun hook-value) + (setq hook-value nil)) + (when (setq old-fun (car (member function hook-value))) + (setq hook-value (remq old-fun hook-value)))) + (when old-fun + ;; Remove auxiliary depth info to avoid leaks. + (put hook 'hook--depth-alist + (delq (assq old-fun (get hook 'hook--depth-alist)) + (get hook 'hook--depth-alist)))) ;; If the function is on the global hook, we need to shadow it locally ;;(when (and local (member function (default-value hook)) ;; (not (member (cons 'not function) hook-value))) commit 5d287b4605d11dfbe56f77c719942198a807ba58 Author: Michael Albinus Date: Fri Apr 23 19:57:50 2021 +0200 * lisp/net/tramp-cmds.el (tramp-recompile-elpa-command-completion-p): Check, whether Tramp has a package description. diff --git a/lisp/net/tramp-cmds.el b/lisp/net/tramp-cmds.el index 6342cf5287..a3cf6f3211 100644 --- a/lisp/net/tramp-cmds.el +++ b/lisp/net/tramp-cmds.el @@ -482,7 +482,8 @@ It is completed by \"M-x TAB\" only if package.el is loaded, and Tramp is an installed ELPA package." ;; We cannot apply `package-installed-p', this would also return the ;; builtin package. - (tramp-compat-funcall 'package--user-installed-p 'tramp)) + (and (assq 'tramp (bound-and-true-p package-alist)) + (tramp-compat-funcall 'package--user-installed-p 'tramp))) ;;;###tramp-autoload (defun tramp-recompile-elpa () commit 57cc2e94f724d11838f4a90827a26ea187bae675 Author: Juri Linkov Date: Fri Apr 23 19:52:22 2021 +0300 * lisp/wdired.el (wdired--before-change-fn): Wrap body in save-match-data. Suggested by Michael Heerdegen (bug#14013) diff --git a/lisp/wdired.el b/lisp/wdired.el index 05b0a0cfb2..35211bcf86 100644 --- a/lisp/wdired.el +++ b/lisp/wdired.el @@ -295,27 +295,28 @@ or \\[wdired-abort-changes] to abort changes"))) (put 'wdired--self-insert 'delete-selection 'delete-selection-uses-region-p) (defun wdired--before-change-fn (beg end) - (save-excursion - ;; Make sure to process entire lines. - (goto-char end) - (setq end (line-end-position)) - (goto-char beg) - (forward-line 0) - - (while (< (point) end) - (unless (wdired--line-preprocessed-p) + (save-match-data + (save-excursion + ;; Make sure to process entire lines. + (goto-char end) + (setq end (line-end-position)) + (goto-char beg) + (forward-line 0) + + (while (< (point) end) + (unless (wdired--line-preprocessed-p) + (with-silent-modifications + (put-text-property (point) (1+ (point)) 'front-sticky t) + (wdired--preprocess-files) + (when wdired-allow-to-change-permissions + (wdired--preprocess-perms)) + (when (fboundp 'make-symbolic-link) + (wdired--preprocess-symlinks)))) + (forward-line)) + (when (eobp) (with-silent-modifications - (put-text-property (point) (1+ (point)) 'front-sticky t) - (wdired--preprocess-files) - (when wdired-allow-to-change-permissions - (wdired--preprocess-perms)) - (when (fboundp 'make-symbolic-link) - (wdired--preprocess-symlinks)))) - (forward-line)) - (when (eobp) - (with-silent-modifications - ;; Is this good enough? Assumes no extra white lines from dired. - (put-text-property (1- (point-max)) (point-max) 'read-only t))))) + ;; Is this good enough? Assumes no extra white lines from dired. + (put-text-property (1- (point-max)) (point-max) 'read-only t)))))) (defun wdired-isearch-filter-read-only (beg end) "Skip matches that have a read-only property." commit beb3d04698aa625aafbb04167ef45ac5e371cae2 Author: Eli Zaretskii Date: Fri Apr 23 16:33:36 2021 +0300 ; * etc/NEWS: Fix quoting. diff --git a/etc/NEWS b/etc/NEWS index e90fcf0f1d..7d600eb374 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2272,7 +2272,7 @@ The old names are now obsolete. --- *** 'world-clock-mode' can no longer be turned on interactively. -Use `world-clock' to turn on that mode. +Use 'world-clock' to turn on that mode. ** D-Bus commit e44a0b7c79e20cd1841bd59f7a2c2a0698a1a3cd Author: Eli Zaretskii Date: Fri Apr 23 16:32:37 2021 +0300 Fix a recent change in minibuf.texi * doc/lispref/minibuf.texi (Basic Completion) (Programmed Completion): Improve wording, punctuation, and markup of a recently-added text. diff --git a/doc/lispref/minibuf.texi b/doc/lispref/minibuf.texi index faee43b21a..7cf2fcf68f 100644 --- a/doc/lispref/minibuf.texi +++ b/doc/lispref/minibuf.texi @@ -980,17 +980,17 @@ and @var{suffix} holds the text after point. Normally completion operates on the whole string, so for all normal collections, this will always return @code{(0 . (length -@var{suffix}))}. But more complex completion such as completion on -files is done one field at a time. For example, completion of +@var{suffix}))}. But more complex completion, such as completion on +files, is done one field at a time. For example, completion of @code{"/usr/sh"} will include @code{"/usr/share/"} but not @code{"/usr/share/doc"} even if @code{"/usr/share/doc"} exists. Also @code{all-completions} on @code{"/usr/sh"} will not include @code{"/usr/share/"} but only @code{"share/"}. So if @var{string} is @code{"/usr/sh"} and @var{suffix} is @code{"e/doc"}, -@code{completion-boundaries} will return @code{(5 . 1)} which tells us +@code{completion-boundaries} will return @w{@code{(5 . 1)}} which tells us that the @var{collection} will only return completion information that pertains to the area after @code{"/usr/"} and before @code{"/doc"}. -@code{try-completion} is not affected by nontrivial boundaries; i.e., +@code{try-completion} is not affected by nontrivial boundaries; e.g., @code{try-completion} on @code{"/usr/sh"} might still return @code{"/usr/share/"}, not @code{"share/"}. @end defun @@ -1897,11 +1897,11 @@ should return @code{(boundaries @var{start} . @var{end})}, where string, and @var{end} is the position of the end boundary in @var{suffix}. -If you return nontrivial boundaries, make sure that the +If a Lisp program returns nontrivial boundaries, it should make sure that the @code{all-completions} operation is consistent with them. The completions returned by @code{all-completions} should only pertain to the piece of the prefix and suffix covered by the completion -boundaries. @ref{Basic Completion} for the precise expected semantics +boundaries. @xref{Basic Completion}, for the precise expected semantics of completion boundaries. @item metadata commit 87e5cc2ccbe3423640cd95d60f0b588d9d2bd029 Author: Stefan Kangas Date: Fri Apr 23 15:14:13 2021 +0200 ; * etc/NEWS: Fix typo. diff --git a/etc/NEWS b/etc/NEWS index 76fff77ae6..e90fcf0f1d 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2272,7 +2272,7 @@ The old names are now obsolete. --- *** 'world-clock-mode' can no longer be turned on interactively. -Use 'display-time-world' to turn on that mode. +Use `world-clock' to turn on that mode. ** D-Bus commit 2595b4cf9ea689f2ad3c639cfcdbf1b05c4cef07 Author: Eli Zaretskii Date: Fri Apr 23 16:02:42 2021 +0300 ; * etc/NEWS: Fix a recently added entry. diff --git a/etc/NEWS b/etc/NEWS index c97a5abf1b..76fff77ae6 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2271,7 +2271,8 @@ The following user options have been renamed: The old names are now obsolete. --- -*** `world-clock-mode' is no longer interactive. +*** 'world-clock-mode' can no longer be turned on interactively. +Use 'display-time-world' to turn on that mode. ** D-Bus commit 1fd1ef176c6702e1504b425b9bcf506d99e060b0 Author: Stefan Kangas Date: Fri Apr 23 14:31:40 2021 +0200 * etc/NEWS: 'world-clock-mode' is no longer interactive. diff --git a/etc/NEWS b/etc/NEWS index 61904767b9..c97a5abf1b 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2270,6 +2270,9 @@ The following user options have been renamed: The old names are now obsolete. +--- +*** `world-clock-mode' is no longer interactive. + ** D-Bus +++ commit 3995f0515ab0b0e359f9976d589eed45f38eaa6d Author: Philipp Stephani Date: Fri Apr 23 13:01:51 2021 +0200 Expand documentation on nontrivial completion boundaries. The interplay between nontrivial completion boundaries and the other completion functions is somewhat subtle, so it deserves a bit more explanation. * doc/lispref/minibuf.texi (Basic Completion) (Programmed Completion): Add a few more remarks about nontrivial completion boundaries. diff --git a/doc/lispref/minibuf.texi b/doc/lispref/minibuf.texi index f012bfef07..faee43b21a 100644 --- a/doc/lispref/minibuf.texi +++ b/doc/lispref/minibuf.texi @@ -990,6 +990,9 @@ Also @code{all-completions} on @code{"/usr/sh"} will not include @code{completion-boundaries} will return @code{(5 . 1)} which tells us that the @var{collection} will only return completion information that pertains to the area after @code{"/usr/"} and before @code{"/doc"}. +@code{try-completion} is not affected by nontrivial boundaries; i.e., +@code{try-completion} on @code{"/usr/sh"} might still return +@code{"/usr/share/"}, not @code{"share/"}. @end defun If you store a completion alist in a variable, you should mark the @@ -1894,6 +1897,13 @@ should return @code{(boundaries @var{start} . @var{end})}, where string, and @var{end} is the position of the end boundary in @var{suffix}. +If you return nontrivial boundaries, make sure that the +@code{all-completions} operation is consistent with them. The +completions returned by @code{all-completions} should only pertain to +the piece of the prefix and suffix covered by the completion +boundaries. @ref{Basic Completion} for the precise expected semantics +of completion boundaries. + @item metadata This specifies a request for information about the state of the current completion. The return value should have the form commit 3806d2168bdc36796d2dfac5f743582f0ce71c72 Author: Philipp Stephani Date: Fri Apr 23 12:52:51 2021 +0200 Fix small bug in 'completion-table-subvert'. Even for a trivial underlying completion table (where the 'boundaries' action returns nil), we need to provide nontrivial boundaries so that they match the behavior of 'all-completions'. * lisp/minibuffer.el (completion-table-subvert): Return boundaries even for trivial underlying completion table. * test/lisp/minibuffer-tests.el (completion-table-subvert-test): Amend unit test to also test boundaries. While there, also test the other completion functions. diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 7da3c39e6b..51e0519d48 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -271,7 +271,7 @@ the form (concat S2 S)." (let* ((str (if (string-prefix-p s1 string completion-ignore-case) (concat s2 (substring string (length s1))))) (res (if str (complete-with-action action table str pred)))) - (when res + (when (or res (eq (car-safe action) 'boundaries)) (cond ((eq (car-safe action) 'boundaries) (let ((beg (or (and (eq (car-safe res) 'boundaries) (cadr res)) 0))) diff --git a/test/lisp/minibuffer-tests.el b/test/lisp/minibuffer-tests.el index 791e51cdcd..027711c21e 100644 --- a/test/lisp/minibuffer-tests.el +++ b/test/lisp/minibuffer-tests.el @@ -83,7 +83,12 @@ (let* ((origtable '("A-hello" "A-there")) (subvtable (completion-table-subvert origtable "B" "A"))) (should (equal (try-completion "B-hel" subvtable) - "B-hello")))) + "B-hello")) + (should (equal (all-completions "B-hel" subvtable) '("-hello"))) + (should (test-completion "B-hello" subvtable)) + (should (equal (completion-boundaries "B-hel" subvtable + nil "suffix") + '(1 . 6))))) (ert-deftest completion-table-test-quoting () (let ((process-environment