commit 750bc57cbb8d081566e671e8fc3e27a82588c197 (HEAD, refs/remotes/origin/master) Author: Stefan Monnier Date: Sat Feb 18 12:56:24 2023 -0500 Don't rely on dynamic scoping to fix bug#59213 Rather than look up a dynamically scoped var to decide whether to trim closures, use an ad-hoc marker on those closures which should not be trimmed. * lisp/emacs-lisp/cconv.el (cconv-dont-trim-unused-variables): Delete var. (cconv-make-interpreted-closure): Use a `:closure-dont-trim-context` markers instead. * lisp/emacs-lisp/edebug.el (edebug-make-enter-wrapper): Use `:closure-dont-trim-context` rather than `cconv-dont-trim-unused-variables`. * lisp/emacs-lisp/testcover.el (testcover-analyze-coverage): Remove workaround for `cconv-dont-trim-unused-variables`. * test/lisp/emacs-lisp/cconv-tests.el (cconv-safe-for-space): New test. diff --git a/lisp/emacs-lisp/cconv.el b/lisp/emacs-lisp/cconv.el index b8121aeba55..940a1045625 100644 --- a/lisp/emacs-lisp/cconv.el +++ b/lisp/emacs-lisp/cconv.el @@ -113,10 +113,6 @@ cconv--interactive-form-funs (defvar cconv--dynbound-variables nil "List of variables known to be dynamically bound.") -(defvar cconv-dont-trim-unused-variables nil - "When bound to non-nil, don't remove unused variables from the environment. -This is intended for use by edebug and similar.") - ;;;###autoload (defun cconv-closure-convert (form &optional dynbound-vars) "Main entry point for closure conversion. @@ -882,15 +878,22 @@ cconv-fv (cons fvs dyns))))) (defun cconv-make-interpreted-closure (fun env) + ;; FIXME: I don't know what "This function is evaluated both at + ;; compile time and run time" is intended to mean here. "Make a closure for the interpreter. This function is evaluated both at compile time and run time. FUN, the closure's function, must be a lambda form. ENV, the closure's environment, is a mixture of lexical bindings of the form -(SYMBOL . VALUE) and symbols which indicate dynamic bindings of those +\(SYMBOL . VALUE) and symbols which indicate dynamic bindings of those symbols." (cl-assert (eq (car-safe fun) 'lambda)) (let ((lexvars (delq nil (mapcar #'car-safe env)))) - (if (or cconv-dont-trim-unused-variables (null lexvars)) + (if (or (null lexvars) + ;; Functions with a `:closure-dont-trim-context' marker + ;; should keep their whole context untrimmed (bug#59213). + (and (eq :closure-dont-trim-context (nth 2 fun)) + ;; Check the function doesn't just return the magic keyword. + (nthcdr 3 fun))) ;; The lexical environment is empty, or needs to be preserved, ;; so there's no need to look for free variables. ;; Attempting to replace ,(cdr fun) by a macroexpanded version diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el index 735a358cdba..552526b6efc 100644 --- a/lisp/emacs-lisp/edebug.el +++ b/lisp/emacs-lisp/edebug.el @@ -1217,16 +1217,18 @@ edebug-make-enter-wrapper (setq edebug-old-def-name nil)) (setq edebug-def-name (or edebug-def-name edebug-old-def-name (gensym "edebug-anon"))) - `(let ((cconv-dont-trim-unused-variables t)) - (edebug-enter - (quote ,edebug-def-name) - ,(if edebug-inside-func - `(list - ;; Doesn't work with more than one def-body!! - ;; But the list will just be reversed. - ,@(nreverse edebug-def-args)) - 'nil) - (function (lambda () ,@forms))))) + `(edebug-enter + (quote ,edebug-def-name) + ,(if edebug-inside-func + `(list + ;; Doesn't work with more than one def-body!! + ;; But the list will just be reversed. + ,@(nreverse edebug-def-args)) + 'nil) + ;; Make sure `forms' is not nil so we don't accidentally return + ;; the magic keyword. Mark the closure so we don't throw away + ;; unused vars (bug#59213). + #'(lambda () :closure-dont-trim-context ,@(or forms '(nil))))) (defvar edebug-form-begin-marker) ; the mark for def being instrumented diff --git a/lisp/emacs-lisp/testcover.el b/lisp/emacs-lisp/testcover.el index 1212905f08a..ed31b90ca32 100644 --- a/lisp/emacs-lisp/testcover.el +++ b/lisp/emacs-lisp/testcover.el @@ -442,11 +442,6 @@ testcover-analyze-coverage (let ((testcover-vector (get sym 'edebug-coverage))) (testcover-analyze-coverage-progn body))) - (`(let ((cconv-dont-trim-unused-variables t)) - (edebug-enter ',sym ,_ (function (lambda nil . ,body)))) - (let ((testcover-vector (get sym 'edebug-coverage))) - (testcover-analyze-coverage-progn body))) - (`(edebug-after ,(and before-form (or `(edebug-before ,before-id) before-id)) ,after-id ,wrapped-form) diff --git a/test/lisp/emacs-lisp/cconv-tests.el b/test/lisp/emacs-lisp/cconv-tests.el index 83013cf46a9..349ffeb7e47 100644 --- a/test/lisp/emacs-lisp/cconv-tests.el +++ b/test/lisp/emacs-lisp/cconv-tests.el @@ -364,5 +364,18 @@ cconv-tests-interactive-closure-bug51695 (call-interactively f)) '((t 51696) (nil 51695) (t 51697))))))) +(ert-deftest cconv-safe-for-space () + (let* ((magic-string "This-is-a-magic-string") + (safe-p (lambda (x) (not (string-match magic-string (format "%S" x)))))) + (should (funcall safe-p (lambda (x) (+ x 1)))) + (should (funcall safe-p (eval '(lambda (x) (+ x 1)) + `((y . ,magic-string))))) + (should (funcall safe-p (eval '(lambda (x) :closure-dont-trim-context) + `((y . ,magic-string))))) + (should-not (funcall safe-p + (eval '(lambda (x) :closure-dont-trim-context (+ x 1)) + `((y . ,magic-string))))))) + + (provide 'cconv-tests) ;;; cconv-tests.el ends here commit 2ac8d7e64a08ea6e22bb90ad16e2880440fbcf16 Author: Michael Albinus Date: Sat Feb 18 18:27:56 2023 +0100 Improve Tramp's user and host name completion * lisp/net/tramp.el (tramp-completion-handle-file-exists-p): Improve user name completion. (tramp-skeleton-file-exists-p): New defmacro, which also handles host name completion. (tramp-handle-file-exists-p): * lisp/net/tramp-adb.el (tramp-adb-handle-file-exists-p): * lisp/net/tramp-sh.el (tramp-sh-handle-file-exists-p): * lisp/net/tramp-sudoedit.el (tramp-sudoedit-handle-file-exists-p): Use it. diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el index 38fd8a4e258..f8c38859477 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el @@ -487,16 +487,9 @@ tramp-adb-handle-file-executable-p (defun tramp-adb-handle-file-exists-p (filename) "Like `file-exists-p' for Tramp files." - ;; `file-exists-p' is used as predicate in file name completion. - ;; We don't want to run it when `non-essential' is t, or there is - ;; no connection process yet. - (when (tramp-connectable-p filename) - (with-parsed-tramp-file-name (expand-file-name filename) nil - (with-tramp-file-property v localname "file-exists-p" - (if (tramp-file-property-p v localname "file-attributes") - (not (null (tramp-get-file-property v localname "file-attributes"))) - (tramp-adb-send-command-and-check - v (format "test -e %s" (tramp-shell-quote-argument localname)))))))) + (tramp-skeleton-file-exists-p filename + (tramp-adb-send-command-and-check + v (format "test -e %s" (tramp-shell-quote-argument localname))))) (defun tramp-adb-handle-file-readable-p (filename) "Like `file-readable-p' for Tramp files." diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 7a6c9658aa9..b3d837f9514 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -1186,20 +1186,13 @@ tramp-sh-handle-file-truename (defun tramp-sh-handle-file-exists-p (filename) "Like `file-exists-p' for Tramp files." - ;; `file-exists-p' is used as predicate in file name completion. - ;; We don't want to run it when `non-essential' is t, or there is - ;; no connection process yet. - (when (tramp-connectable-p filename) - (with-parsed-tramp-file-name (expand-file-name filename) nil - (with-tramp-file-property v localname "file-exists-p" - (if (tramp-file-property-p v localname "file-attributes") - (not (null (tramp-get-file-property v localname "file-attributes"))) - (tramp-send-command-and-check - v - (format - "%s %s" - (tramp-get-file-exists-command v) - (tramp-shell-quote-argument localname)))))))) + (tramp-skeleton-file-exists-p filename + (tramp-send-command-and-check + v + (format + "%s %s" + (tramp-get-file-exists-command v) + (tramp-shell-quote-argument localname))))) (defun tramp-sh-handle-file-attributes (filename &optional id-format) "Like `file-attributes' for Tramp files." diff --git a/lisp/net/tramp-sudoedit.el b/lisp/net/tramp-sudoedit.el index 1f646253579..fa1689d6851 100644 --- a/lisp/net/tramp-sudoedit.el +++ b/lisp/net/tramp-sudoedit.el @@ -454,16 +454,9 @@ tramp-sudoedit-handle-file-executable-p (defun tramp-sudoedit-handle-file-exists-p (filename) "Like `file-exists-p' for Tramp files." - ;; `file-exists-p' is used as predicate in file name completion. - ;; We don't want to run it when `non-essential' is t, or there is - ;; no connection process yet. - (when (tramp-connectable-p filename) - (with-parsed-tramp-file-name (expand-file-name filename) nil - (with-tramp-file-property v localname "file-exists-p" - (if (tramp-file-property-p v localname "file-attributes") - (not (null (tramp-get-file-property v localname "file-attributes"))) - (tramp-sudoedit-send-command - v "test" "-e" (file-name-unquote localname))))))) + (tramp-skeleton-file-exists-p filename + (tramp-sudoedit-send-command + v "test" "-e" (file-name-unquote localname)))) (defun tramp-sudoedit-handle-file-name-all-completions (filename directory) "Like `file-name-all-completions' for Tramp files." diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 95b42fb1c43..baa9f966dd8 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -2976,8 +2976,9 @@ tramp-completion-handle-file-exists-p ;; We need special handling only when a method is needed. Then we ;; regard all files "/method:" or "/[method/" as existent, if ;; "method" is a valid Tramp method. And we regard all files - ;; "/method:user@host" or "/[method/user@host" as existent, if - ;; "user@host" is a valid file name completion. + ;; "/method:user@", "/user@" or "/[method/user@" as existent, if + ;; "user@" is a valid file name completion. Host completion is + ;; performed in the respective backen operation. (or (and (cond ;; Completion styles like `flex' and `substring' check for ;; the file name "/". This does exist. @@ -2989,27 +2990,30 @@ tramp-completion-handle-file-exists-p (regexp tramp-prefix-regexp) (* (regexp tramp-remote-file-name-spec-regexp) (regexp tramp-postfix-hop-regexp)) - (group (regexp tramp-method-regexp)) + (group-n 9 (regexp tramp-method-regexp)) (? (regexp tramp-postfix-method-regexp)) eos) filename)) - (assoc (match-string 1 filename) tramp-methods)) - ;; Is it a valid user@host? + (assoc (match-string 9 filename) tramp-methods)) + ;; Is it a valid user? ((string-match (rx (regexp tramp-prefix-regexp) (* (regexp tramp-remote-file-name-spec-regexp) (regexp tramp-postfix-hop-regexp)) - (group (regexp tramp-remote-file-name-spec-regexp)) + (group-n 10 + (regexp tramp-method-regexp) + (regexp tramp-postfix-method-regexp)) + (group-n 11 + (regexp tramp-user-regexp) + (regexp tramp-postfix-user-regexp)) eos) filename) - (member - (concat - (file-name-nondirectory filename) tramp-postfix-host-format) - (file-name-all-completions - (file-name-nondirectory filename) - (file-name-directory filename))))) - t) + (member + (match-string 11 filename) + (file-name-all-completions + "" (concat tramp-prefix-format (match-string 10 filename)))))) + t) (tramp-run-real-handler #'file-exists-p (list filename)))) @@ -3629,6 +3633,25 @@ tramp-skeleton-directory-files-and-attributes (tramp-dissect-file-name ,directory) 'file-missing ,directory) nil))) +(defmacro tramp-skeleton-file-exists-p (filename &rest body) + "Skeleton for `tramp-*-handle-file-exists-p'. +BODY is the backend specific code." + (declare (indent 1) (debug t)) + ;; `file-exists-p' is used as predicate in file name completion. + `(or (and minibuffer-completing-file-name + (file-name-absolute-p ,filename) + (tramp-string-empty-or-nil-p + (tramp-file-name-localname (tramp-dissect-file-name ,filename)))) + ;; We don't want to run it when `non-essential' is t, or there + ;; is no connection process yet. + (when (tramp-connectable-p ,filename) + (with-parsed-tramp-file-name (expand-file-name ,filename) nil + (with-tramp-file-property v localname "file-exists-p" + (if (tramp-file-property-p v localname "file-attributes") + (not + (null (tramp-get-file-property v localname "file-attributes"))) + ,@body)))))) + (defmacro tramp-skeleton-file-local-copy (filename &rest body) "Skeleton for `tramp-*-handle-file-local-copy'. BODY is the backend specific code." @@ -4066,13 +4089,8 @@ tramp-handle-file-equal-p (defun tramp-handle-file-exists-p (filename) "Like `file-exists-p' for Tramp files." - ;; `file-exists-p' is used as predicate in file name completion. - ;; We don't want to run it when `non-essential' is t, or there is - ;; no connection process yet. - (when (tramp-connectable-p filename) - (with-parsed-tramp-file-name (expand-file-name filename) nil - (with-tramp-file-property v localname "file-exists-p" - (not (null (file-attributes filename))))))) + (tramp-skeleton-file-exists-p filename + (not (null (file-attributes filename))))) (defun tramp-handle-file-in-directory-p (filename directory) "Like `file-in-directory-p' for Tramp files." commit b3502b922821fd100fb86b8cda6a0a62fba7d394 Author: andrés ramírez Date: Mon Feb 13 15:02:52 2023 +0000 Allow disabling viper faces in the minibuffer * lisp/emulation/viper-cmd.el (viper-enable-minibuffer-faces): New defcustom. (viper-set-mode-vars-for): Use it to decide whether to use distinct faces in the minibuffer. (Bug#61432) Copyright-paperwork-exempt: yes diff --git a/lisp/emulation/viper-cmd.el b/lisp/emulation/viper-cmd.el index 0eb58565b37..8cf81c33b5b 100644 --- a/lisp/emulation/viper-cmd.el +++ b/lisp/emulation/viper-cmd.el @@ -466,6 +466,12 @@ viper-normalize-minor-mode-map-alist ;; Viper mode-changing commands and utilities +(defcustom viper-enable-minibuffer-faces t + "If non-nil, viper uses distinct faces in the minibuffer." + :type 'boolean + :version "30.1" + :group 'viper-misc) + ;; Modifies mode-line-buffer-identification. (defun viper-refresh-mode-line () (setq-local viper-mode-string @@ -561,7 +567,7 @@ viper-set-mode-vars-for )) ;; minibuffer faces - (if (viper-has-face-support-p) + (if (and (viper-has-face-support-p) viper-enable-minibuffer-faces) (setq viper-minibuffer-current-face (cond ((eq state 'emacs-state) viper-minibuffer-emacs-face) ((eq state 'vi-state) viper-minibuffer-vi-face) commit 97f24924df62303c944176510038f398370f8fb6 Author: Stefan Kangas Date: Sat Feb 18 12:39:17 2023 +0100 Remove redundant requires from package.el * lisp/emacs-lisp/package.el (package-check-signature) (package-untar-buffer): Simplify by removing redundant require for autoloaded function. diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index 09917cd29b1..a0bb5e75393 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -378,10 +378,8 @@ package-check-signature `allow-unsigned', return `allow-unsigned', otherwise return the value of variable `package-check-signature'." (if (eq package-check-signature 'allow-unsigned) - (progn - (require 'epg-config) - (and (epg-find-configuration 'OpenPGP) - 'allow-unsigned)) + (and (epg-find-configuration 'OpenPGP) + 'allow-unsigned) package-check-signature)) (defcustom package-unsigned-archives nil @@ -958,7 +956,6 @@ package-untar-buffer "Untar the current buffer. This uses `tar-untar-buffer' from Tar mode. All files should untar into a directory named DIR; otherwise, signal an error." - (require 'tar-mode) (tar-mode) ;; Make sure everything extracts into DIR. (let ((regexp (concat "\\`" (regexp-quote (expand-file-name dir)) "/")) commit 0be5f7ab6368175953c0a5bcbbd485fd9edda2b0 Merge: 1298d1db189 1769a588300 Author: Stefan Kangas Date: Sat Feb 18 10:45:46 2023 +0100 Merge from origin/emacs-29 1769a588300 Fix some uses of 'use-dialog-box' deef41a8259 Fix hi-lock-tests when 'use-dialog-box' is non-nil 5093a534960 Fix regression due to change in face sort order by 'face-... 3e747630999 * lisp/files.el (file-equal-p): Work around Haiku stat bug. 13fd7667f9c ; * src/treesit.c: Improve sectioning. a40b1745d4a (project-vc-backend-markers-alist): Add entry for vc-got 18e96ed7c8a project.el: Extract backend->marker association for a defvar 0a5615669a4 Don't completely clip into visible range in treesit_recor... 5b34fc07085 * lisp/treesit.el (treesit-node-at): Update docstring (bu... 1c7d7623781 ; Minor copyedit of NEWS wrt *-ts-modes 09fad246de8 * lisp/calc/calc.el (calc-mode): Improve docstring. 8aad8d75aa9 ; Improve and update documentation of native compilation d6e4f243720 Merge 'emacs-29' into 'feature/inhibit-native-comp-cleanup' a555abc56d5 Fix order of faces in 'face-list' b44a7ff85dc Allow 'icon-title-format' to have the value t f1f571e72ae Add electric indent for preproc directives 83af806ab7c Rename 'emacs-news-toggle-tag' to 'emacs-news-cycle-tag' 5bc88b3b175 Add menu to news-mode 40f4bc4e0aa ; Avoid installing VC package dependencies multiple times 1c9d81a2b42 Attempt to recognise if a VC package has no Elisp files 2550e8bb0b0 Fix mule-tests under en_US.UTF-8 locale 32795309939 Move block closer above declaration_list rule (bug#61531) b18754bb179 Minor improvements in c-ts-mode and docs 3c6b726a7b4 Add super node as a keyword 1917c51fe68 ; Prevent ERC-induced false positive in JUnit report b16965ef7e6 Delete perplexing paragraph from Gnus manual 43c62a4732d ; Fix typo fdac69b45e6 ; Auto-commit of loaddefs files. 7678b7e46f2 Eglot: check server capability before sending didSave (bu... a3a1ef7bd5e Fix rust-ts-mode type and module highlighting (Bug#61302) 477aa047ee7 rust-ts-mode: Highlight variable reassignments 5206a551c16 Improve backward compatibility of save-restriction accd88d5545 Don't indent template_string contents (bug#61503) d97a3839967 csharp-ts-mode: fontify compiler directives (bug#61512) 420d2cae846 Update to Transient v0.3.7-209-gdab1dfa a3751b5d0c1 ; Raise an error if a VC package checkout is empty 6a32ba8b69c ; Fix the installation of dependencies for VC packages 4eac80fcc39 ; Prepare to update ERC version to 5.5 4f099a72173 ; Remove failing erc-reuse-buffers test ce4a066ed1e * Generate trampolines in a temporary directory if no oth... 4bb27a5ca93 ; Minor docs copyedits 13bcff3da5c Merge branch 'emacs-29' of git.savannah.gnu.org:/srv/git/... 3d572ae0d50 Rename with/without-narrowing to with/without-restriction d806b0e33cf * lisp/repeat.el: Rename internal function and variable (... 1a64f326e0a * Fix previous change 95692f6754c Rename native-comp-deferred-compilation-deny-list 8d8464bd5a9 Rename native-comp-deferred-compilation into native-comp-... 5d0912f1445 Rename comp-enable-subr-trampolines into native-comp-enab... dd8b720ee74 ; * etc/NEWS: Fix typos. 909bd04cf5f ; * lisp/calendar/lunar.el: Add comments. (bug#61460) 10f2aedea9a ; * lisp/progmodes/c-ts-mode.el (c-ts-base-mode): delete ... abfd00e5c02 * lisp/emacs-lisp/comp.el (native-comp-never-optimize-fun... 1795839babc Support `comp-enable-subr-trampolines' as string value 865758130a1 ; * admin/git-bisect-start: Update failing commits b948d0d7efe Merge branch 'scratch/fix-locked-narrowing' b6e2799aa1c * Some more `inhibit-native-compile' clean-up dcb2379a463 Minor improvements to labeled narrowing c0681cd3477 Revert "Add new variable 'inhibit-native-compilation'" 3969a34fa1b Revert "Rename to inhibit-automatic-native-compilation" 4297039bd13 Save and restore the absence of narrowing locks 2956e54b1dd Add an extensive test for labeled (locked) narrowing 79ce185ad13 Update the documentation about labeled (locked) narrowing a6cd4553d48 Rename two long line optimizations variables 0d73e4aa261 Add specific symbols for narrowings d8438e2bb44 Add 'without-narrowing' macro 97314447e60 Make 'narrowing-lock' and 'narrowing-unlock' internal a4aa32bdfff Fix 'save-restriction' for narrowing locks commit 1769a588300f471a85fe8887864ae33340dececb Author: Eli Zaretskii Date: Sat Feb 18 10:58:00 2023 +0200 Fix some uses of 'use-dialog-box' * lisp/frame.el (display-mouse-p): Fix return value on MS-Windows in batch invocations. * lisp/hi-lock.el (hi-lock-unface-buffer): Don't consider 'last-nonmenu-event' being nil as a mouse event, for the purpose of using dialog boxes. diff --git a/lisp/frame.el b/lisp/frame.el index af95a047c38..81383349354 100644 --- a/lisp/frame.el +++ b/lisp/frame.el @@ -2120,8 +2120,9 @@ display-mouse-p ;; a toggle. (featurep 't-mouse) ;; No way to check whether a w32 console has a mouse, assume - ;; it always does. - (boundp 'w32-use-full-screen-buffer)))))) + ;; it always does, except in batch invocations. + (and (not noninteractive) + (boundp 'w32-use-full-screen-buffer))))))) (defun display-popup-menus-p (&optional display) "Return non-nil if popup menus are supported on DISPLAY. diff --git a/lisp/hi-lock.el b/lisp/hi-lock.el index 78fc5e6f716..5c536b190fb 100644 --- a/lisp/hi-lock.el +++ b/lisp/hi-lock.el @@ -611,6 +611,7 @@ hi-lock-unface-buffer (cond (current-prefix-arg (list t)) ((and (display-popup-menus-p) + last-nonmenu-event (listp last-nonmenu-event) use-dialog-box) (catch 'snafu commit deef41a82590658455bfd6468b2811147dd5f845 Author: Eli Zaretskii Date: Sat Feb 18 10:45:12 2023 +0200 Fix hi-lock-tests when 'use-dialog-box' is non-nil * test/lisp/hi-lock-tests.el (hi-lock-case-fold) (hi-lock-unhighlight): Bind 'use-dialog-box' to nil. diff --git a/test/lisp/hi-lock-tests.el b/test/lisp/hi-lock-tests.el index aeb08ecbb29..794a3b1d0c2 100644 --- a/test/lisp/hi-lock-tests.el +++ b/test/lisp/hi-lock-tests.el @@ -86,13 +86,18 @@ hi-lock-case-fold (unhighlight-regexp "a a") (should (= (length (overlays-in (point-min) (point-max))) 0)) - (let ((search-spaces-regexp search-whitespace-regexp)) (highlight-regexp "a a")) + (let ((search-spaces-regexp search-whitespace-regexp)) + (highlight-regexp "a a")) (should (= (length (overlays-in (point-min) (point-max))) 1)) - (cl-letf (((symbol-function 'completing-read) - (lambda (_prompt _coll - &optional _x _y _z _hist defaults _inherit) - (car defaults)))) - (call-interactively 'unhighlight-regexp)) + ;; We bind use-dialog-box to nil to prevent unhighlight-regexp + ;; from using popup menus, since the replacement for + ;; completing-read below is not ready for that calamity + (let ((use-dialog-box nil)) + (cl-letf (((symbol-function 'completing-read) + (lambda (_prompt _coll + &optional _x _y _z _hist defaults _inherit) + (car defaults)))) + (call-interactively 'unhighlight-regexp))) (should (= (length (overlays-in (point-min) (point-max))) 0)) (emacs-lisp-mode) @@ -142,12 +147,16 @@ hi-lock-case-fold (let ((search-spaces-regexp search-whitespace-regexp)) (highlight-regexp "a a")) (font-lock-ensure) (should (memq 'hi-yellow (get-text-property 1 'face))) - (cl-letf (((symbol-function 'completing-read) - (lambda (_prompt _coll - &optional _x _y _z _hist defaults _inherit) - (car defaults))) - (font-lock-fontified t)) - (call-interactively 'unhighlight-regexp)) + ;; We bind use-dialog-box to nil to prevent unhighlight-regexp + ;; from using popup menus, since the replacement for + ;; completing-read below is not ready for that calamity + (let ((use-dialog-box nil)) + (cl-letf (((symbol-function 'completing-read) + (lambda (_prompt _coll + &optional _x _y _z _hist defaults _inherit) + (car defaults))) + (font-lock-fontified t)) + (call-interactively 'unhighlight-regexp))) (should (null (get-text-property 1 'face)))))) (ert-deftest hi-lock-unhighlight () @@ -156,58 +165,64 @@ hi-lock-unhighlight (with-temp-buffer (insert "aAbB\n") - (cl-letf (((symbol-function 'completing-read) - (lambda (_prompt _coll - &optional _x _y _z _hist defaults _inherit) - (car defaults)))) - - (highlight-regexp "a") - (highlight-regexp "b") - (should (= (length (overlays-in (point-min) (point-max))) 4)) - ;; `hi-lock--regexps-at-point' should take regexp "a" at point 1, - ;; not the last regexp "b" - (goto-char 1) - (call-interactively 'unhighlight-regexp) - (should (= (length (overlays-in 1 3)) 0)) - (should (= (length (overlays-in 3 5)) 2)) - ;; Next call should unhighlight remaining regepxs - (call-interactively 'unhighlight-regexp) - (should (= (length (overlays-in 3 5)) 0)) - - ;; Test unhighlight all - (highlight-regexp "a") - (highlight-regexp "b") - (should (= (length (overlays-in (point-min) (point-max))) 4)) - (unhighlight-regexp t) - (should (= (length (overlays-in (point-min) (point-max))) 0)) - - (emacs-lisp-mode) - (setq font-lock-mode t) - - (highlight-regexp "a") - (highlight-regexp "b") - (font-lock-ensure) - (should (memq 'hi-yellow (get-text-property 1 'face))) - (should (memq 'hi-yellow (get-text-property 3 'face))) - ;; `hi-lock--regexps-at-point' should take regexp "a" at point 1, - ;; not the last regexp "b" - (goto-char 1) - (let ((font-lock-fontified t)) (call-interactively 'unhighlight-regexp)) - (should (null (get-text-property 1 'face))) - (should (memq 'hi-yellow (get-text-property 3 'face))) - ;; Next call should unhighlight remaining regepxs - (let ((font-lock-fontified t)) (call-interactively 'unhighlight-regexp)) - (should (null (get-text-property 3 'face))) - - ;; Test unhighlight all - (highlight-regexp "a") - (highlight-regexp "b") - (font-lock-ensure) - (should (memq 'hi-yellow (get-text-property 1 'face))) - (should (memq 'hi-yellow (get-text-property 3 'face))) - (let ((font-lock-fontified t)) (unhighlight-regexp t)) - (should (null (get-text-property 1 'face))) - (should (null (get-text-property 3 'face))))))) + ;; We bind use-dialog-box to nil to prevent unhighlight-regexp + ;; from using popup menus, since the replacement for + ;; completing-read below is not ready for that calamity + (let ((use-dialog-box nil)) + (cl-letf (((symbol-function 'completing-read) + (lambda (_prompt _coll + &optional _x _y _z _hist defaults _inherit) + (car defaults)))) + (highlight-regexp "a") + (highlight-regexp "b") + (should (= (length (overlays-in (point-min) (point-max))) 4)) + ;; `hi-lock--regexps-at-point' should take regexp "a" at point 1, + ;; not the last regexp "b" + (goto-char 1) + (call-interactively 'unhighlight-regexp) + (should (= (length (overlays-in 1 3)) 0)) + (should (= (length (overlays-in 3 5)) 2)) + ;; Next call should unhighlight remaining regepxs + (call-interactively 'unhighlight-regexp) + (should (= (length (overlays-in 3 5)) 0)) + + ;; Test unhighlight all + (highlight-regexp "a") + (highlight-regexp "b") + (should (= (length (overlays-in (point-min) (point-max))) 4)) + (unhighlight-regexp t) + (should (= (length (overlays-in (point-min) (point-max))) 0)) + + (emacs-lisp-mode) + (setq font-lock-mode t) + + (highlight-regexp "a") + (highlight-regexp "b") + (font-lock-ensure) + (should (memq 'hi-yellow (get-text-property 1 'face))) + (should (memq 'hi-yellow (get-text-property 3 'face))) + ;; `hi-lock--regexps-at-point' should take regexp "a" at point 1, + ;; not the last regexp "b" + (goto-char 1) + (let ((font-lock-fontified t)) + (call-interactively 'unhighlight-regexp)) + (should (null (get-text-property 1 'face))) + (should (memq 'hi-yellow (get-text-property 3 'face))) + ;; Next call should unhighlight remaining regepxs + (let ((font-lock-fontified t)) + (call-interactively 'unhighlight-regexp)) + (should (null (get-text-property 3 'face))) + + ;; Test unhighlight all + (highlight-regexp "a") + (highlight-regexp "b") + (font-lock-ensure) + (should (memq 'hi-yellow (get-text-property 1 'face))) + (should (memq 'hi-yellow (get-text-property 3 'face))) + (let ((font-lock-fontified t)) + (unhighlight-regexp t)) + (should (null (get-text-property 1 'face))) + (should (null (get-text-property 3 'face)))))))) (provide 'hi-lock-tests) ;;; hi-lock-tests.el ends here commit 5093a5349603390666681966442a21382287b4bd Author: Eli Zaretskii Date: Sat Feb 18 09:37:34 2023 +0200 Fix regression due to change in face sort order by 'face-list' * lisp/faces.el (x-create-frame-with-faces): Undo reversing of the face list, which is no longer necessary, since 'face-list's sorting order has been reversed recently. (Bug#61521) diff --git a/lisp/faces.el b/lisp/faces.el index d1a7881e396..8bf7e4429d9 100644 --- a/lisp/faces.el +++ b/lisp/faces.el @@ -2226,7 +2226,7 @@ x-create-frame-with-faces (unwind-protect (progn (x-setup-function-keys frame) - (dolist (face (nreverse (face-list))) + (dolist (face (face-list)) (face-spec-recalc face frame)) (x-handle-reverse-video frame parameters) (frame-set-background-mode frame t) commit 3e747630999894553e2726f81b7d13da46b96350 Author: Po Lu Date: Sat Feb 18 11:03:07 2023 +0800 * lisp/files.el (file-equal-p): Work around Haiku stat bug. diff --git a/lisp/files.el b/lisp/files.el index 0d24852358e..57e01340359 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -6357,7 +6357,18 @@ file-equal-p (let (f1-attr f2-attr) (and (setq f1-attr (file-attributes (file-truename file1))) (setq f2-attr (file-attributes (file-truename file2))) - (equal f1-attr f2-attr)))))) + (progn + ;; Haiku systems change the file's last access timestamp + ;; every time `stat' is called. Make sure to not compare + ;; the timestamps in that case. + (or (equal f1-attr f2-attr) + (when (and (eq system-type 'haiku) + (consp (nthcdr 4 f1-attr)) + (consp (nthcdr 4 f2-attr))) + (ignore-errors + (setcar (nthcdr 4 f1-attr) nil) + (setcar (nthcdr 4 f2-attr) nil)) + (equal f1-attr f2-attr))))))))) (defun file-in-directory-p (file dir) "Return non-nil if DIR is a parent directory of FILE. commit 13fd7667f9c7fe5a4588bcae427e2da1ce368fe0 Author: Po Lu Date: Sat Feb 11 09:26:11 2023 +0800 ; * src/treesit.c: Improve sectioning. diff --git a/src/treesit.c b/src/treesit.c index 08119f149b7..e1d6f1ef79f 100644 --- a/src/treesit.c +++ b/src/treesit.c @@ -720,6 +720,7 @@ DEFUN ("treesit-language-abi-version", Ftreesit_language_abi_version, } } + /*** Parsing functions */ static void @@ -1113,6 +1114,7 @@ treesit_read_buffer (void *parser, uint32_t byte_index, return beg; } + /*** Functions for parser and node object */ /* Wrap the parser in a Lisp_Object to be used in the Lisp @@ -1275,6 +1277,9 @@ treesit_ensure_query_compiled (Lisp_Object query, Lisp_Object *signal_symbol, return treesit_query; } + +/* Lisp definitions. */ + DEFUN ("treesit-parser-p", Ftreesit_parser_p, Streesit_parser_p, 1, 1, 0, doc: /* Return t if OBJECT is a tree-sitter parser. */) @@ -1493,6 +1498,7 @@ treesit_parser_live_p (Lisp_Object parser) (!NILP (Fbuffer_live_p (XTS_PARSER (parser)->buffer)))); } + /*** Parser API */ DEFUN ("treesit-parser-root-node", @@ -1739,6 +1745,7 @@ DEFUN ("treesit-parser-remove-notifier", Ftreesit_parser_remove_notifier, return Qnil; } + /*** Node API */ /* Check that OBJ is a positive integer and signal an error if @@ -2261,6 +2268,7 @@ DEFUN ("treesit-node-eq", return same_node ? Qt : Qnil; } + /*** Query functions */ DEFUN ("treesit-pattern-expand", @@ -2835,6 +2843,7 @@ DEFUN ("treesit-query-capture", return Fnreverse (result); } + /*** Navigation */ static inline void @@ -3455,7 +3464,7 @@ DEFUN ("treesit-available-p", Ftreesit_available_p, #endif } - + /*** Initialization */ /* Initialize the tree-sitter routines. */ commit a40b1745d4ade399852ea15a60c07e63907eb298 Author: Dmitry Gutov Date: Sat Feb 18 00:54:02 2023 +0200 (project-vc-backend-markers-alist): Add entry for vc-got * lisp/progmodes/project.el (project-vc-backend-markers-alist): Add entry for vc-got (bug#61577). Bump the version. diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 46bafc55777..1228c73fee8 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -1,7 +1,7 @@ ;;; project.el --- Operations on the current project -*- lexical-binding: t; -*- ;; Copyright (C) 2015-2023 Free Software Foundation, Inc. -;; Version: 0.9.6 +;; Version: 0.9.7 ;; Package-Requires: ((emacs "26.1") (xref "1.4.0")) ;; This is a GNU ELPA :core package. Avoid using functionality that @@ -505,7 +505,8 @@ project-vc-backend-markers-alist "_svn" ".svn")) (DARCS . "_darcs") - (Fossil . ".fslckout")) + (Fossil . ".fslckout") + (Got . ".got")) "Associative list assigning root markers to VC backend symbols. See `project-vc-extra-root-markers' for the marker value format.") commit 18e96ed7c8a388d5aee4be37c8f268fb826fc1d2 Author: Dmitry Gutov Date: Sat Feb 18 00:50:29 2023 +0200 project.el: Extract backend->marker association for a defvar * lisp/progmodes/project.el (project-vc-backend-markers-alist): Extract from 'project-try-vc'. (project-try-vc): Update accordingly (bug#61577). diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 2343adf4698..46bafc55777 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -494,6 +494,22 @@ project-vc-external-roots-function The directory names should be absolute. Used in the VC-aware project backend implementation of `project-external-roots'.") +(defvar project-vc-backend-markers-alist + `((Git . ".git") + (Hg . ".hg") + (Bzr . ".bzr") + ;; See the comment above `vc-svn-admin-directory' for why we're + ;; duplicating the definition. + (SVN . ,(if (and (memq system-type '(cygwin windows-nt ms-dos)) + (getenv "SVN_ASP_DOT_NET_HACK")) + "_svn" + ".svn")) + (DARCS . "_darcs") + (Fossil . ".fslckout")) + "Associative list assigning root markers to VC backend symbols. + +See `project-vc-extra-root-markers' for the marker value format.") + (defun project-try-vc (dir) (defvar vc-svn-admin-directory) (require 'vc-svn) @@ -501,17 +517,11 @@ project-try-vc ;; `project-vc-merge-submodules' or `project-vc-extra-root-markers' ;; changes. (or (vc-file-getprop dir 'project-vc) - (let* ((backend-markers-alist `((Git . ".git") - (Hg . ".hg") - (Bzr . ".bzr") - (SVN . ,vc-svn-admin-directory) - (DARCS . "_darcs") - (Fossil . ".fslckout"))) - (backend-markers + (let* ((backend-markers (delete nil (mapcar - (lambda (b) (assoc-default b backend-markers-alist)) + (lambda (b) (assoc-default b project-vc-backend-markers-alist)) vc-handled-backends))) (marker-re (concat @@ -537,7 +547,7 @@ project-try-vc (backend (cl-find-if (lambda (b) - (member (assoc-default b backend-markers-alist) + (member (assoc-default b project-vc-backend-markers-alist) last-matches)) vc-handled-backends)) project) commit 0a5615669a4f5d7e2db3c4117f3c2440e9c4cfd5 Author: Yuan Fu Date: Fri Feb 17 14:21:49 2023 -0800 Don't completely clip into visible range in treesit_record_change (Bug#61369) From min (visible_end, max (visible_beg, new_end_byte)) - visible_beg to max (visible_beg, new_end_byte) - visible_beg * src/treesit.c (treesit_record_change): We don't clip the new end into the visible range anymore. If you think of it, when inserting in a narrowed region, the visible region is always extended to accommodate more text, rather than pushing text at the end to keep the size of the visible region. diff --git a/src/treesit.c b/src/treesit.c index cab2f0d5354..08119f149b7 100644 --- a/src/treesit.c +++ b/src/treesit.c @@ -770,7 +770,8 @@ treesit_record_change (ptrdiff_t start_byte, ptrdiff_t old_end_byte, treesit_check_parser (lisp_parser); TSTree *tree = XTS_PARSER (lisp_parser)->tree; /* See comment (ref:visible-beg-null) if you wonder why we don't - update visible_beg/end when tree is NULL. */ + update visible_beg/end when tree is NULL. */ + if (tree != NULL) { eassert (start_byte <= old_end_byte); @@ -794,8 +795,14 @@ treesit_record_change (ptrdiff_t start_byte, ptrdiff_t old_end_byte, ptrdiff_t old_end_offset = (min (visible_end, max (visible_beg, old_end_byte)) - visible_beg); - ptrdiff_t new_end_offset = (min (visible_end, - max (visible_beg, new_end_byte)) + /* We don't clip new_end_offset under visible_end, because + inserting in narrowed region always extends the visible + region. If we clip new_end_offset here, and re-add the + clipped "tail" in treesit_sync_visible_region later, + while it is technically equivalent, tree-sitter's + incremental parsing algorithm doesn't seem to like it + (bug#61369). */ + ptrdiff_t new_end_offset = (max (visible_beg, new_end_byte) - visible_beg); eassert (start_offset <= old_end_offset); eassert (start_offset <= new_end_offset); @@ -817,11 +824,13 @@ treesit_record_change (ptrdiff_t start_byte, ptrdiff_t old_end_byte, /* Move forward. */ visi_beg_delta = (old_end_byte < visible_beg ? new_end_byte - old_end_byte : 0); + XTS_PARSER (lisp_parser)->visible_beg = visible_beg + visi_beg_delta; XTS_PARSER (lisp_parser)->visible_end = (visible_end + visi_beg_delta + (new_end_offset - old_end_offset)); + eassert (XTS_PARSER (lisp_parser)->visible_beg >= 0); eassert (XTS_PARSER (lisp_parser)->visible_beg <= XTS_PARSER (lisp_parser)->visible_end); commit 5b34fc07085a4ec636124756d09dcc3be8414eb8 Author: Dmitry Gutov Date: Fri Feb 17 17:06:53 2023 +0200 * lisp/treesit.el (treesit-node-at): Update docstring (bug#61529). diff --git a/lisp/treesit.el b/lisp/treesit.el index 6015e78bbd5..09531b838a1 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -166,10 +166,13 @@ treesit-node-at A leaf node is a node that doesn't have any child nodes. The returned node's span covers POS: the node's beginning is before -or at POS, and the node's end is at or after POS. +or at POS, and the node's end is after POS. -If no leaf node's span covers POS (e.g., POS is on whitespace -between two leaf nodes), return the first leaf node after POS. +If no such node exists, but there's a leaf node which ends at POS, +return that node. + +Otherwise (e.g., when POS is on whitespace between two leaf +nodes), return the first leaf node after POS. If there is no leaf node after POS, return the first leaf node before POS. commit 1c7d7623781cd7ee5d2ba7c1303e476592ccaee1 Author: Eli Zaretskii Date: Fri Feb 17 16:57:09 2023 +0200 ; Minor copyedit of NEWS wrt *-ts-modes * etc/NEWS: Add desktop.el caveat for when restarting after trying the *-ts-modes. Suggested by Alan Mackenzie . diff --git a/etc/NEWS b/etc/NEWS index 6d3d849a757..b140d1dcbfd 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -3251,8 +3251,10 @@ for which a "built-in" mode would be turned on. For example: (add-to-list 'major-mode-remap-alist '(ruby-mode . ruby-ts-mode)) If you try these modes and don't like them, you can go back to the -"built-in" modes by restarting Emacs. But please tell us why you -didn't like the tree-sitter based modes, so that we could try +"built-in" modes by restarting Emacs. (If you use desktop.el to save +and restore Emacs sessions, make sure no buffer under these modes is +recorded in the desktop file, before restarting.) But please tell us +why you didn't like the tree-sitter based modes, so that we could try improving them. Each major mode based on tree-sitter needs a language grammar library, commit 09fad246de82c720295a8708657d61407bb968c3 Author: Stefan Kangas Date: Fri Feb 17 15:23:19 2023 +0100 * lisp/calc/calc.el (calc-mode): Improve docstring. diff --git a/lisp/calc/calc.el b/lisp/calc/calc.el index 39e54c89e06..f129552c9a4 100644 --- a/lisp/calc/calc.el +++ b/lisp/calc/calc.el @@ -1282,16 +1282,17 @@ calc-kill-stack-buffer (defun calc-mode () "Calculator major mode. -This is an RPN calculator featuring arbitrary-precision integer, rational, -floating-point, complex, matrix, and symbolic arithmetic. +This is a Reverse Polish notation (RPN) calculator featuring +arbitrary-precision integer, rational, floating-point, complex, +matrix, and symbolic arithmetic. RPN calculation: 2 RET 3 + produces 5. Algebraic style: \\=' 2+3 RET produces 5. Basic operators are +, -, *, /, ^, & (reciprocal), % (modulo), n (change-sign). -Press ? repeatedly for more complete help. Press `h i' to read the -Calc manual on-line, `h s' to read the summary, or `h t' for the tutorial. +Press \\`?' repeatedly for more complete help. Press \\`h i' to read the +Calc manual, \\`h s' to read the summary, or \\`h t' for the tutorial. Notations: 3.14e6 3.14 * 10^6 _23 negative number -23 (or type `23 n') commit 8aad8d75aa94d0d07f6abb0f0e04d7634d0d1d4a Author: Eli Zaretskii Date: Fri Feb 17 16:15:51 2023 +0200 ; Improve and update documentation of native compilation * src/comp.c (syms_of_comp) : Doc fixes. * lisp/emacs-lisp/comp.el (native-comp-never-optimize-functions): Doc fix. * doc/lispref/compile.texi (Native-Compilation Variables): Document 'native-comp-jit-compilation' and 'native-comp-enable-subr-trampolines'. diff --git a/doc/lispref/compile.texi b/doc/lispref/compile.texi index 0617b9c533c..cdbf64036da 100644 --- a/doc/lispref/compile.texi +++ b/doc/lispref/compile.texi @@ -849,7 +849,12 @@ Native Compilation of @code{user-emacs-directory} (@pxref{Init File}). You can do that by either changing the value of @code{native-comp-eln-load-path} (@pxref{Native-Compilation Variables}) or by temporarily pointing the -@env{HOME} environment variable to a non-existing directory. +@env{HOME} environment variable to a non-existing directory. Note +that the latter technique might still produce a small number of +@file{*.eln} files if Emacs needs to generate @dfn{trampolines}, which +are used if Lisp primitives are advised or redefined in your Lisp code +that is being natively compiled. @xref{Native-Compilation Variables, +trampolines}. @menu * Native-Compilation Functions:: Functions to natively-compile Lisp. @@ -1075,3 +1080,64 @@ Native-Compilation Variables specifically, Emacs will write these files into the first writable directory in the list. Thus, you can control where native-compilation stores the results by changing the value of this variable. + +@cindex disable asynchronous native compilation +@cindex inhibit asynchronous native compilation +@cindex asynchronous native compilation, disable +@defvar native-comp-jit-compilation +This variable, if non-@code{nil}, enables asynchronous (a.k.a.@: +@dfn{just-in-time}, or @acronym{JIT}) native compilation of the +@file{*.elc} files loaded by Emacs for which the corresponding +@file{*.eln} files do not already exist. This JIT compilation uses +separate Emacs sub-processes running in batch mode, according to the +value of @code{native-comp-async-jobs-number}. When the JIT +compilation of a Lisp file finishes successfully, the resulting +@file{.eln} file is loaded and its code replaces the definition of +functions provided by the @file{.elc} file. +@end defvar + +@cindex trampolines, in native compilation + Setting the value of @code{native-comp-jit-compilation} to@code{nil} +disables JIT native compilation. However, even when JIT native +compilation is disabled, Emacs might still need to start asynchronous +native compilation subprocesses to produce @dfn{trampolines}. To +control this, use a separate variable, described below. + +@defvar native-comp-enable-subr-trampolines +This variable controls generation of trampolines. A trampoline is a +small piece of native code required to allow calling Lisp primitives, +which were advised or redefined, from Lisp code that was +natively-compiled with @code{native-comp-speed} set to 2 or greater. +Emacs stores the generated trampolines on separate @file{*.eln} files. +By default, this variable's value is @code{t}, which enables the +generation of trampoline files; setting it to @code{nil} disables the +generation of trampolines. Note that if a trampoline needed for +advising or redefining a primitive is not available and cannot be +generated, calls to that primitive from natively-compiled Lisp will +ignore redefinitions and advices, and will behave as if the primitive +was called directly from C. Therefore, we don't recommend disabling +the trampoline generation, unless you know that all the trampolines +needed by your Lisp programs are already compiled and accessible to +Emacs. + +The value of this variable can also be a string, in which case it is +interpreted as the name of a directory in which to store the generated +trampoline @file{*.eln} files, overriding the directories specified by +@code{native-comp-eln-load-path}. This is useful if you want the +trampolines to be generated as needed, but don't want to store them +under the user's @env{HOME} directory or the other public directories +where @file{*.eln} files are kept. However, unlike with directories +in @code{native-comp-eln-load-path}, the trampolines will be stored in +the directory given by the value of this variable, not in its +version-specific subdirectory. + +If this variable is non-@code{nil}, and Emacs needs to produce a +trampoline, but it cannot find any writable directory to store the +trampoline, it will store it inside @code{temporary-file-directory} +(@pxref{Unique File Names}). + +Trampolines produced when no writable directory is found to store +them, or when this variable is a string, will only be available for +the duration of the current Emacs session, because Emacs doesn't look +for trampolines in either of these places. +@end defvar diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index a6b9b3f57ea..2d9cad6d98c 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -112,9 +112,8 @@ native-comp-never-optimize-functions "Primitive functions to exclude from trampoline optimization. Primitive functions included in this list will not be called -directly by the native code being compiled, this makes -tranpolines for those primitives not necessary in case of -function redefinition/advise." +directly by the natively-compiled code, which makes trampolines for +those primitives unnecessary in case of function redefinition/advice." :type '(repeat symbol) :version "28.1") diff --git a/src/comp.c b/src/comp.c index 019d1e78fff..beaf443a0f7 100644 --- a/src/comp.c +++ b/src/comp.c @@ -5670,19 +5670,17 @@ syms_of_comp (void) { #ifdef HAVE_NATIVE_COMP DEFVAR_LISP ("comp--delayed-sources", Vcomp__delayed_sources, - doc: /* List of sources to be native-compiled when startup is finished. + doc: /* List of sources to be native-compiled when startup is finished. For internal use. */); - DEFVAR_BOOL ("comp--compilable", - comp__compilable, - doc: /* Non-nil when comp.el can be native compiled. + DEFVAR_BOOL ("comp--compilable", comp__compilable, + doc: /* Non-nil when comp.el can be native compiled. For internal use. */); /* Compiler control customizes. */ - DEFVAR_BOOL ("native-comp-jit-compilation", - native_comp_jit_compilation, - doc: /* If non-nil compile loaded .elc files asynchronously. + DEFVAR_BOOL ("native-comp-jit-compilation", native_comp_jit_compilation, + doc: /* If non-nil, compile loaded .elc files asynchronously. -After compilation, each function definition is updated to the native -compiled one. */); +After compilation, each function definition is updated to use the +natively-compiled one. */); native_comp_jit_compilation = true; DEFSYM (Qnative_comp_speed, "native-comp-speed"); @@ -5827,31 +5825,34 @@ syms_of_comp (void) /* FIXME should be initialized but not here... Plus this don't have to be necessarily exposed to lisp but can easy debug for now. */ DEFVAR_LISP ("comp-subr-list", Vcomp_subr_list, - doc: /* List of all defined subrs. */); + doc: /* List of all defined subrs. */); DEFVAR_LISP ("comp-abi-hash", Vcomp_abi_hash, - doc: /* String signing the .eln files ABI. */); + doc: /* String signing the .eln files ABI. */); Vcomp_abi_hash = Qnil; DEFVAR_LISP ("comp-native-version-dir", Vcomp_native_version_dir, - doc: /* Directory in use to disambiguate eln compatibility. */); + doc: /* Directory in use to disambiguate eln compatibility. */); Vcomp_native_version_dir = Qnil; DEFVAR_LISP ("comp-deferred-pending-h", Vcomp_deferred_pending_h, - doc: /* Hash table symbol-name -> function-value. + doc: /* Hash table symbol-name -> function-value. For internal use. */); Vcomp_deferred_pending_h = CALLN (Fmake_hash_table, QCtest, Qeq); DEFVAR_LISP ("comp-eln-to-el-h", Vcomp_eln_to_el_h, - doc: /* Hash table eln-filename -> el-filename. */); + doc: /* Hash table eln-filename -> el-filename. */); Vcomp_eln_to_el_h = CALLN (Fmake_hash_table, QCtest, Qequal); DEFVAR_LISP ("native-comp-eln-load-path", Vnative_comp_eln_load_path, - doc: /* List of eln cache directories. + doc: /* List of directories to look for natively-compiled *.eln files. -If a directory is non absolute it is assumed to be relative to -`invocation-directory'. -`comp-native-version-dir' value is used as a sub-folder name inside -each eln cache directory. -The last directory of this list is assumed to be the system one. */); +The *.eln files are actually looked for in a version-specific +subdirectory of each directory in this list. That subdirectory +is determined by the value of `comp-native-version-dir'. +If the name of a directory in this list is not absolute, it is +assumed to be relative to `invocation-directory'. +The last directory of this list is assumed to be the one holding +the system *.eln files, which are the files produced when building +Emacs. */); /* Temporary value in use for bootstrap. We can't do better as `invocation-directory' is still unset, will be fixed up during @@ -5860,45 +5861,47 @@ syms_of_comp (void) DEFVAR_LISP ("native-comp-enable-subr-trampolines", Vnative_comp_enable_subr_trampolines, - doc: /* If non-nil, enable primitive trampoline synthesis. -This makes Emacs respect redefinition or advises of primitive functions -when they are called from Lisp code natively-compiled at `native-comp-speed' -of 2. + doc: /* If non-nil, enable generation of trampolines for calling primitives. +Trampolines are needed so that Emacs respects redefinition or advice of +primitive functions when they are called from Lisp code natively-compiled +at `native-comp-speed' of 2. -If `comp-enable-subr-trampolines' is a string it specifies a directory -in which to deposit the trampoline. - -By default, this is enabled, and when Emacs sees a redefined or advised +By default, the value is t, and when Emacs sees a redefined or advised primitive called from natively-compiled Lisp, it generates a trampoline for it on-the-fly. -Disabling this, when a trampoline for a redefined or advised primitive is -not available from previous compilations, means that such redefinition -or advise will not have effect on calls from natively-compiled Lisp code. -That is, calls to primitives without existing trampolines from -natively-compiled Lisp will behave as if the primitive was called -directly from C. */); +If the value is a file name (a string), it specifies the directory in +which to deposit the generated trampolines, overriding the directories +in `native-comp-eln-load-path'. + +When this variable is nil, generation of trampolines is disabled. + +Disabling the generation of trampolines, when a trampoline for a redefined +or advised primitive is not already available from previous compilations, +means that such redefinition or advice will not have effect when calling +primitives from natively-compiled Lisp code. That is, calls to primitives +without existing trampolines from natively-compiled Lisp will behave as if +the primitive was called directly from C, and will ignore its redefinition +and advice. */); DEFVAR_LISP ("comp-installed-trampolines-h", Vcomp_installed_trampolines_h, - doc: /* Hash table subr-name -> installed trampoline. -This is used to prevent double trampoline instantiation but also to + doc: /* Hash table subr-name -> installed trampoline. +This is used to prevent double trampoline instantiation, and also to protect the trampolines against GC. */); Vcomp_installed_trampolines_h = CALLN (Fmake_hash_table); DEFVAR_LISP ("comp-no-native-file-h", V_comp_no_native_file_h, - doc: /* Files for which no deferred compilation has to be performed. + doc: /* Files for which no deferred compilation should be performed. These files' compilation should not be deferred because the bytecode version was explicitly requested by the user during load. For internal use. */); V_comp_no_native_file_h = CALLN (Fmake_hash_table, QCtest, Qequal); DEFVAR_BOOL ("comp-file-preloaded-p", comp_file_preloaded_p, - doc: /* When non-nil assume the file being compiled to -be preloaded. */); + doc: /* When non-nil, assume the file being compiled to be preloaded. */); DEFVAR_LISP ("comp-loaded-comp-units-h", Vcomp_loaded_comp_units_h, - doc: /* Hash table recording all loaded compilation units. -file -> CU. */); + doc: /* Hash table recording all loaded compilation units, file -> CU. */); Vcomp_loaded_comp_units_h = CALLN (Fmake_hash_table, QCweakness, Qvalue, QCtest, Qequal); commit d6e4f2437202f13bec85d68c003700d06aa343e6 Merge: ce4a066ed1e a555abc56d5 Author: Andrea Corallo Date: Fri Feb 17 11:14:38 2023 +0100 Merge 'emacs-29' into 'feature/inhibit-native-comp-cleanup' commit a555abc56d5270cebe94f904189526d7ac433a94 Author: Eli Zaretskii Date: Fri Feb 17 10:27:39 2023 +0200 Fix order of faces in 'face-list' * lisp/faces.el (frame-face-alist, face-list): Sort faces in decreasing order of face IDs. Patch by Brennan Vincent . (Bug#61521) Copyright-paperwork-exempt: yes diff --git a/lisp/faces.el b/lisp/faces.el index 4933b495a6c..d1a7881e396 100644 --- a/lisp/faces.el +++ b/lisp/faces.el @@ -191,7 +191,7 @@ frame-face-alist (let ((face-id (car (gethash face face--new-frame-defaults)))) (push `(,face-id ,face . ,spec) faces))) (frame--face-hash-table frame)) - (mapcar #'cdr (sort faces (lambda (f1 f2) (< (car f1) (car f2))))))) + (mapcar #'cdr (sort faces (lambda (f1 f2) (> (car f1) (car f2))))))) (defun face-list () "Return a list of all defined faces." @@ -199,7 +199,7 @@ face-list (maphash (lambda (face spec) (push `(,(car spec) . ,face) faces)) face--new-frame-defaults) - (mapcar #'cdr (sort faces (lambda (f1 f2) (< (car f1) (car f2))))))) + (mapcar #'cdr (sort faces (lambda (f1 f2) (> (car f1) (car f2))))))) (defun make-face (face) "Define a new face with name FACE, a symbol. commit b44a7ff85dc8074735c5a8baa1fdea9d47c35ffa Author: Eli Zaretskii Date: Fri Feb 17 09:40:32 2023 +0200 Allow 'icon-title-format' to have the value t * src/xdisp.c (gui_consider_frame_title, syms_of_xdisp): If the value of 'icon-title-format' is t, use 'frame-title-format' instead. (Bug#61496) * etc/NEWS: * doc/lispref/frames.texi (Frame Titles): Document the new handling of the value t. (Basic Parameters): Fix the documentation of the 'title' and 'name' frame parameters. diff --git a/doc/lispref/frames.texi b/doc/lispref/frames.texi index 68f31e500bb..638b759ff13 100644 --- a/doc/lispref/frames.texi +++ b/doc/lispref/frames.texi @@ -1474,19 +1474,24 @@ Basic Parameters @vindex title@r{, a frame parameter} @item title -If a frame has a non-@code{nil} title, it appears in the window +If a frame has a non-@code{nil} title, that title appears in the window system's title bar at the top of the frame, and also in the mode line of windows in that frame if @code{mode-line-frame-identification} uses @samp{%F} (@pxref{%-Constructs}). This is normally the case when Emacs is not using a window system, and can only display one frame at -a time. @xref{Frame Titles}. +a time. When Emacs is using a window system, this parameter, if +non-@code{nil}, overrides the title determined by the @code{name} +parameter and the implicit title calculated according to +@code{frame-title-format}. It also overrides the title determined by +@code{icon-title-format} for iconified frames. @xref{Frame Titles}. @vindex name@r{, a frame parameter} @item name -The name of the frame. The frame name serves as a default for the frame -title, if the @code{title} parameter is unspecified or @code{nil}. If -you don't specify a name, Emacs sets the frame name automatically -(@pxref{Frame Titles}). +The name of the frame. If you don't specify a name via this +parameter, Emacs sets the frame name automatically, as specified by +@code{frame-title-format} and @code{icon-title-format}, and that is +the frame's title that will appear on display when Emacs uses a window +system (unless the @code{title} parameter overrides it). If you specify the frame name explicitly when you create the frame, the name is also used (instead of the name of the Emacs executable) when @@ -2630,17 +2635,26 @@ Frame Titles frame is redisplayed. @defvar frame-title-format -This variable specifies how to compute a name for a frame when you have -not explicitly specified one. The variable's value is actually a mode +This variable specifies how to compute a name for a frame when you +have not explicitly specified one (via the frame's parameters; +@pxref{Basic Parameters}). The variable's value is actually a mode line construct, just like @code{mode-line-format}, except that the -@samp{%c}, @samp{%C}, and @samp{%l} constructs are ignored. @xref{Mode Line -Data}. +@samp{%c}, @samp{%C}, and @samp{%l} constructs are ignored. +@xref{Mode Line Data}. @end defvar @defvar icon-title-format -This variable specifies how to compute the name for an iconified frame, -when you have not explicitly specified the frame title. This title -appears in the icon itself. +This variable specifies how to compute the name for an iconified frame +when you have not explicitly specified the frame's name via the +frame's parameters. The resulting title appears in the frame's icon +itself. If the value is a string, is should be a mode line construct +like that of @code{frame-title-format}. The value can also be +@code{t}, which means to use @code{frame-title-format} instead; this +avoids problems with some window managers and desktop environments, +where a change in a frame's title (when a frame is iconified) is +interpreted as a request to raise the frame and/or give it input +focus. The default is a string identical to the default value of +@code{frame-title-format}. @end defvar @defvar multiple-frames diff --git a/etc/NEWS b/etc/NEWS index 35063678f58..133c07e56df 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1202,6 +1202,13 @@ the most recently deleted frame. With a numerical prefix argument between 1 and 16, where 1 is the most recently deleted frame, undelete the corresponding deleted frame. ++++ +*** The variable 'icon-title-format' can now have the value t. +That value means to use 'frame-title-format' for iconified frames. +This is useful with some window managers and desktop environments +which treat changes in frame's title as requests to raise the frame +and/or give it input focus. + ** Tab Bars and Tab Lines --- diff --git a/src/xdisp.c b/src/xdisp.c index 5c5ecaa2bcb..1f630de7586 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -13424,7 +13424,8 @@ gui_consider_frame_title (Lisp_Object frame) Fselect_window (f->selected_window, Qt); set_buffer_internal_1 (XBUFFER (XWINDOW (f->selected_window)->contents)); - fmt = FRAME_ICONIFIED_P (f) ? Vicon_title_format : Vframe_title_format; + fmt = (FRAME_ICONIFIED_P (f) && !EQ (Vicon_title_format, Qt) + ? Vicon_title_format : Vframe_title_format); mode_line_target = MODE_LINE_TITLE; title_start = MODE_LINE_NOPROP_LEN (0); @@ -36608,9 +36609,11 @@ syms_of_xdisp (void) DEFVAR_LISP ("icon-title-format", Vicon_title_format, doc: /* Template for displaying the title bar of an iconified frame. \(Assuming the window manager supports this feature.) -This variable has the same structure as `mode-line-format' (which see), -and is used only on frames for which no explicit name has been set -\(see `modify-frame-parameters'). */); +If the value is a string, it should have the same structure +as `mode-line-format' (which see), and is used only on frames +for which no explicit name has been set \(see `modify-frame-parameters'). +If the value is t, that means use `frame-title-format' for +iconified frames. */); /* Do not nest calls to pure_list. This works around a bug in Oracle Developer Studio 12.6. */ Lisp_Object icon_title_name_format commit ce4a066ed1ea07f651f439132017db8ceb32779c (refs/remotes/origin/feature/inhibit-native-comp-cleanup) Author: Andrea Corallo Date: Tue Feb 14 11:21:45 2023 +0100 * Generate trampolines in a temporary directory if no other option is viable * lisp/emacs-lisp/comp.el (comp--trampoline-abs-filename): Use temporary file if no other option is viable. diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index ed706feb923..a6b9b3f57ea 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -3800,18 +3800,22 @@ comp--trampoline-abs-filename (list (expand-file-name comp-native-version-dir native-compile-target-directory)) (comp-eln-load-path-eff))) + with rel-filename = (comp-trampoline-filename subr-name) for dir in dirs - for f = (expand-file-name - (comp-trampoline-filename subr-name) - dir) + for abs-filename = (expand-file-name rel-filename dir) unless (file-exists-p dir) do (ignore-errors (make-directory dir t) - (cl-return f)) - when (file-writable-p f) - do (cl-return f) - finally (error "Cannot find suitable directory for output in \ -`native-comp-eln-load-path'"))) + (cl-return abs-filename)) + when (file-writable-p abs-filename) + do (cl-return abs-filename) + ;; Default to some temporary directory if no better option was + ;; found. + finally (cl-return + (expand-file-name + (make-temp-file-internal (file-name-sans-extension rel-filename) + 0 ".eln" nil) + temporary-file-directory)))) (defun comp-trampoline-compile (subr-name) "Synthesize compile and return a trampoline for SUBR-NAME." commit 1a64f326e0a8b86768031ac688ded9c863ff759c Author: Andrea Corallo Date: Mon Feb 13 17:00:31 2023 +0100 * Fix previous change * lisp/emacs-lisp/generate-lisp-file.el (generate-lisp-file-trailer): Fix previous change b6e2799aa1c. diff --git a/lisp/emacs-lisp/generate-lisp-file.el b/lisp/emacs-lisp/generate-lisp-file.el index d878784ba32..b2f67ab848d 100644 --- a/lisp/emacs-lisp/generate-lisp-file.el +++ b/lisp/emacs-lisp/generate-lisp-file.el @@ -103,7 +103,7 @@ generate-lisp-file-trailer (insert ";; no-byte-" "compile: t\n")) (unless autoloads (insert ";; no-update-autoloads: t\n")) - (unless native-comp-jit-compilation + (when inhibit-native-compile (insert ";; no-native-" "compile: t\n")) (when coding (insert (format ";; coding: %s\n" commit 95692f6754c3a8f55a90df2d6f7ce62be55cdcfc Author: Andrea Corallo Date: Mon Feb 13 16:40:02 2023 +0100 Rename native-comp-deferred-compilation-deny-list * lisp/emacs-lisp/comp.el (native-comp-jit-compilation-deny-list) (native-compile-async-skip-p): Rename native-comp-deferred-compilation-deny-list into native-comp-jit-compilation-deny-list. (native-comp-deferred-compilation-deny-list): Mark it obsolete. diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index fc1862a45e8..ed706feb923 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -85,13 +85,17 @@ native-comp-always-compile :type 'boolean :version "28.1") -(defcustom native-comp-deferred-compilation-deny-list +(defcustom native-comp-jit-compilation-deny-list '() "List of regexps to exclude matching files from deferred native compilation. Files whose names match any regexp are excluded from native compilation." :type '(repeat regexp) :version "28.1") +(make-obsolete-variable 'native-comp-deferred-compilation-deny-list + 'native-comp-jit-compilation-deny-list + "29.1") + (defcustom native-comp-bootstrap-deny-list '() "List of regexps to exclude files from native compilation during bootstrap. @@ -4144,11 +4148,11 @@ native-compile-async-skip-p (t (error "SELECTOR must be a function a regexp or nil"))) ;; Also exclude files from deferred compilation if ;; any of the regexps in - ;; `native-comp-deferred-compilation-deny-list' matches. + ;; `native-comp-jit-compilation-deny-list' matches. (and (eq load 'late) (cl-some (lambda (re) (string-match-p re file)) - native-comp-deferred-compilation-deny-list)))) + native-comp-jit-compilation-deny-list)))) (defun native--compile-async (files &optional recursively load selector) ;; BEWARE, this function is also called directly from C. commit 8d8464bd5a98598e7a6fe63370545c7f07574926 Author: Andrea Corallo Date: Mon Feb 13 16:37:43 2023 +0100 Rename native-comp-deferred-compilation into native-comp-jit-compilation * src/comp.c (maybe_defer_native_compilation, syms_of_comp): Rename native-comp-deferred-compilation into native-comp-jit-compilation. * lisp/subr.el (native-comp-deferred-compilation): Mark native-comp-deferred-compilation as obsolete. * lisp/startup.el (native-comp-deferred-compilation) (normal-top-level): Rename native-comp-deferred-compilation into native-comp-jit-compilation. * lisp/progmodes/elisp-mode.el (emacs-lisp-native-compile-and-load): Likewise. * lisp/emacs-lisp/generate-lisp-file.el (generate-lisp-file-trailer): Likewise. diff --git a/lisp/emacs-lisp/generate-lisp-file.el b/lisp/emacs-lisp/generate-lisp-file.el index 167cdfbf826..d878784ba32 100644 --- a/lisp/emacs-lisp/generate-lisp-file.el +++ b/lisp/emacs-lisp/generate-lisp-file.el @@ -103,7 +103,7 @@ generate-lisp-file-trailer (insert ";; no-byte-" "compile: t\n")) (unless autoloads (insert ";; no-update-autoloads: t\n")) - (unless native-comp-deferred-compilation + (unless native-comp-jit-compilation (insert ";; no-native-" "compile: t\n")) (when coding (insert (format ";; coding: %s\n" diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el index ba1183f686b..1c339d08148 100644 --- a/lisp/progmodes/elisp-mode.el +++ b/lisp/progmodes/elisp-mode.el @@ -220,7 +220,7 @@ emacs-lisp-native-compile-and-load Load the compiled code when finished. Use `emacs-lisp-byte-compile-and-load' in combination with -`native-comp-deferred-compilation' set to t to achieve asynchronous +`native-comp-jit-compilation' set to t to achieve asynchronous native compilation." (interactive nil emacs-lisp-mode) (emacs-lisp--before-compile-buffer) diff --git a/lisp/startup.el b/lisp/startup.el index ddbb39df857..b0f019d704e 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -542,7 +542,7 @@ startup--honor-delayed-native-compilations (setq comp--compilable t)) (defvar native-comp-eln-load-path) -(defvar native-comp-deferred-compilation) +(defvar native-comp-jit-compilation) (defvar native-comp-enable-subr-trampolines) (defvar startup--original-eln-load-path nil @@ -597,7 +597,7 @@ normal-top-level ;; in this session. This is necessary if libgccjit is not ;; available on MS-Windows, but Emacs was built with ;; native-compilation support. - (setq native-comp-deferred-compilation nil + (setq native-comp-jit-compilation nil native-comp-enable-subr-trampolines nil)) ;; Form `native-comp-eln-load-path'. diff --git a/lisp/subr.el b/lisp/subr.el index 56c8377da87..db33483f509 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1898,6 +1898,10 @@ max-specpdl-size 'native-comp-enable-subr-trampolines "29.1") +(make-obsolete-variable 'native-comp-deferred-compilation + 'native-comp-jit-compilation + "29.1") + ;;;; Alternate names for functions - these are not being phased out. diff --git a/src/comp.c b/src/comp.c index ba3ed95bcce..019d1e78fff 100644 --- a/src/comp.c +++ b/src/comp.c @@ -5173,7 +5173,7 @@ maybe_defer_native_compilation (Lisp_Object function_name, if (!load_gccjit_if_necessary (false)) return; - if (!native_comp_deferred_compilation + if (!native_comp_jit_compilation || noninteractive || !NILP (Vpurify_flag) || !COMPILEDP (definition) @@ -5677,13 +5677,13 @@ syms_of_comp (void) doc: /* Non-nil when comp.el can be native compiled. For internal use. */); /* Compiler control customizes. */ - DEFVAR_BOOL ("native-comp-deferred-compilation", - native_comp_deferred_compilation, + DEFVAR_BOOL ("native-comp-jit-compilation", + native_comp_jit_compilation, doc: /* If non-nil compile loaded .elc files asynchronously. After compilation, each function definition is updated to the native compiled one. */); - native_comp_deferred_compilation = true; + native_comp_jit_compilation = true; DEFSYM (Qnative_comp_speed, "native-comp-speed"); DEFSYM (Qnative_comp_debug, "native-comp-debug"); commit 5d0912f1445e33f1ccf23a84f0dc6d08c4ee2b60 Author: Andrea Corallo Date: Mon Feb 13 16:33:40 2023 +0100 Rename comp-enable-subr-trampolines into native-comp-enable-subr-trampolines * src/data.c (Ffset): Rename comp-enable-subr-trampolines into native-comp-enable-subr-trampolines. * src/comp.c (syms_of_comp): Likewise. * lisp/subr.el (comp-enable-subr-trampolines): Make comp-enable-subr-trampolines obsolete. * lisp/startup.el (native-comp-enable-subr-trampolines) (normal-top-level): Rename comp-enable-subr-trampolines into native-comp-enable-subr-trampolines. * lisp/loadup.el (dump-mode): Likewise. * lisp/emacs-lisp/comp.el (comp-subr-trampoline-install) (comp--trampoline-abs-filename): Likewise. diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index 5077ca0aa1f..fc1862a45e8 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -700,7 +700,7 @@ comp-no-spawn ;;;###autoload (defun comp-subr-trampoline-install (subr-name) "Make SUBR-NAME effectively advice-able when called from native code." - (unless (or (null comp-enable-subr-trampolines) + (unless (or (null native-comp-enable-subr-trampolines) (memq subr-name native-comp-never-optimize-functions) (gethash subr-name comp-installed-trampolines-h)) (cl-assert (subr-primitive-p (symbol-function subr-name))) @@ -3790,8 +3790,8 @@ comp-trampoline-search (defun comp--trampoline-abs-filename (subr-name) "Return the absolute filename for a trampoline for SUBR-NAME." (cl-loop - with dirs = (if (stringp comp-enable-subr-trampolines) - (list comp-enable-subr-trampolines) + with dirs = (if (stringp native-comp-enable-subr-trampolines) + (list native-comp-enable-subr-trampolines) (if native-compile-target-directory (list (expand-file-name comp-native-version-dir native-compile-target-directory)) diff --git a/lisp/loadup.el b/lisp/loadup.el index 5c576861579..46b26750cd5 100644 --- a/lisp/loadup.el +++ b/lisp/loadup.el @@ -550,7 +550,7 @@ (equal dump-mode "pdump")) ;; Don't enable this before bootstrap is completed, as the ;; compiler infrastructure may not be usable yet. - (setq comp-enable-subr-trampolines t)) + (setq native-comp-enable-subr-trampolines t)) (message "Dumping under the name %s" output) (condition-case () (delete-file output) diff --git a/lisp/startup.el b/lisp/startup.el index 240cfa30098..ddbb39df857 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -543,7 +543,7 @@ startup--honor-delayed-native-compilations (defvar native-comp-eln-load-path) (defvar native-comp-deferred-compilation) -(defvar comp-enable-subr-trampolines) +(defvar native-comp-enable-subr-trampolines) (defvar startup--original-eln-load-path nil "Original value of `native-comp-eln-load-path'.") @@ -598,7 +598,7 @@ normal-top-level ;; available on MS-Windows, but Emacs was built with ;; native-compilation support. (setq native-comp-deferred-compilation nil - comp-enable-subr-trampolines nil)) + native-comp-enable-subr-trampolines nil)) ;; Form `native-comp-eln-load-path'. (let ((path-env (getenv "EMACSNATIVELOADPATH"))) diff --git a/lisp/subr.el b/lisp/subr.el index a56aeab724a..56c8377da87 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1894,6 +1894,10 @@ max-specpdl-size instead; it will indirectly limit the specpdl stack size as well.") (make-obsolete-variable 'max-specpdl-size nil "29.1") +(make-obsolete-variable 'comp-enable-subr-trampolines + 'native-comp-enable-subr-trampolines + "29.1") + ;;;; Alternate names for functions - these are not being phased out. diff --git a/src/comp.c b/src/comp.c index 82224845bff..ba3ed95bcce 100644 --- a/src/comp.c +++ b/src/comp.c @@ -5858,7 +5858,8 @@ syms_of_comp (void) dump reload. */ Vnative_comp_eln_load_path = Fcons (build_string ("../native-lisp/"), Qnil); - DEFVAR_LISP ("comp-enable-subr-trampolines", Vcomp_enable_subr_trampolines, + DEFVAR_LISP ("native-comp-enable-subr-trampolines", + Vnative_comp_enable_subr_trampolines, doc: /* If non-nil, enable primitive trampoline synthesis. This makes Emacs respect redefinition or advises of primitive functions when they are called from Lisp code natively-compiled at `native-comp-speed' diff --git a/src/data.c b/src/data.c index a43fa8991fe..0f1d881e00b 100644 --- a/src/data.c +++ b/src/data.c @@ -855,7 +855,7 @@ DEFUN ("fset", Ffset, Sfset, 2, 2, 0, #ifdef HAVE_NATIVE_COMP register Lisp_Object function = XSYMBOL (symbol)->u.s.function; - if (!NILP (Vcomp_enable_subr_trampolines) + if (!NILP (Vnative_comp_enable_subr_trampolines) && SUBRP (function) && !SUBR_NATIVE_COMPILEDP (function)) CALLN (Ffuncall, Qcomp_subr_trampoline_install, symbol); commit abfd00e5c02ec0aed8bbac1eca0d0db1874f020a Author: Andrea Corallo Date: Mon Feb 13 11:56:02 2023 +0100 * lisp/emacs-lisp/comp.el (native-comp-never-optimize-functions): Improve doc diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index eeee66b3d1b..5077ca0aa1f 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -105,7 +105,12 @@ native-comp-never-optimize-functions ;; correctly (see comment in `advice--add-function'). DO NOT ;; REMOVE. macroexpand rename-buffer) - "Primitive functions to exclude from trampoline optimization." + "Primitive functions to exclude from trampoline optimization. + +Primitive functions included in this list will not be called +directly by the native code being compiled, this makes +tranpolines for those primitives not necessary in case of +function redefinition/advise." :type '(repeat symbol) :version "28.1") commit 1795839babcf8572a79aaee3c76ca5b357937a59 Author: Andrea Corallo Date: Mon Feb 13 11:09:46 2023 +0100 Support `comp-enable-subr-trampolines' as string value * src/comp.c (syms_of_comp): Update `comp-enable-subr-trampolines'. * lisp/emacs-lisp/comp.el (native-comp-never-optimize-functions) (comp--trampoline-abs-filename): Support `comp-enable-subr-trampolines' string value. * src/data.c (Ffset): Use Vcomp_enable_subr_trampolines now. diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index 8a41989237e..eeee66b3d1b 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -3782,6 +3782,28 @@ comp-trampoline-search when (file-exists-p filename) do (cl-return (native-elisp-load filename)))) +(defun comp--trampoline-abs-filename (subr-name) + "Return the absolute filename for a trampoline for SUBR-NAME." + (cl-loop + with dirs = (if (stringp comp-enable-subr-trampolines) + (list comp-enable-subr-trampolines) + (if native-compile-target-directory + (list (expand-file-name comp-native-version-dir + native-compile-target-directory)) + (comp-eln-load-path-eff))) + for dir in dirs + for f = (expand-file-name + (comp-trampoline-filename subr-name) + dir) + unless (file-exists-p dir) + do (ignore-errors + (make-directory dir t) + (cl-return f)) + when (file-writable-p f) + do (cl-return f) + finally (error "Cannot find suitable directory for output in \ +`native-comp-eln-load-path'"))) + (defun comp-trampoline-compile (subr-name) "Synthesize compile and return a trampoline for SUBR-NAME." (let* ((lambda-list (comp-make-lambda-list-from-subr @@ -3803,22 +3825,7 @@ comp-trampoline-compile (lexical-binding t)) (comp--native-compile form nil - (cl-loop - for dir in (if native-compile-target-directory - (list (expand-file-name comp-native-version-dir - native-compile-target-directory)) - (comp-eln-load-path-eff)) - for f = (expand-file-name - (comp-trampoline-filename subr-name) - dir) - unless (file-exists-p dir) - do (ignore-errors - (make-directory dir t) - (cl-return f)) - when (file-writable-p f) - do (cl-return f) - finally (error "Cannot find suitable directory for output in \ -`native-comp-eln-load-path'"))))) + (comp--trampoline-abs-filename subr-name)))) ;; Some entry point support code. diff --git a/src/comp.c b/src/comp.c index 7d67995fa87..82224845bff 100644 --- a/src/comp.c +++ b/src/comp.c @@ -5858,12 +5858,15 @@ syms_of_comp (void) dump reload. */ Vnative_comp_eln_load_path = Fcons (build_string ("../native-lisp/"), Qnil); - DEFVAR_BOOL ("comp-enable-subr-trampolines", comp_enable_subr_trampolines, + DEFVAR_LISP ("comp-enable-subr-trampolines", Vcomp_enable_subr_trampolines, doc: /* If non-nil, enable primitive trampoline synthesis. This makes Emacs respect redefinition or advises of primitive functions when they are called from Lisp code natively-compiled at `native-comp-speed' of 2. +If `comp-enable-subr-trampolines' is a string it specifies a directory +in which to deposit the trampoline. + By default, this is enabled, and when Emacs sees a redefined or advised primitive called from natively-compiled Lisp, it generates a trampoline for it on-the-fly. diff --git a/src/data.c b/src/data.c index bb4d1347d72..a43fa8991fe 100644 --- a/src/data.c +++ b/src/data.c @@ -855,7 +855,7 @@ DEFUN ("fset", Ffset, Sfset, 2, 2, 0, #ifdef HAVE_NATIVE_COMP register Lisp_Object function = XSYMBOL (symbol)->u.s.function; - if (comp_enable_subr_trampolines + if (!NILP (Vcomp_enable_subr_trampolines) && SUBRP (function) && !SUBR_NATIVE_COMPILEDP (function)) CALLN (Ffuncall, Qcomp_subr_trampoline_install, symbol); commit b6e2799aa1c3887c2995e115e6ff2f69d59f0e44 Author: Andrea Corallo Date: Mon Feb 13 10:26:03 2023 +0100 * Some more `inhibit-native-compile' clean-up * lisp/emacs-lisp/generate-lisp-file.el (generate-lisp-file-trailer): Use `native-comp-deferred-compilation'. diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index 828e31c43bd..8a41989237e 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -4107,14 +4107,12 @@ comp--native-compile data ;; So we return the compiled function. (native-elisp-load data))) - ;; We may have created a temporary file when we're being - ;; called with something other than a file as the argument. - ;; Delete it if we can. (when (and (not (stringp function-or-file)) (not output) comp-ctxt (comp-ctxt-output comp-ctxt) (file-exists-p (comp-ctxt-output comp-ctxt))) + ;; NOTE: Not sure if we want to remove this or being cautious. (cond ((eq 'windows-nt system-type) ;; We may still be using the temporary .eln file. (ignore-errors (delete-file (comp-ctxt-output comp-ctxt)))) diff --git a/lisp/emacs-lisp/generate-lisp-file.el b/lisp/emacs-lisp/generate-lisp-file.el index b2f67ab848d..167cdfbf826 100644 --- a/lisp/emacs-lisp/generate-lisp-file.el +++ b/lisp/emacs-lisp/generate-lisp-file.el @@ -103,7 +103,7 @@ generate-lisp-file-trailer (insert ";; no-byte-" "compile: t\n")) (unless autoloads (insert ";; no-update-autoloads: t\n")) - (when inhibit-native-compile + (unless native-comp-deferred-compilation (insert ";; no-native-" "compile: t\n")) (when coding (insert (format ";; coding: %s\n" commit c0681cd3477b6fce5e257ac720a32e09357ea157 Author: Andrea Corallo Date: Mon Feb 13 10:19:31 2023 +0100 Revert "Add new variable 'inhibit-native-compilation'" This reverts commit 5fec9182dbeffa88cef6651d8c798ef9665d6681. diff --git a/doc/lispref/compile.texi b/doc/lispref/compile.texi index 8bb079b65df..0617b9c533c 100644 --- a/doc/lispref/compile.texi +++ b/doc/lispref/compile.texi @@ -981,24 +981,6 @@ Native-Compilation Variables This section documents the variables that control native-compilation. -@defvar inhibit-native-compilation -If your Emacs has support for native compilation, Emacs will (by -default) compile the Lisp files you're loading in the background, and -then install the native-compiled versions of the functions. If you -wish to disable this, you can set this variable to non-@code{nil}. If -you want to set it permanently, this should probably be done from the -early init file, since setting it in the normal init file is probably -too late. - -While setting this variable disables automatic compilation of Lisp -files, the compiler may still be invoked to install @dfn{trampolines} -if any built-in functions are redefined. However, these trampolines -will not get written to your cache directory. - -You can also use the @samp{EMACS_INHIBIT_NATIVE_COMPILATION} -environment variable to disable native compilation. -@end defvar - @defopt native-comp-speed This variable specifies the optimization level for native compilation. Its value should be a number between @minus{}1 and 3. Values between diff --git a/etc/NEWS b/etc/NEWS index 5ce18872f1a..8f344aa5764 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -199,14 +199,6 @@ load time. ** Native Compilation +++ -*** New variable 'inhibit-native-compilation'. -If set, Emacs will inhibit native compilation (and won't write -anything to the eln cache automatically). The variable is initialised -from the EMACS_INHIBIT_NATIVE_COMPILATION environment variable on -Emacs startup. - - ---- *** New command 'native-compile-prune-cache'. This command deletes old subdirectories of the eln cache (but not the ones for the current Emacs version). Note that subdirectories of the diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index ab6c8a8ea90..828e31c43bd 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -3803,25 +3803,22 @@ comp-trampoline-compile (lexical-binding t)) (comp--native-compile form nil - ;; If we've disabled nativecomp, don't write the trampolines to - ;; the eln cache (but create them). - (and (not inhibit-native-compilation) - (cl-loop - for dir in (if native-compile-target-directory - (list (expand-file-name comp-native-version-dir - native-compile-target-directory)) - (comp-eln-load-path-eff)) - for f = (expand-file-name - (comp-trampoline-filename subr-name) - dir) - unless (file-exists-p dir) - do (ignore-errors - (make-directory dir t) - (cl-return f)) - when (file-writable-p f) - do (cl-return f) - finally (error "Cannot find suitable directory for output in \ -`native-comp-eln-load-path'")))))) + (cl-loop + for dir in (if native-compile-target-directory + (list (expand-file-name comp-native-version-dir + native-compile-target-directory)) + (comp-eln-load-path-eff)) + for f = (expand-file-name + (comp-trampoline-filename subr-name) + dir) + unless (file-exists-p dir) + do (ignore-errors + (make-directory dir t) + (cl-return f)) + when (file-writable-p f) + do (cl-return f) + finally (error "Cannot find suitable directory for output in \ +`native-comp-eln-load-path'"))))) ;; Some entry point support code. diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el index 7ba2c38cb75..ba1183f686b 100644 --- a/lisp/progmodes/elisp-mode.el +++ b/lisp/progmodes/elisp-mode.el @@ -220,7 +220,7 @@ emacs-lisp-native-compile-and-load Load the compiled code when finished. Use `emacs-lisp-byte-compile-and-load' in combination with -`inhibit-native-compilation' set to nil to achieve asynchronous +`native-comp-deferred-compilation' set to t to achieve asynchronous native compilation." (interactive nil emacs-lisp-mode) (emacs-lisp--before-compile-buffer) diff --git a/lisp/startup.el b/lisp/startup.el index b0a8eed9d38..240cfa30098 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -542,7 +542,7 @@ startup--honor-delayed-native-compilations (setq comp--compilable t)) (defvar native-comp-eln-load-path) -(defvar inhibit-native-compilation) +(defvar native-comp-deferred-compilation) (defvar comp-enable-subr-trampolines) (defvar startup--original-eln-load-path nil @@ -579,9 +579,6 @@ normal-top-level It sets `command-line-processed', processes the command-line, reads the initialization files, etc. It is the default value of the variable `top-level'." - ;; Allow disabling automatic .elc->.eln processing. - (setq inhibit-native-compilation (getenv "EMACS_INHIBIT_NATIVE_COMPILATION")) - (if command-line-processed (message internal--top-level-message) (setq command-line-processed t) @@ -600,7 +597,7 @@ normal-top-level ;; in this session. This is necessary if libgccjit is not ;; available on MS-Windows, but Emacs was built with ;; native-compilation support. - (setq inhibit-native-compilation t + (setq native-comp-deferred-compilation nil comp-enable-subr-trampolines nil)) ;; Form `native-comp-eln-load-path'. diff --git a/lisp/subr.el b/lisp/subr.el index 6282abc1b16..a56aeab724a 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1894,9 +1894,6 @@ max-specpdl-size instead; it will indirectly limit the specpdl stack size as well.") (make-obsolete-variable 'max-specpdl-size nil "29.1") -(make-obsolete-variable 'native-comp-deferred-compilation - 'inhibit-native-compilation "29.1") - ;;;; Alternate names for functions - these are not being phased out. diff --git a/src/comp.c b/src/comp.c index 88b871aaae8..7d67995fa87 100644 --- a/src/comp.c +++ b/src/comp.c @@ -5174,7 +5174,6 @@ maybe_defer_native_compilation (Lisp_Object function_name, return; if (!native_comp_deferred_compilation - || !NILP (Vinhibit_native_compilation) || noninteractive || !NILP (Vpurify_flag) || !COMPILEDP (definition) @@ -5678,13 +5677,6 @@ syms_of_comp (void) doc: /* Non-nil when comp.el can be native compiled. For internal use. */); /* Compiler control customizes. */ - DEFVAR_LISP ("inhibit-native-compilation", Vinhibit_native_compilation, - doc: /* If non-nil, inhibit automatic native compilation of loaded .elc files. - -After compilation, each function definition is updated to the native -compiled one. */); - Vinhibit_native_compilation = Qnil; - DEFVAR_BOOL ("native-comp-deferred-compilation", native_comp_deferred_compilation, doc: /* If non-nil compile loaded .elc files asynchronously. commit 3969a34fa1ba1647665c662ce0a594b92f3f9d87 Author: Andrea Corallo Date: Mon Feb 13 10:15:33 2023 +0100 Revert "Rename to inhibit-automatic-native-compilation" This reverts commit f97993ee667f9be7589825f3a4fbc095d6944ec6. diff --git a/doc/lispref/compile.texi b/doc/lispref/compile.texi index be2125a9ab3..8bb079b65df 100644 --- a/doc/lispref/compile.texi +++ b/doc/lispref/compile.texi @@ -981,7 +981,7 @@ Native-Compilation Variables This section documents the variables that control native-compilation. -@defvar inhibit-automatic-native-compilation +@defvar inhibit-native-compilation If your Emacs has support for native compilation, Emacs will (by default) compile the Lisp files you're loading in the background, and then install the native-compiled versions of the functions. If you @@ -995,7 +995,7 @@ Native-Compilation Variables if any built-in functions are redefined. However, these trampolines will not get written to your cache directory. -You can also use the @samp{EMACS_INHIBIT_AUTOMATIC_NATIVE_COMPILATION} +You can also use the @samp{EMACS_INHIBIT_NATIVE_COMPILATION} environment variable to disable native compilation. @end defvar diff --git a/etc/NEWS b/etc/NEWS index 2d15e39036a..5ce18872f1a 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -199,11 +199,12 @@ load time. ** Native Compilation +++ -*** New variable 'inhibit-automatic-native-compilation'. +*** New variable 'inhibit-native-compilation'. If set, Emacs will inhibit native compilation (and won't write -anything to the eln cache automatically). The variable is initialized -during Emacs startup from the environment variable -'EMACS_INHIBIT_AUTOMATIC_NATIVE_COMPILATION'. +anything to the eln cache automatically). The variable is initialised +from the EMACS_INHIBIT_NATIVE_COMPILATION environment variable on +Emacs startup. + --- *** New command 'native-compile-prune-cache'. diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index 7ba8e956fb2..ab6c8a8ea90 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -3805,7 +3805,7 @@ comp-trampoline-compile form nil ;; If we've disabled nativecomp, don't write the trampolines to ;; the eln cache (but create them). - (and (not inhibit-automatic-native-compilation) + (and (not inhibit-native-compilation) (cl-loop for dir in (if native-compile-target-directory (list (expand-file-name comp-native-version-dir diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el index be969b0c3e3..7ba2c38cb75 100644 --- a/lisp/progmodes/elisp-mode.el +++ b/lisp/progmodes/elisp-mode.el @@ -220,8 +220,8 @@ emacs-lisp-native-compile-and-load Load the compiled code when finished. Use `emacs-lisp-byte-compile-and-load' in combination with -`inhibit-automatic-native-compilation' set to nil to achieve -asynchronous native compilation." +`inhibit-native-compilation' set to nil to achieve asynchronous +native compilation." (interactive nil emacs-lisp-mode) (emacs-lisp--before-compile-buffer) (load (native-compile buffer-file-name))) diff --git a/lisp/startup.el b/lisp/startup.el index e5ec15eebea..b0a8eed9d38 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -542,7 +542,7 @@ startup--honor-delayed-native-compilations (setq comp--compilable t)) (defvar native-comp-eln-load-path) -(defvar inhibit-automatic-native-compilation) +(defvar inhibit-native-compilation) (defvar comp-enable-subr-trampolines) (defvar startup--original-eln-load-path nil @@ -580,8 +580,7 @@ normal-top-level reads the initialization files, etc. It is the default value of the variable `top-level'." ;; Allow disabling automatic .elc->.eln processing. - (setq inhibit-automatic-native-compilation - (getenv "EMACS_INHIBIT_AUTOMATIC_NATIVE_COMPILATION")) + (setq inhibit-native-compilation (getenv "EMACS_INHIBIT_NATIVE_COMPILATION")) (if command-line-processed (message internal--top-level-message) @@ -601,7 +600,7 @@ normal-top-level ;; in this session. This is necessary if libgccjit is not ;; available on MS-Windows, but Emacs was built with ;; native-compilation support. - (setq inhibit-automatic-native-compilation t + (setq inhibit-native-compilation t comp-enable-subr-trampolines nil)) ;; Form `native-comp-eln-load-path'. diff --git a/lisp/subr.el b/lisp/subr.el index 9e6388987df..6282abc1b16 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1895,7 +1895,7 @@ max-specpdl-size (make-obsolete-variable 'max-specpdl-size nil "29.1") (make-obsolete-variable 'native-comp-deferred-compilation - 'inhibit-automatic-native-compilation "29.1") + 'inhibit-native-compilation "29.1") ;;;; Alternate names for functions - these are not being phased out. diff --git a/src/comp.c b/src/comp.c index 10cf7962ba1..88b871aaae8 100644 --- a/src/comp.c +++ b/src/comp.c @@ -5174,7 +5174,7 @@ maybe_defer_native_compilation (Lisp_Object function_name, return; if (!native_comp_deferred_compilation - || !NILP (Vinhibit_automatic_native_compilation) + || !NILP (Vinhibit_native_compilation) || noninteractive || !NILP (Vpurify_flag) || !COMPILEDP (definition) @@ -5678,13 +5678,12 @@ syms_of_comp (void) doc: /* Non-nil when comp.el can be native compiled. For internal use. */); /* Compiler control customizes. */ - DEFVAR_LISP ("inhibit-automatic-native-compilation", - Vinhibit_automatic_native_compilation, + DEFVAR_LISP ("inhibit-native-compilation", Vinhibit_native_compilation, doc: /* If non-nil, inhibit automatic native compilation of loaded .elc files. After compilation, each function definition is updated to the native compiled one. */); - Vinhibit_automatic_native_compilation = Qnil; + Vinhibit_native_compilation = Qnil; DEFVAR_BOOL ("native-comp-deferred-compilation", native_comp_deferred_compilation,