From eb3a90619fed86298c96951af527a8483bdd1a3c Mon Sep 17 00:00:00 2001 From: Jim Porter Date: Thu, 4 May 2023 21:04:46 -0700 Subject: [PATCH 1/9] ; Allow spaces in directory names for Git hooks * build-aux/git-hooks/post-commit: * build-aux/git-hooks/pre-push: Quote "$HOOKS_DIR" to allow spaces. --- build-aux/git-hooks/post-commit | 2 +- build-aux/git-hooks/pre-push | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build-aux/git-hooks/post-commit b/build-aux/git-hooks/post-commit index 10f43b539ac..12cae09206a 100755 --- a/build-aux/git-hooks/post-commit +++ b/build-aux/git-hooks/post-commit @@ -44,4 +44,4 @@ else fi git rev-parse HEAD | $awk -v reason=post-commit \ - -f $HOOKS_DIR/commit-msg-files.awk + -f "$HOOKS_DIR"/commit-msg-files.awk diff --git a/build-aux/git-hooks/pre-push b/build-aux/git-hooks/pre-push index 8d5dde2bbaf..420aae3492b 100755 --- a/build-aux/git-hooks/pre-push +++ b/build-aux/git-hooks/pre-push @@ -85,4 +85,4 @@ $awk -v origin_name="$1" ' # Print every SHA after oldref, up to (and including) newref. system("git rev-list --first-parent --reverse " oldref ".." newref) } -' | $awk -v reason=pre-push -f $HOOKS_DIR/commit-msg-files.awk +' | $awk -v reason=pre-push -f "$HOOKS_DIR"/commit-msg-files.awk From f204c4a6cfa77fdbb2573b728110576e206b0b20 Mon Sep 17 00:00:00 2001 From: Jim Porter Date: Thu, 4 May 2023 22:43:13 -0700 Subject: [PATCH 2/9] ; Use a Bourne shell-compatible form for command substitution * build-aux/git-hooks/post-commit: * build-aux/git-hooks/pre-push: Use `` instead of $(). --- build-aux/git-hooks/post-commit | 2 +- build-aux/git-hooks/pre-push | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build-aux/git-hooks/post-commit b/build-aux/git-hooks/post-commit index 12cae09206a..e02fee48db4 100755 --- a/build-aux/git-hooks/post-commit +++ b/build-aux/git-hooks/post-commit @@ -34,7 +34,7 @@ ### Code: -HOOKS_DIR=$(dirname $0) +HOOKS_DIR=`dirname "$0"` # Prefer gawk if available, as it handles NUL bytes properly. if type gawk >/dev/null 2>&1; then diff --git a/build-aux/git-hooks/pre-push b/build-aux/git-hooks/pre-push index 420aae3492b..a342814c1e3 100755 --- a/build-aux/git-hooks/pre-push +++ b/build-aux/git-hooks/pre-push @@ -31,7 +31,7 @@ ### Code: -HOOKS_DIR=$(dirname $0) +HOOKS_DIR=`dirname "$0"` # Prefer gawk if available, as it handles NUL bytes properly. if type gawk >/dev/null 2>&1; then From 778a1ee35b46017ab06c13c8a29f054533bc952b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Engdeg=C3=A5rd?= Date: Fri, 5 May 2023 19:19:51 +0200 Subject: [PATCH 3/9] Fix dired and tramp where `ls` does not have the `-N` option This includes BSD ls, also used by macOS (bug#63142). * lisp/dired.el (dired-insert-directory): * lisp/net/tramp-sh.el (tramp-sh-handle-insert-directory): Test whether -N is understood by ls since that option is used along with --dired. Remove -N when we remove --dired. --- lisp/dired.el | 6 +++--- lisp/net/tramp-sh.el | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lisp/dired.el b/lisp/dired.el index 1c8d011d765..e70467ca53b 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -1647,9 +1647,9 @@ If HDR is non-nil, insert a header line with the directory name." ;; save the answer in `dired-use-ls-dired'. (or (setq dired-use-ls-dired (eq 0 (call-process insert-directory-program - nil nil nil "--dired"))) + nil nil nil "--dired" "-N"))) (progn - (message "ls does not support --dired; \ + (message "ls does not support --dired -N; \ see `dired-use-ls-dired' for more details.") nil)) dired-use-ls-dired))) @@ -1665,7 +1665,7 @@ see `dired-use-ls-dired' for more details.") ;; "--dired", so we cannot add it to the `process-file' ;; call for wildcards. (when (file-remote-p dir) - (setq switches (string-replace "--dired" "" switches))) + (setq switches (string-replace "--dired -N" "" switches))) (let* ((default-directory (car dir-wildcard)) (script (format "ls %s %s" switches (cdr dir-wildcard))) (remotep (file-remote-p dir)) diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 94fbc588b5d..d020615af07 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -2566,7 +2566,7 @@ The method used must be an out-of-band method." (setq switches (append switches (split-string (tramp-sh--quoting-style-options v)))) (unless (tramp-get-ls-command-with v "--dired") - (setq switches (delete "--dired" switches))) + (setq switches (delete "-N" (delete "--dired" switches)))) (when wildcard (setq wildcard (tramp-run-real-handler #'file-name-nondirectory (list localname))) From f6476f8536853bd3e5577c76f619c7a9710cc46a Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Fri, 5 May 2023 19:39:22 +0200 Subject: [PATCH 4/9] Improve ange-ftp-file-remote-p * lisp/net/ange-ftp.el (ange-ftp-file-remote-p): Handle hop identification. --- lisp/net/ange-ftp.el | 1 + 1 file changed, 1 insertion(+) diff --git a/lisp/net/ange-ftp.el b/lisp/net/ange-ftp.el index 1c20a27801d..16ec33f92dc 100644 --- a/lisp/net/ange-ftp.el +++ b/lisp/net/ange-ftp.el @@ -4242,6 +4242,7 @@ directory, so that Emacs will know its current contents." ((eq identification 'user) user) ((eq identification 'host) host) ((eq identification 'localname) localname) + ((eq identification 'hop) nil) (t (ange-ftp-replace-name-component file "")))))) (defun ange-ftp-load (file &optional noerror nomessage nosuffix must-suffix) From 0e8d8a72284f6b3aaa1bbce73d41c7d84bbc4d3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Fri, 5 May 2023 19:44:11 +0100 Subject: [PATCH 5/9] Fido-mode: never shadow 'external' completion style As explained in the manual (20.7.2 Fast minibuffer selection) 'fido-mode' and 'fido-vertical-mode' give priority the "flex" completion style. In fact, bug#62015 was recently fixed in commit because that priority was not taking place correctly and some completions were missed. However, an exception must be made for the 'external' completion style. That style, made available by the lisp/external-completion.el library, is specifically designed to work with backends that provide only a partial view of all completions. If we allow 'flex' to step in front of 'external' it could mean that 'flex' matches something and 'external' isn't triggered as it probably should. To reproduce have the rust-mode ELPA package and the rust-analyzer LSP server handy. Then: emacs -Q -f package-initialize main.rs Where main.rs is this content: fn foo1() {} fn foo2() {} fn foo3() {} fn foobar1() {} fn foobar2() {} fn foobar3() {} The rust-analyzer server can be quickly configured to return only 3 workspace symbols max, so evaluate: (setq-default eglot-workspace-configuration '(:rust-analyzer (:workspace (:symbol (:search (:limit 3)))))) Now start M-x eglot and M-x fido-vertical-mode and type C-u M-. to find an arbitrary symbol in this one-file project. Type 'f'. You will see the three foo's are listed, correctly. Now type '3'. You will only see "foo3". But that's wrong because "foobar3" was available, if only the server had been asked for it. This commit fixes the situation and no completions are lost. As an unfortunate side-effect of this commit, the fontification of completions-common-part on the matches is lost, but that is not worse than missing out on completions and there are better ways to recover the fontification anyway (in external-completion.el). See also: https://github.com/joaotavora/eglot/discussions/1219#discussioncomment-5818336 * lisp/icomplete.el (icomplete--fido-ccd): Do not touch entries with 'external in them. --- lisp/icomplete.el | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lisp/icomplete.el b/lisp/icomplete.el index 6ed2cbe395c..e6fdd1f1836 100644 --- a/lisp/icomplete.el +++ b/lisp/icomplete.el @@ -427,7 +427,10 @@ if that doesn't produce a completion match." for (cat . alist) in completion-category-defaults collect `(,cat . ,(cl-loop for entry in alist for (prop . val) = entry - if (eq prop 'styles) + if (and (eq prop 'styles) + ;; Never step in front of 'external', as that + ;; might lose us completions. + (not (memq 'external val))) collect `(,prop . (flex ,@(delq 'flex val))) else collect entry)))) From 1438574dd73a097293f8cfe356c3459cec6ee005 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Engdeg=C3=A5rd?= Date: Thu, 4 May 2023 17:28:08 +0200 Subject: [PATCH 6/9] Don't inline funcall to literal lambda form * lisp/emacs-lisp/byte-opt.el (byte-optimize-funcall): Don't convert (funcall '(lambda ...) ...) -> ((lambda ...) ...) because that would inline what is essentially an `eval` of a function using dynamic binding rules into lexbound code. --- lisp/emacs-lisp/byte-opt.el | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el index 0f7a3cb2665..d859706c180 100644 --- a/lisp/emacs-lisp/byte-opt.el +++ b/lisp/emacs-lisp/byte-opt.el @@ -1420,10 +1420,13 @@ See Info node `(elisp) Integer Basics'." (defun byte-optimize-funcall (form) - ;; (funcall (lambda ...) ...) ==> ((lambda ...) ...) - ;; (funcall foo ...) ==> (foo ...) - (let ((fn (nth 1 form))) - (if (memq (car-safe fn) '(quote function)) + ;; (funcall #'(lambda ...) ...) -> ((lambda ...) ...) + ;; (funcall #'SYM ...) -> (SYM ...) + ;; (funcall 'SYM ...) -> (SYM ...) + (let* ((fn (nth 1 form)) + (head (car-safe fn))) + (if (or (eq head 'function) + (and (eq head 'quote) (symbolp (nth 1 fn)))) (cons (nth 1 fn) (cdr (cdr form))) form))) From 3b038d46e24532bc4bca56f37d30afd70fae388d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Engdeg=C3=A5rd?= Date: Thu, 4 May 2023 17:31:15 +0200 Subject: [PATCH 7/9] Remove useless handling of erroneous code in Lisp optimiser * lisp/emacs-lisp/byte-opt.el (byte-optimize-form-code-walker): ((closure ...) ...) is a malformed function call; treat it as such. Better malformed function warning location. --- lisp/emacs-lisp/byte-opt.el | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el index d859706c180..d046c4d401c 100644 --- a/lisp/emacs-lisp/byte-opt.el +++ b/lisp/emacs-lisp/byte-opt.el @@ -469,10 +469,6 @@ for speeding up processing.") form (byte-optimize-form newform for-effect)))) - ;; FIXME: Strictly speaking, I think this is a bug: (closure...) - ;; is a *value* and shouldn't appear in the car. - (`((closure . ,_) . ,_) form) - (`(setq ,var ,expr) (let ((lexvar (assq var byte-optimize--lexvars)) (value (byte-optimize-form expr nil))) @@ -500,7 +496,7 @@ for speeding up processing.") (cons fn (mapcar #'byte-optimize-form exps))) (`(,(pred (not symbolp)) . ,_) - (byte-compile-warn-x fn "`%s' is a malformed function" fn) + (byte-compile-warn-x form "`%s' is a malformed function" fn) form) ((guard (when for-effect From 044392c5c563a0bb2c24b65e5222b8f9b3cbe0d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Engdeg=C3=A5rd?= Date: Thu, 4 May 2023 17:37:17 +0200 Subject: [PATCH 8/9] Constant-propagate cons and vector literals * lisp/emacs-lisp/byte-opt.el (byte-optimize--substitutable-p): Allow quoted lists and conses, and vector literals, to be substituted from lexical variables. This can eliminate variable bindings and create new constant folding opportunities. --- lisp/emacs-lisp/byte-opt.el | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el index d046c4d401c..8fe5066c49e 100644 --- a/lisp/emacs-lisp/byte-opt.el +++ b/lisp/emacs-lisp/byte-opt.el @@ -221,21 +221,17 @@ for speeding up processing.") (defun byte-optimize--substitutable-p (expr) "Whether EXPR is a constant that can be propagated." - ;; Only consider numbers, symbols and strings to be values for substitution - ;; purposes. Numbers and symbols are immutable, and mutating string - ;; literals (or results from constant-evaluated string-returning functions) - ;; can be considered undefined. - ;; (What about other quoted values, like conses?) (or (booleanp expr) (numberp expr) - (stringp expr) - (and (consp expr) - (or (and (memq (car expr) '(quote function)) - (symbolp (cadr expr))) - ;; (internal-get-closed-var N) can be considered constant for - ;; const-prop purposes. - (and (eq (car expr) 'internal-get-closed-var) - (integerp (cadr expr))))) + (arrayp expr) + (let ((head (car-safe expr))) + (cond ((eq head 'quote) t) + ;; Don't substitute #'(lambda ...) since that would enable + ;; uncontrolled inlining. + ((eq head 'function) (symbolp (cadr expr))) + ;; (internal-get-closed-var N) can be considered constant for + ;; const-prop purposes. + ((eq head 'internal-get-closed-var) (integerp (cadr expr))))) (keywordp expr))) (defmacro byte-optimize--pcase (exp &rest cases) From 1ef219e220c9645a5592eb73837aba8d50e4265c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Engdeg=C3=A5rd?= Date: Thu, 4 May 2023 17:47:05 +0200 Subject: [PATCH 9/9] Make old-struct test more robust * test/lisp/emacs-lisp/cl-lib-tests.el (old-struct): Use the `vector` constructor instead of vector literals to avoid failing because of `type-of` constant-folding. --- test/lisp/emacs-lisp/cl-lib-tests.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/lisp/emacs-lisp/cl-lib-tests.el b/test/lisp/emacs-lisp/cl-lib-tests.el index 4e1a0fd63a2..b14731c4d0a 100644 --- a/test/lisp/emacs-lisp/cl-lib-tests.el +++ b/test/lisp/emacs-lisp/cl-lib-tests.el @@ -530,7 +530,7 @@ (ert-deftest old-struct () (cl-defstruct foo x) - (let ((x [cl-struct-foo]) + (let ((x (vector 'cl-struct-foo)) (saved cl-old-struct-compat-mode)) (cl-old-struct-compat-mode -1) (should (eq (type-of x) 'vector)) @@ -540,7 +540,7 @@ (let ((cl-struct-foo (cl--struct-get-class 'foo))) (setf (symbol-function 'cl-struct-foo) :quick-object-witness-check) (should (eq (type-of x) 'foo)) - (should (eq (type-of [foo]) 'vector))) + (should (eq (type-of (vector 'foo)) 'vector))) (cl-old-struct-compat-mode (if saved 1 -1))))