From 12bab2092045876a8193402c9f69af196ea22969 Mon Sep 17 00:00:00 2001 From: Mattias Engdegård Date: Thu, 6 May 2021 15:50:39 +0200 Subject: Tidy file-matching regexps and remove some ineffective backslashes * lisp/emacs-lisp/package.el (package--delete-directory): * lisp/net/tramp-cmds.el (tramp-recompile-elpa): Escape dot; replace $ with \'. * lisp/help.el (help-for-help): * lisp/transient.el (transient-font-lock-keywords): Remove useless backslashes. --- lisp/emacs-lisp/package.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index e1339177519..b68ebfbd887 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -2267,7 +2267,7 @@ Clean-up the corresponding .eln files if Emacs is native compiled." (when (featurep 'native-compile) (cl-loop - for file in (directory-files-recursively dir ".el\\'") + for file in (directory-files-recursively dir "\\.el\\'") do (comp-clean-up-stale-eln (comp-el-to-eln-filename file)))) (delete-directory dir t)) -- cgit v1.2.3 From 643cc3fa144e94b33a7b8f1d4965cec7b383ed35 Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Thu, 6 May 2021 09:57:35 +0200 Subject: * Rename comp-limple-mode -> native-comp-limple-mode * lisp/emacs-lisp/comp.el (comp-limple-lock-keywords): Doc update. (native-comp-limple-mode, comp-log-to-buffer): Rename comp-limple-mode -> native-comp-limple-mode. --- lisp/emacs-lisp/comp.el | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index f700faa38b3..19a6d1eef9c 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -1028,9 +1028,9 @@ Assume allocation class 'd-default as default." (,(rx-to-string `(seq "(" (group-n 1 (or ,@(mapcar #'symbol-name comp-limple-ops))))) (1 font-lock-keyword-face))) - "Highlights used by `comp-limple-mode'.") + "Highlights used by `native-comp-limple-mode'.") -(define-derived-mode comp-limple-mode fundamental-mode "LIMPLE" +(define-derived-mode native-comp-limple-mode fundamental-mode "LIMPLE" "Syntax-highlight LIMPLE IR." (setf font-lock-defaults '(comp-limple-lock-keywords))) @@ -1059,8 +1059,8 @@ with `message'. Otherwise, log with `comp-log-to-buffer'." (inhibit-read-only t) at-end-p) (with-current-buffer log-buffer - (unless (eq major-mode 'comp-limple-mode) - (comp-limple-mode)) + (unless (eq major-mode 'native-comp-limple-mode) + (native-comp-limple-mode)) (when (= (point) (point-max)) (setf at-end-p t)) (save-excursion -- cgit v1.2.3 From 43f29696adc37ae75d87cd4b86d78e830e01e018 Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Thu, 6 May 2021 10:12:48 +0200 Subject: Rename comp-speed -> native-comp-speed * lisp/emacs-lisp/bytecomp.el (byte-compile-from-buffer): Rename comp-speed -> native-comp-speed. * lisp/emacs-lisp/comp.el (native-comp-speed, comp-ctxt, comp-func, comp-spill-lap-function, comp-trampoline-compile, comp-run-async-workers): Likewise. * src/comp.c (emit_ctxt_code, load_comp_unit, syms_of_comp): Likewise. * test/src/comp-tests.el (comp-tests-tco, comp-tests-fw-prop-1) (comp-tests-check-ret-type-spec, comp-tests-pure): Likewise. --- lisp/emacs-lisp/bytecomp.el | 4 ++-- lisp/emacs-lisp/comp.el | 18 +++++++++--------- src/comp.c | 6 +++--- test/src/comp-tests.el | 8 ++++---- 4 files changed, 18 insertions(+), 18 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index e93cee99249..2a07ea79f56 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -2238,8 +2238,8 @@ With argument ARG, insert value in current buffer after the form." (setq byte-compile-noruntime-functions nil) (setq byte-compile-new-defuns nil) (when byte-native-compiling - (defvar comp-speed) - (push `(comp-speed . ,comp-speed) byte-native-qualities) + (defvar native-comp-speed) + (push `(native-comp-speed . ,native-comp-speed) byte-native-qualities) (defvar comp-debug) (push `(comp-debug . ,comp-debug) byte-native-qualities) (defvar comp-native-driver-options) diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index 19a6d1eef9c..d02c3b0c23b 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -43,7 +43,7 @@ "Emacs Lisp native compiler." :group 'lisp) -(defcustom comp-speed 2 +(defcustom native-comp-speed 2 "Optimization level for native compilation, a number between -1 and 3. -1 functions are kept in bytecode form and no native compilation is performed. 0 native compilation is performed with no optimizations. @@ -743,7 +743,7 @@ Returns ELT." "Lisp side of the compiler context." (output nil :type string :documentation "Target output file-name for the compilation.") - (speed comp-speed :type number + (speed native-comp-speed :type number :documentation "Default speed for this compilation unit.") (debug comp-debug :type number :documentation "Default debug level for this compilation unit.") @@ -899,7 +899,7 @@ CFG is mutated by a pass.") (has-non-local nil :type boolean :documentation "t if non local jumps are present.") (speed nil :type number - :documentation "Optimization level (see `comp-speed').") + :documentation "Optimization level (see `native-comp-speed').") (pure nil :type boolean :documentation "t if pure nil otherwise.") (type nil :type (or null comp-mvar) @@ -1334,7 +1334,7 @@ clashes." filename (when byte-native-for-bootstrap (car (last comp-eln-load-path)))))) - (setf (comp-ctxt-speed comp-ctxt) (alist-get 'comp-speed + (setf (comp-ctxt-speed comp-ctxt) (alist-get 'native-comp-speed byte-native-qualities) (comp-ctxt-debug comp-ctxt) (alist-get 'comp-debug byte-native-qualities) @@ -3250,14 +3250,14 @@ Return t if something was changed." ;; funcall trampoline gets optimized into normal indirect calls. ;; This makes effectively this calls equivalent to all the subrs that got ;; dedicated byte-code ops. -;; Triggered at comp-speed >= 2. +;; Triggered at native-comp-speed >= 2. ;; - Recursive calls gets optimized into direct calls. -;; Triggered at comp-speed >= 2. +;; Triggered at native-comp-speed >= 2. ;; - Intra compilation unit procedure calls gets optimized into direct calls. ;; This can be a big win and even allow gcc to inline but does not make ;; function in the compilation unit re-definable safely without recompiling ;; the full compilation unit. -;; For this reason this is triggered only at comp-speed == 3. +;; For this reason this is triggered only at native-comp-speed == 3. (defun comp-func-in-unit (func) "Given FUNC return the `comp-fun' definition in the current context. @@ -3756,7 +3756,7 @@ Return the trampoline if found or nil otherwise." ;; Use speed 0 to maximize compilation speed and not to ;; optimize away funcall calls! (byte-optimize nil) - (comp-speed 1) + (native-comp-speed 1) (lexical-binding t)) (comp--native-compile form nil @@ -3905,7 +3905,7 @@ display a message." do (let* ((expr `((require 'comp) ,(when (boundp 'backtrace-line-length) `(setf backtrace-line-length ,backtrace-line-length)) - (setf comp-speed ,comp-speed + (setf native-comp-speed ,native-comp-speed comp-debug ,comp-debug comp-verbose ,comp-verbose comp-libgccjit-reproducer ,comp-libgccjit-reproducer diff --git a/src/comp.c b/src/comp.c index 89667b2febc..c87a3e66661 100644 --- a/src/comp.c +++ b/src/comp.c @@ -2745,7 +2745,7 @@ emit_ctxt_code (void) { /* Emit optimize qualities. */ Lisp_Object opt_qly[] = - { Fcons (Qcomp_speed, make_fixnum (comp.speed)), + { Fcons (Qnative_comp_speed, make_fixnum (comp.speed)), Fcons (Qcomp_debug, make_fixnum (comp.debug)), Fcons (Qgccjit, Fcomp_libgccjit_version ()) }; @@ -4856,7 +4856,7 @@ load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u, bool loading_dump, /* 'dlopen' returns the same handle when trying to load two times the same shared. In this case touching 'd_reloc' etc leads to fails in case a frame with a reference to it in a live reg is - active (comp-speed > 0). + active (native-comp-speed > 0). We must *never* mess with static pointers in an already loaded eln. */ @@ -5207,7 +5207,7 @@ After compilation, each function definition is updated to the native compiled one. */); comp_deferred_compilation = true; - DEFSYM (Qcomp_speed, "comp-speed"); + DEFSYM (Qnative_comp_speed, "native-comp-speed"); DEFSYM (Qcomp_debug, "comp-debug"); DEFSYM (Qcomp_native_driver_options, "comp-native-driver-options"); DEFSYM (Qcomp_libgccjit_reproducer, "comp-libgccjit-reproducer"); diff --git a/test/src/comp-tests.el b/test/src/comp-tests.el index e3e4bdd9b61..9e9097c994a 100644 --- a/test/src/comp-tests.el +++ b/test/src/comp-tests.el @@ -786,7 +786,7 @@ Return a list of results." (comp-deftest tco () "Check for tail recursion elimination." - (let ((comp-speed 3) + (let ((native-comp-speed 3) ;; Disable ipa-pure otherwise `comp-tests-tco-f' gets ;; optimized-out. (comp-disabled-passes '(comp-ipa-pure)) @@ -814,7 +814,7 @@ Return a list of results." (comp-deftest fw-prop-1 () "Some tests for forward propagation." - (let ((comp-speed 2) + (let ((native-comp-speed 2) (comp-post-pass-hooks '((comp-final comp-tests-fw-prop-checker-1)))) (eval '(defun comp-tests-fw-prop-1-f () (let* ((a "xxx") @@ -828,7 +828,7 @@ Return a list of results." (defun comp-tests-check-ret-type-spec (func-form ret-type) (let ((lexical-binding t) - (comp-speed 2) + (native-comp-speed 2) (f-name (cl-second func-form))) (eval func-form t) (native-compile f-name) @@ -1399,7 +1399,7 @@ Return a list of results." (comp-deftest pure () "Some tests for pure functions optimization." - (let ((comp-speed 3) + (let ((native-comp-speed 3) (comp-post-pass-hooks '((comp-final comp-tests-pure-checker-1 comp-tests-pure-checker-2)))) (load (native-compile (ert-resource-file "comp-test-pure.el"))) -- cgit v1.2.3 From 94c69eb1d7dfbe5a6a792c707de0bffe6cd11e28 Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Thu, 6 May 2021 10:14:00 +0200 Subject: Rename comp-debug -> native-comp-debug * src/comp.c (emit_ctxt_code, syms_of_comp): Rename comp-debug -> native-comp-debug. * lisp/emacs-lisp/comp.el (native-comp-debug, comp-ctxt) (comp-spill-lap-function, comp-run-async-workers): Likewise. * lisp/emacs-lisp/bytecomp.el (byte-compile-from-buffer): Likewise. * test/src/comp-tests.el (comp-tests-bootstrap): Likewise. --- lisp/emacs-lisp/bytecomp.el | 4 ++-- lisp/emacs-lisp/comp.el | 8 ++++---- src/comp.c | 4 ++-- test/src/comp-tests.el | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 2a07ea79f56..16740e92d35 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -2240,8 +2240,8 @@ With argument ARG, insert value in current buffer after the form." (when byte-native-compiling (defvar native-comp-speed) (push `(native-comp-speed . ,native-comp-speed) byte-native-qualities) - (defvar comp-debug) - (push `(comp-debug . ,comp-debug) byte-native-qualities) + (defvar native-comp-debug) + (push `(native-comp-debug . ,native-comp-debug) byte-native-qualities) (defvar comp-native-driver-options) (push `(comp-native-driver-options . ,comp-native-driver-options) byte-native-qualities) diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index d02c3b0c23b..4a8fee01c5d 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -55,7 +55,7 @@ :safe #'integerp :version "28.1") -(defcustom comp-debug (if (eq 'windows-nt system-type) 1 0) +(defcustom native-comp-debug (if (eq 'windows-nt system-type) 1 0) "Debug level for native compilation, a number between 0 and 3. This is intended for debugging the compiler itself. 0 no debug output. @@ -745,7 +745,7 @@ Returns ELT." :documentation "Target output file-name for the compilation.") (speed native-comp-speed :type number :documentation "Default speed for this compilation unit.") - (debug comp-debug :type number + (debug native-comp-debug :type number :documentation "Default debug level for this compilation unit.") (driver-options comp-native-driver-options :type list :documentation "Options for the GCC driver.") @@ -1336,7 +1336,7 @@ clashes." (car (last comp-eln-load-path)))))) (setf (comp-ctxt-speed comp-ctxt) (alist-get 'native-comp-speed byte-native-qualities) - (comp-ctxt-debug comp-ctxt) (alist-get 'comp-debug + (comp-ctxt-debug comp-ctxt) (alist-get 'native-comp-debug byte-native-qualities) (comp-ctxt-driver-options comp-ctxt) (alist-get 'comp-native-driver-options byte-native-qualities) @@ -3906,7 +3906,7 @@ display a message." ,(when (boundp 'backtrace-line-length) `(setf backtrace-line-length ,backtrace-line-length)) (setf native-comp-speed ,native-comp-speed - comp-debug ,comp-debug + native-comp-debug ,native-comp-debug comp-verbose ,comp-verbose comp-libgccjit-reproducer ,comp-libgccjit-reproducer comp-async-compilation t diff --git a/src/comp.c b/src/comp.c index c87a3e66661..3608167cad1 100644 --- a/src/comp.c +++ b/src/comp.c @@ -2746,7 +2746,7 @@ emit_ctxt_code (void) /* Emit optimize qualities. */ Lisp_Object opt_qly[] = { Fcons (Qnative_comp_speed, make_fixnum (comp.speed)), - Fcons (Qcomp_debug, make_fixnum (comp.debug)), + Fcons (Qnative_comp_debug, make_fixnum (comp.debug)), Fcons (Qgccjit, Fcomp_libgccjit_version ()) }; emit_static_object (TEXT_OPTIM_QLY_SYM, Flist (ARRAYELTS (opt_qly), opt_qly)); @@ -5208,7 +5208,7 @@ compiled one. */); comp_deferred_compilation = true; DEFSYM (Qnative_comp_speed, "native-comp-speed"); - DEFSYM (Qcomp_debug, "comp-debug"); + DEFSYM (Qnative_comp_debug, "native-comp-debug"); DEFSYM (Qcomp_native_driver_options, "comp-native-driver-options"); DEFSYM (Qcomp_libgccjit_reproducer, "comp-libgccjit-reproducer"); diff --git a/test/src/comp-tests.el b/test/src/comp-tests.el index 9e9097c994a..be02c30a752 100644 --- a/test/src/comp-tests.el +++ b/test/src/comp-tests.el @@ -59,7 +59,7 @@ Check that the resulting binaries do not differ." (comp1-src (make-temp-file "stage1-" nil ".el")) (comp2-src (make-temp-file "stage2-" nil ".el")) ;; Can't use debug symbols. - (comp-debug 0)) + (native-comp-debug 0)) (copy-file comp-src comp1-src t) (copy-file comp-src comp2-src t) (let ((load-no-native t)) -- cgit v1.2.3 From 6efd7885dbae1b430b65ed2bf13d4a7dfd9d08fd Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Thu, 6 May 2021 10:17:12 +0200 Subject: * Rename comp-verbose -> native-comp-verbose * lisp/emacs-lisp/comp.el (native-comp-verbose, comp-log) (comp-log-func, comp-final, comp-run-async-workers): Rename comp-verbose -> native-comp-verbose. --- lisp/emacs-lisp/comp.el | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index 4a8fee01c5d..18920020e6c 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -67,7 +67,7 @@ This is intended for debugging the compiler itself. :safe #'natnump :version "28.1") -(defcustom comp-verbose 0 +(defcustom native-comp-verbose 0 "Compiler verbosity for native compilation, a number between 0 and 3. This is intended for debugging the compiler itself. 0 no logging. @@ -1037,9 +1037,9 @@ Assume allocation class 'd-default as default." (cl-defun comp-log (data &optional (level 1) quoted) "Log DATA at LEVEL. LEVEL is a number from 1-3, and defaults to 1; if it is less -than `comp-verbose', do nothing. If `noninteractive', log +than `native-comp-verbose', do nothing. If `noninteractive', log with `message'. Otherwise, log with `comp-log-to-buffer'." - (when (>= comp-verbose level) + (when (>= native-comp-verbose level) (if noninteractive (cl-typecase data (atom (message "%s" data)) @@ -1091,7 +1091,7 @@ with `message'. Otherwise, log with `comp-log-to-buffer'." (defun comp-log-func (func verbosity) "Log function FUNC at VERBOSITY. VERBOSITY is a number between 0 and 3." - (when (>= comp-verbose verbosity) + (when (>= native-comp-verbose verbosity) (comp-log (format "\nFunction: %s\n" (comp-func-name func)) verbosity) (cl-loop for block-name being each hash-keys of (comp-func-blocks func) @@ -3650,7 +3650,7 @@ Prepare every function for final compilation and drive the C back-end." (print-circle t) (print-escape-multibyte t) (expr `((require 'comp) - (setf comp-verbose ,comp-verbose + (setf native-comp-verbose ,native-comp-verbose comp-libgccjit-reproducer ,comp-libgccjit-reproducer comp-ctxt ,comp-ctxt comp-eln-load-path ',comp-eln-load-path @@ -3907,7 +3907,7 @@ display a message." `(setf backtrace-line-length ,backtrace-line-length)) (setf native-comp-speed ,native-comp-speed native-comp-debug ,native-comp-debug - comp-verbose ,comp-verbose + native-comp-verbose ,native-comp-verbose comp-libgccjit-reproducer ,comp-libgccjit-reproducer comp-async-compilation t comp-eln-load-path ',comp-eln-load-path -- cgit v1.2.3 From 65952950780aacc7693d9f7ef9a80c76073e99b1 Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Thu, 6 May 2021 10:18:32 +0200 Subject: * Rename comp-always-compile → native-comp-always-compile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * lisp/emacs-lisp/comp.el (native-comp-always-compile) (comp-run-async-workers): comp-always-compile → native-comp-always-compile. --- lisp/emacs-lisp/comp.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index 18920020e6c..c9d1c94ec95 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -78,7 +78,7 @@ This is intended for debugging the compiler itself. :risky t :version "28.1") -(defcustom comp-always-compile nil +(defcustom native-comp-always-compile nil "Non-nil means unconditionally (re-)compile all files." :type 'boolean :version "28.1") @@ -3897,7 +3897,7 @@ display a message." do (cl-assert (string-match-p comp-valid-source-re source-file) nil "`comp-files-queue' should be \".el\" files: %s" source-file) - when (or comp-always-compile + when (or native-comp-always-compile load ; Always compile when the compilation is ; commanded for late load. (file-newer-than-file-p -- cgit v1.2.3 From 85b61c0c58c5198715e5b7bfff9d7319a6ab1a2c Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Thu, 6 May 2021 10:19:35 +0200 Subject: Rename comp-bootstrap-deny-list → native-comp-bootstrap-deny-list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * lisp/emacs-lisp/comp.el (native-comp-bootstrap-deny-list) (batch-native-compile): Rename comp-bootstrap-deny-list → native-comp-bootstrap-deny-list. --- lisp/emacs-lisp/comp.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index c9d1c94ec95..621bb81455d 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -90,7 +90,7 @@ Files whose names match any regexp are excluded from native compilation." :type '(repeat regexp) :version "28.1") -(defcustom comp-bootstrap-deny-list +(defcustom native-comp-bootstrap-deny-list '() "List of regexps to exclude files from native compilation during bootstrap. Files whose names match any regexp are excluded from native compilation @@ -4159,7 +4159,7 @@ Native compilation equivalent to `batch-byte-compile'." (cl-loop for file in command-line-args-left if (or (null byte-native-for-bootstrap) (cl-notany (lambda (re) (string-match re file)) - comp-bootstrap-deny-list)) + native-comp-bootstrap-deny-list)) do (comp--native-compile file) else do (byte-compile-file file))) -- cgit v1.2.3 From 31ca1c3e81b26357692c4c2428744f7f2f153596 Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Thu, 6 May 2021 10:26:33 +0200 Subject: Rename comp-never-optimize-functions → native-comp-never-optimize-functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * lisp/emacs-lisp/nadvice.el (advice--add-function): Rename comp-never-optimize-functions → native-comp-never-optimize-functions. * lisp/emacs-lisp/comp.el (native-comp-never-optimize-functions) (comp-subr-trampoline-install, comp-call-optim-form-call): Likewise. --- lisp/emacs-lisp/comp.el | 6 +++--- lisp/emacs-lisp/nadvice.el | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index 621bb81455d..b1b55914043 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -98,7 +98,7 @@ during bootstrap." :type '(repeat regexp) :version "28.1") -(defcustom comp-never-optimize-functions +(defcustom native-comp-never-optimize-functions '(;; The following two are mandatory for Emacs to be working ;; correctly (see comment in `advice--add-function'). DO NOT ;; REMOVE. @@ -662,7 +662,7 @@ Useful to hook into pass checkers.") (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) - (memq subr-name comp-never-optimize-functions) + (memq subr-name native-comp-never-optimize-functions) (gethash subr-name comp-installed-trampolines-h)) (cl-assert (subr-primitive-p (symbol-function subr-name))) (comp--install-trampoline @@ -3275,7 +3275,7 @@ FUNCTION can be a function-name or byte compiled function." (when (and callee (or (symbolp callee) (gethash callee (comp-ctxt-byte-func-to-func-h comp-ctxt))) - (not (memq callee comp-never-optimize-functions))) + (not (memq callee native-comp-never-optimize-functions))) (let* ((f (if (symbolp callee) (symbol-function callee) (cl-assert (byte-code-function-p callee)) diff --git a/lisp/emacs-lisp/nadvice.el b/lisp/emacs-lisp/nadvice.el index 747572a3363..bf3e9446399 100644 --- a/lisp/emacs-lisp/nadvice.el +++ b/lisp/emacs-lisp/nadvice.el @@ -324,13 +324,13 @@ is also interactive. There are 3 cases: (subr-primitive-p (gv-deref ref))) (let ((subr-name (intern (subr-name (gv-deref ref))))) ;; Requiring the native compiler to advice `macroexpand' cause a - ;; circular dependency in eager macro expansion. - ;; uniquify is advising `rename-buffer' while being loaded in - ;; loadup.el. This would require the whole native compiler - ;; machinery but we don't want to include it in the dump. - ;; Because these two functions are already handled in - ;; `comp-never-optimize-functions' we hack the problem this way - ;; for now :/ + ;; circular dependency in eager macro expansion. uniquify is + ;; advising `rename-buffer' while being loaded in loadup.el. + ;; This would require the whole native compiler machinery but we + ;; don't want to include it in the dump. Because these two + ;; functions are already handled in + ;; `native-comp-never-optimize-functions' we hack the problem + ;; this way for now :/ (unless (memq subr-name '(macroexpand rename-buffer)) ;; Must require explicitly as during bootstrap we have no ;; autoloads. -- cgit v1.2.3 From d8f84a1c00ebf3020e201587e182cc8e4bc4a170 Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Thu, 6 May 2021 10:27:57 +0200 Subject: * Rename comp-async-jobs-number → native-comp-async-jobs-number MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * lisp/emacs-lisp/comp.el (native-comp-async-jobs-number) (comp-effective-async-max-jobs, native--compile-async) (native-compile-async): Rename comp-async-jobs-number → native-comp-async-jobs-number. --- lisp/emacs-lisp/comp.el | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index b1b55914043..54c51c6e34b 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -107,7 +107,7 @@ during bootstrap." :type '(repeat symbol) :version "28.1") -(defcustom comp-async-jobs-number 0 +(defcustom native-comp-async-jobs-number 0 "Default number of subprocesses used for async native compilation. Value of zero means to use half the number of the CPU's execution units, or one if there's just one execution unit." @@ -3851,7 +3851,7 @@ processes from `comp-async-compilations'" (defvar comp-num-cpus nil) (defun comp-effective-async-max-jobs () "Compute the effective number of async jobs." - (if (zerop comp-async-jobs-number) + (if (zerop native-comp-async-jobs-number) (or comp-num-cpus (setf comp-num-cpus ;; FIXME: we already have a function to determine @@ -3867,7 +3867,7 @@ processes from `comp-async-compilations'" (shell-command-to-string "sysctl -n hw.ncpu"))) (t 1)) 2)))) - comp-async-jobs-number)) + native-comp-async-jobs-number)) (defvar comp-last-scanned-async-output nil) (make-variable-buffer-local 'comp-last-scanned-async-output) @@ -4066,7 +4066,7 @@ nil -- Select all files. a string -- A regular expression selecting files with matching names. a function -- A function selecting files with matching names. -The variable `comp-async-jobs-number' specifies the number +The variable `native-comp-async-jobs-number' specifies the number of (commands) to run simultaneously. LOAD can also be the symbol `late'. This is used internally if @@ -4200,7 +4200,7 @@ nil -- Select all files. a string -- A regular expression selecting files with matching names. a function -- A function selecting files with matching names. -The variable `comp-async-jobs-number' specifies the number +The variable `native-comp-async-jobs-number' specifies the number of (commands) to run simultaneously." ;; Normalize: we only want to pass t or nil, never e.g. `late'. (let ((load (not (not load)))) -- cgit v1.2.3 From e73186a44644705ff50d2b819fd2eb213e713259 Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Thu, 6 May 2021 14:49:31 +0200 Subject: * Rename comp-async-cu-done-functions → native-comp-async-cu-done-functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * lisp/emacs-lisp/comp.el (native-comp-async-cu-done-functions) (comp-run-async-workers): Rename comp-async-cu-done-functions → native-comp-async-cu-done-functions. --- lisp/emacs-lisp/comp.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index 54c51c6e34b..93541fa6d8f 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -115,7 +115,7 @@ or one if there's just one execution unit." :risky t :version "28.1") -(defcustom comp-async-cu-done-functions nil +(defcustom native-comp-async-cu-done-functions nil "List of functions to call after asynchronously compiling one compilation unit. Called with one argument FILE, the filename used as input to compilation." @@ -3940,7 +3940,7 @@ display a message." :sentinel (lambda (process _event) (run-hook-with-args - 'comp-async-cu-done-functions + 'native-comp-async-cu-done-functions source-file) (comp-accept-and-process-async-output process) (ignore-errors (delete-file temp-file)) -- cgit v1.2.3 From 4e063bf8eb47cb87891a71021be636a33492f706 Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Thu, 6 May 2021 14:52:43 +0200 Subject: * Rename comp-async-all-done-hook → native-comp-async-all-done-hook MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * lisp/emacs-lisp/comp.el (native-comp-async-all-done-hook) (comp-run-async-workers): Rename comp-async-all-done-hook → native-comp-async-all-done-hook. --- lisp/emacs-lisp/comp.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index 93541fa6d8f..9756d1f58a0 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -122,7 +122,7 @@ compilation." :type 'hook :version "28.1") -(defcustom comp-async-all-done-hook nil +(defcustom native-comp-async-all-done-hook nil "Hook run after completing asynchronous compilation of all input files." :type 'hook :version "28.1") @@ -3886,7 +3886,7 @@ processes from `comp-async-compilations'" (defun comp-run-async-workers () "Start compiling files from `comp-files-queue' asynchronously. -When compilation is finished, run `comp-async-all-done-hook' and +When compilation is finished, run `native-comp-async-all-done-hook' and display a message." (if (or comp-files-queue (> (comp-async-runnings) 0)) @@ -3958,7 +3958,7 @@ display a message." when (>= (comp-async-runnings) (comp-effective-async-max-jobs)) do (cl-return))) ;; No files left to compile and all processes finished. - (run-hooks 'comp-async-all-done-hook) + (run-hooks 'native-comp-async-all-done-hook) (with-current-buffer (get-buffer-create comp-async-buffer-name) (save-excursion (goto-char (point-max)) -- cgit v1.2.3 From 4e01605efab2ad8521ed9783d64862a6459ec91f Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Thu, 6 May 2021 14:53:28 +0200 Subject: * Rename comp-async-env-modifier-form → native-comp-async-env-modifier-form MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * lisp/emacs-lisp/comp.el (native-comp-async-env-modifier-form) (comp-final, comp-run-async-workers): Rename comp-async-env-modifier-form → native-comp-async-env-modifier-form. --- lisp/emacs-lisp/comp.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index 9756d1f58a0..24b65424a18 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -127,7 +127,7 @@ compilation." :type 'hook :version "28.1") -(defcustom comp-async-env-modifier-form nil +(defcustom native-comp-async-env-modifier-form nil "Form evaluated before compilation by each asynchronous compilation subprocess. Used to modify the compiler environment." :type 'sexp @@ -3657,7 +3657,7 @@ Prepare every function for final compilation and drive the C back-end." comp-native-driver-options ',comp-native-driver-options load-path ',load-path) - ,comp-async-env-modifier-form + ,native-comp-async-env-modifier-form (message "Compiling %s..." ',output) (comp-final1))) (temp-file (make-temp-file @@ -3915,7 +3915,7 @@ display a message." ',comp-native-driver-options load-path ',load-path warning-fill-column most-positive-fixnum) - ,comp-async-env-modifier-form + ,native-comp-async-env-modifier-form (message "Compiling %s..." ,source-file) (comp--native-compile ,source-file ,(and load t)))) (source-file1 source-file) ;; Make the closure works :/ -- cgit v1.2.3 From c90129c5e5404d12b538aa3b69c7af4b89a728cd Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Thu, 6 May 2021 14:54:32 +0200 Subject: * Rename comp-async-report-warnings-errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * lisp/emacs-lisp/comp.el (native-comp-async-report-warnings-errors) (comp-accept-and-process-async-output): Rename comp-async-report-warnings-errors → native-comp-async-report-warnings-errors. --- lisp/emacs-lisp/comp.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index 24b65424a18..908a71846ae 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -134,7 +134,7 @@ Used to modify the compiler environment." :risky t :version "28.1") -(defcustom comp-async-report-warnings-errors t +(defcustom native-comp-async-report-warnings-errors t "Whether to report warnings and errors from asynchronous native compilation. When native compilation happens asynchronously, it can produce @@ -3873,7 +3873,7 @@ processes from `comp-async-compilations'" (make-variable-buffer-local 'comp-last-scanned-async-output) (defun comp-accept-and-process-async-output (process) "Accept PROCESS output and check for diagnostic messages." - (if comp-async-report-warnings-errors + (if native-comp-async-report-warnings-errors (with-current-buffer (process-buffer process) (save-excursion (accept-process-output process) -- cgit v1.2.3 From 419852a599ceac1d80eb578a9a6df707fc6f6c8e Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Thu, 6 May 2021 14:55:30 +0200 Subject: * Rename comp-async-query-on-exit → native-comp-async-query-on-exit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * lisp/emacs-lisp/comp.el (native-comp-async-query-on-exit) (comp-run-async-workers): Rename comp-async-query-on-exit → native-comp-async-query-on-exit. --- lisp/emacs-lisp/comp.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index 908a71846ae..8a1f26be1fb 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -152,7 +152,7 @@ Set this variable to nil if these warnings annoy you." :type 'boolean :version "28.1") -(defcustom comp-async-query-on-exit nil +(defcustom native-comp-async-query-on-exit nil "Whether to query the user about killing async compilations when exiting. If this is non-nil, Emacs will ask for confirmation to exit and kill the asynchronous native compilations if any are running. If nil, when you @@ -3953,7 +3953,7 @@ display a message." (native-elisp-load eln-file (eq load1 'late)))) (comp-run-async-workers)) - :noquery (not comp-async-query-on-exit)))) + :noquery (not native-comp-async-query-on-exit)))) (puthash source-file process comp-async-compilations)) when (>= (comp-async-runnings) (comp-effective-async-max-jobs)) do (cl-return))) -- cgit v1.2.3 From 8c429a42c4ad8137dc932d5ba0f2f5c7bd8f7799 Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Thu, 6 May 2021 14:57:48 +0200 Subject: Rename comp-native-driver-options → native-comp-driver-options MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * src/comp.c (add_driver_options, syms_of_comp): Rename comp-native-driver-options → native-comp-driver-options. * lisp/emacs-lisp/comp.el (native-comp-driver-options) (comp-ctxt, comp-spill-lap-function, comp-final) (comp-run-async-workers): Likewise. * lisp/emacs-lisp/bytecomp.el (byte-compile-from-buffer): Likewise. --- lisp/emacs-lisp/bytecomp.el | 4 ++-- lisp/emacs-lisp/comp.el | 14 +++++++------- src/comp.c | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 16740e92d35..114c264fee3 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -2242,8 +2242,8 @@ With argument ARG, insert value in current buffer after the form." (push `(native-comp-speed . ,native-comp-speed) byte-native-qualities) (defvar native-comp-debug) (push `(native-comp-debug . ,native-comp-debug) byte-native-qualities) - (defvar comp-native-driver-options) - (push `(comp-native-driver-options . ,comp-native-driver-options) + (defvar native-comp-driver-options) + (push `(native-comp-driver-options . ,native-comp-driver-options) byte-native-qualities) (defvar no-native-compile) (push `(no-native-compile . ,no-native-compile) diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index 8a1f26be1fb..2b00faa069d 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -161,7 +161,7 @@ if `confirm-kill-processes' is non-nil." :type 'boolean :version "28.1") -(defcustom comp-native-driver-options nil +(defcustom native-comp-driver-options nil "Options passed verbatim to the native compiler's back-end driver. Note that not all options are meaningful; typically only the options affecting the assembler and linker are likely to be useful. @@ -747,7 +747,7 @@ Returns ELT." :documentation "Default speed for this compilation unit.") (debug native-comp-debug :type number :documentation "Default debug level for this compilation unit.") - (driver-options comp-native-driver-options :type list + (driver-options native-comp-driver-options :type list :documentation "Options for the GCC driver.") (top-level-forms () :type list :documentation "List of spilled top level forms.") @@ -1338,7 +1338,7 @@ clashes." byte-native-qualities) (comp-ctxt-debug comp-ctxt) (alist-get 'native-comp-debug byte-native-qualities) - (comp-ctxt-driver-options comp-ctxt) (alist-get 'comp-native-driver-options + (comp-ctxt-driver-options comp-ctxt) (alist-get 'native-comp-driver-options byte-native-qualities) (comp-ctxt-top-level-forms comp-ctxt) (cl-loop @@ -3654,8 +3654,8 @@ Prepare every function for final compilation and drive the C back-end." comp-libgccjit-reproducer ,comp-libgccjit-reproducer comp-ctxt ,comp-ctxt comp-eln-load-path ',comp-eln-load-path - comp-native-driver-options - ',comp-native-driver-options + native-comp-driver-options + ',native-comp-driver-options load-path ',load-path) ,native-comp-async-env-modifier-form (message "Compiling %s..." ',output) @@ -3911,8 +3911,8 @@ display a message." comp-libgccjit-reproducer ,comp-libgccjit-reproducer comp-async-compilation t comp-eln-load-path ',comp-eln-load-path - comp-native-driver-options - ',comp-native-driver-options + native-comp-driver-options + ',native-comp-driver-options load-path ',load-path warning-fill-column most-positive-fixnum) ,native-comp-async-env-modifier-form diff --git a/src/comp.c b/src/comp.c index 3608167cad1..9173dde2202 100644 --- a/src/comp.c +++ b/src/comp.c @@ -4358,7 +4358,7 @@ DEFUN ("comp-native-driver-options-effective-p", static void add_driver_options (void) { - Lisp_Object options = Fsymbol_value (Qcomp_native_driver_options); + Lisp_Object options = Fsymbol_value (Qnative_comp_driver_options); #if defined (LIBGCCJIT_HAVE_gcc_jit_context_add_driver_option) \ || defined (WINDOWSNT) @@ -5209,7 +5209,7 @@ compiled one. */); DEFSYM (Qnative_comp_speed, "native-comp-speed"); DEFSYM (Qnative_comp_debug, "native-comp-debug"); - DEFSYM (Qcomp_native_driver_options, "comp-native-driver-options"); + DEFSYM (Qnative_comp_driver_options, "native-comp-driver-options"); DEFSYM (Qcomp_libgccjit_reproducer, "comp-libgccjit-reproducer"); /* Limple instruction set. */ -- cgit v1.2.3 From 901ce566037b27233b907a51a9cbd330c77830ba Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Thu, 6 May 2021 15:00:00 +0200 Subject: Rename comp-warning-on-missing-source MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * src/lread.c (maybe_swap_for_eln): Rename comp-warning-on-missing-source → native-comp-warning-on-missing-source. * src/comp.c (syms_of_comp): Likewise. * lisp/emacs-lisp/comp.el (native-comp-warning-on-missing-source): Likewise. --- lisp/emacs-lisp/comp.el | 2 +- src/comp.c | 3 ++- src/lread.c | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index 2b00faa069d..434e0fb4165 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -178,7 +178,7 @@ the .eln output directory." :type 'boolean :version "28.1") -(defcustom comp-warning-on-missing-source t +(defcustom native-comp-warning-on-missing-source t "Emit a warning if a byte-code file being loaded has no corresponding source. The source file is necessary for native code file look-up and deferred compilation mechanism." diff --git a/src/comp.c b/src/comp.c index 9173dde2202..5cf94762a92 100644 --- a/src/comp.c +++ b/src/comp.c @@ -5272,7 +5272,8 @@ compiled one. */); DEFSYM (Qlambda_fixup, "lambda-fixup"); DEFSYM (Qgccjit, "gccjit"); DEFSYM (Qcomp_subr_trampoline_install, "comp-subr-trampoline-install"); - DEFSYM (Qcomp_warning_on_missing_source, "comp-warning-on-missing-source"); + DEFSYM (Qnative_comp_warning_on_missing_source, + "native-comp-warning-on-missing-source"); /* To be signaled by the compiler. */ DEFSYM (Qnative_compiler_error, "native-compiler-error"); diff --git a/src/lread.c b/src/lread.c index e53e1f65ab9..12e4ca66cdc 100644 --- a/src/lread.c +++ b/src/lread.c @@ -1708,7 +1708,8 @@ maybe_swap_for_eln (bool no_native, Lisp_Object *filename, int *fd, src_name = concat2 (src_name, build_string (".gz")); if (NILP (Ffile_exists_p (src_name))) { - if (!NILP (find_symbol_value (Qcomp_warning_on_missing_source))) + if (!NILP (find_symbol_value ( + Qnative_comp_warning_on_missing_source))) call2 (intern_c_string ("display-warning"), Qcomp, CALLN (Fformat, -- cgit v1.2.3 From fbbcbed10ee89e0865bbddc6683ff626ec488ee9 Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Thu, 6 May 2021 16:28:43 +0200 Subject: Rename comp-eln-load-path → native-comp-eln-load-path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * src/comp.c (Fcomp_el_to_eln_filename): Rename comp-eln-load-path → native-comp-eln-load-path. * src/lread.c (maybe_swap_for_eln): Likewise. * lisp/startup.el (native-comp-eln-load-path) (normal-top-level): Likewise. * lisp/emacs-lisp/comp.el (comp-spill-lap-function, comp-final) (comp-eln-load-path-eff, comp-trampoline-compile) (comp-clean-up-stale-eln, comp-run-async-workers) (comp-lookup-eln, batch-byte-native-compile-for-bootstrap): Likewise. --- lisp/emacs-lisp/comp.el | 20 ++++++++++---------- lisp/startup.el | 16 ++++++++-------- src/comp.c | 14 +++++++------- src/lread.c | 2 +- 4 files changed, 26 insertions(+), 26 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index 434e0fb4165..684b814292f 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -1333,7 +1333,7 @@ clashes." (setf (comp-ctxt-output comp-ctxt) (comp-el-to-eln-filename filename (when byte-native-for-bootstrap - (car (last comp-eln-load-path)))))) + (car (last native-comp-eln-load-path)))))) (setf (comp-ctxt-speed comp-ctxt) (alist-get 'native-comp-speed byte-native-qualities) (comp-ctxt-debug comp-ctxt) (alist-get 'native-comp-debug @@ -3653,7 +3653,7 @@ Prepare every function for final compilation and drive the C back-end." (setf native-comp-verbose ,native-comp-verbose comp-libgccjit-reproducer ,comp-libgccjit-reproducer comp-ctxt ,comp-ctxt - comp-eln-load-path ',comp-eln-load-path + native-comp-eln-load-path ',native-comp-eln-load-path native-comp-driver-options ',native-comp-driver-options load-path ',load-path) @@ -3703,12 +3703,12 @@ Prepare every function for final compilation and drive the C back-end." (defun comp-eln-load-path-eff () "Return a list of effective eln load directories. -Account for `comp-eln-load-path' and `comp-native-version-dir'." +Account for `native-comp-eln-load-path' and `comp-native-version-dir'." (mapcar (lambda (dir) (expand-file-name comp-native-version-dir (file-name-as-directory (expand-file-name dir invocation-directory)))) - comp-eln-load-path)) + native-comp-eln-load-path)) (defun comp-trampoline-filename (subr-name) "Given SUBR-NAME return the filename containing the trampoline." @@ -3772,14 +3772,14 @@ Return the trampoline if found or nil otherwise." when (file-writable-p f) do (cl-return f) finally (error "Cannot find suitable directory for output in \ -`comp-eln-load-path'"))))) +`native-comp-eln-load-path'"))))) ;; Some entry point support code. ;;;###autoload (defun comp-clean-up-stale-eln (file) - "Given FILE remove all its *.eln files in `comp-eln-load-path' + "Given FILE remove all its *.eln files in `native-comp-eln-load-path' sharing the original source filename (including FILE)." (when (string-match (rx "-" (group-n 1 (1+ hex)) "-" (1+ hex) ".eln" eos) file) @@ -3910,7 +3910,7 @@ display a message." native-comp-verbose ,native-comp-verbose comp-libgccjit-reproducer ,comp-libgccjit-reproducer comp-async-compilation t - comp-eln-load-path ',comp-eln-load-path + native-comp-eln-load-path ',native-comp-eln-load-path native-comp-driver-options ',native-comp-driver-options load-path ',load-path @@ -4123,10 +4123,10 @@ bytecode definition was not changed in the meantime)." ;;;###autoload (defun comp-lookup-eln (filename) "Given a Lisp source FILENAME return the corresponding .eln file if found. -Search happens in `comp-eln-load-path'." +Search happens in `native-comp-eln-load-path'." (cl-loop with eln-filename = (comp-el-to-eln-rel-filename filename) - for dir in comp-eln-load-path + for dir in native-comp-eln-load-path for f = (expand-file-name eln-filename (expand-file-name comp-native-version-dir (expand-file-name @@ -4169,7 +4169,7 @@ Native compilation equivalent to `batch-byte-compile'." "Like `batch-native-compile', but used for bootstrap. Generate .elc files in addition to the .eln files. Force the produced .eln to be outputted in the eln system -directory (the last entry in `comp-eln-load-path'). +directory (the last entry in `native-comp-eln-load-path'). If the environment variable 'NATIVE_DISABLED' is set, only byte compile." (comp-ensure-native-compiler) diff --git a/lisp/startup.el b/lisp/startup.el index 6bab9e364c2..bb25c1b7b0b 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -519,7 +519,7 @@ DIRS are relative." xdg-dir) (t emacs-d-dir)))) -(defvar comp-eln-load-path) +(defvar native-comp-eln-load-path) (defun normal-top-level () "Emacs calls this function when it first starts up. It sets `command-line-processed', processes the command-line, @@ -538,21 +538,21 @@ It is the default value of the variable `top-level'." (startup--xdg-or-homedot startup--xdg-config-home-emacs nil)) (when (featurep 'native-compile) - ;; Form `comp-eln-load-path'. + ;; Form `native-comp-eln-load-path'. (let ((path-env (getenv "EMACSNATIVELOADPATH"))) (when path-env (dolist (path (split-string path-env path-separator)) (unless (string= "" path) - (push path comp-eln-load-path))))) + (push path native-comp-eln-load-path))))) (push (expand-file-name "eln-cache/" user-emacs-directory) - comp-eln-load-path) + native-comp-eln-load-path) ;; When $HOME is set to '/nonexistent' means we are running the ;; testsuite, add a temporary folder in front to produce there ;; new compilations. (when (equal (getenv "HOME") "/nonexistent") (let ((tmp-dir (make-temp-file "emacs-testsuite-" t))) (add-hook 'kill-emacs-hook (lambda () (delete-directory tmp-dir t))) - (push tmp-dir comp-eln-load-path)))) + (push tmp-dir native-comp-eln-load-path)))) ;; Look in each dir in load-path for a subdirs.el file. If we ;; find one, load it, which will add the appropriate subdirs of ;; that dir into load-path. This needs to be done before setting @@ -640,12 +640,12 @@ It is the default value of the variable `top-level'." (decode-coding-string dir coding t)) path))))) (when (featurep 'native-compile) - (let ((npath (symbol-value 'comp-eln-load-path))) - (set 'comp-eln-load-path + (let ((npath (symbol-value 'native-comp-eln-load-path))) + (set 'native-comp-eln-load-path (mapcar (lambda (dir) ;; Call expand-file-name to remove all the ;; pesky ".." from the directyory names in - ;; comp-eln-load-path. + ;; native-comp-eln-load-path. (expand-file-name (decode-coding-string dir coding t))) npath)))) diff --git a/src/comp.c b/src/comp.c index 5cf94762a92..5128755bf18 100644 --- a/src/comp.c +++ b/src/comp.c @@ -4095,11 +4095,11 @@ directory in `comp-eln-load-path' otherwise. */) Lisp_Object source_filename = filename; filename = Fcomp_el_to_eln_rel_filename (filename); - /* If base_dir was not specified search inside Vcomp_eln_load_path + /* If base_dir was not specified search inside Vnative_comp_eln_load_path for the first directory where we have write access. */ if (NILP (base_dir)) { - Lisp_Object eln_load_paths = Vcomp_eln_load_path; + Lisp_Object eln_load_paths = Vnative_comp_eln_load_path; FOR_EACH_TAIL (eln_load_paths) { Lisp_Object dir = XCAR (eln_load_paths); @@ -4630,7 +4630,7 @@ void eln_load_path_final_clean_up (void) { #ifdef WINDOWSNT - Lisp_Object dir_tail = Vcomp_eln_load_path; + Lisp_Object dir_tail = Vnative_comp_eln_load_path; FOR_EACH_TAIL (dir_tail) { Lisp_Object files_in_dir = @@ -4755,7 +4755,7 @@ void fixup_eln_load_path (Lisp_Object eln_filename) { Lisp_Object last_cell = Qnil; - Lisp_Object tem = Vcomp_eln_load_path; + Lisp_Object tem = Vnative_comp_eln_load_path; FOR_EACH_TAIL (tem) if (CONSP (tem)) last_cell = tem; @@ -5127,7 +5127,7 @@ static bool file_in_eln_sys_dir (Lisp_Object filename) { Lisp_Object eln_sys_dir = Qnil; - Lisp_Object tmp = Vcomp_eln_load_path; + Lisp_Object tmp = Vnative_comp_eln_load_path; FOR_EACH_TAIL (tmp) eln_sys_dir = XCAR (tmp); return !NILP (Fstring_match (Fregexp_quote (Fexpand_file_name (eln_sys_dir, @@ -5369,7 +5369,7 @@ For internal use. */); doc: /* Hash table eln-filename -> el-filename. */); Vcomp_eln_to_el_h = CALLN (Fmake_hash_table, QCtest, Qequal); - DEFVAR_LISP ("comp-eln-load-path", Vcomp_eln_load_path, + DEFVAR_LISP ("native-comp-eln-load-path", Vnative_comp_eln_load_path, doc: /* List of eln cache directories. If a directory is non absolute is assumed to be relative to @@ -5381,7 +5381,7 @@ The last directory of this list is assumed to be the system one. */); /* Temporary value in use for bootstrap. We can't do better as `invocation-directory' is still unset, will be fixed up during dump reload. */ - Vcomp_eln_load_path = Fcons (build_string ("../native-lisp/"), Qnil); + Vnative_comp_eln_load_path = Fcons (build_string ("../native-lisp/"), Qnil); DEFVAR_BOOL ("comp-enable-subr-trampolines", comp_enable_subr_trampolines, doc: /* If non-nil enable primitive trampoline synthesis. diff --git a/src/lread.c b/src/lread.c index 12e4ca66cdc..d2e6323cb14 100644 --- a/src/lread.c +++ b/src/lread.c @@ -1700,7 +1700,7 @@ maybe_swap_for_eln (bool no_native, Lisp_Object *filename, int *fd, return; /* Search eln in the eln-cache directories. */ - Lisp_Object eln_path_tail = Vcomp_eln_load_path; + Lisp_Object eln_path_tail = Vnative_comp_eln_load_path; Lisp_Object src_name = Fsubstring (*filename, Qnil, make_fixnum (-1)); if (NILP (Ffile_exists_p (src_name))) -- cgit v1.2.3 From 615cf550f22f78d123acb1e8e90be6c69699dbee Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Fri, 7 May 2021 17:09:44 +0300 Subject: Fix a recent change in rmc.el * lisp/emacs-lisp/rmc.el (read-multiple-choice): Doc fix. Improve the message when entering recursive-edit. --- lisp/emacs-lisp/rmc.el | 57 +++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 28 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/rmc.el b/lisp/emacs-lisp/rmc.el index 6aa169c0323..8abe570e64b 100644 --- a/lisp/emacs-lisp/rmc.el +++ b/lisp/emacs-lisp/rmc.el @@ -27,36 +27,37 @@ ;;;###autoload (defun read-multiple-choice (prompt choices &optional help-string) - "Ask user a multiple choice question. -PROMPT should be a string that will be displayed as the prompt. - -CHOICES is a list of (KEY NAME [DESCRIPTION]). KEY is a -character to be entered. NAME is a short name for the entry to -be displayed while prompting (if there's room, it might be -shortened). DESCRIPTION is an optional longer explanation for -the entry that will be displayed in a help buffer if the user -requests more help. This help description has a fixed format in -columns, but, for greater flexibility, instead of passing a -DESCRIPTION, the user can use the optional argument HELP-STRING. -This argument is a string that contains the text with the -complete description of all choices. `read-multiple-choice' will -display that description in a help buffer if the user requests -it. + "Ask user to select an entry from CHOICES, promting with PROMPT. +This function allows to ask the user a multiple-choice question. + +CHOICES should be a list of the form (KEY NAME [DESCRIPTION]). +KEY is a character the user should type to select the entry. +NAME is a short name for the entry to be displayed while prompting +\(if there's no room, it might be shortened). +DESCRIPTION is an optional longer description of the entry; it will +be displayed in a help buffer if the user requests more help. This +help description has a fixed format in columns. For greater +flexibility, instead of passing a DESCRIPTION, the caller can pass +the optional argument HELP-STRING. This argument is a string that +should contain a more detailed description of all of the possible +choices. `read-multiple-choice' will display that description in a +help buffer if the user requests that. This function translates user input into responses by consulting the bindings in `query-replace-map'; see the documentation of -that variable for more information. In this case, the useful -bindings are `recenter', `scroll-up', `scroll-down', and `edit'. -If the user enters `recenter', `scroll-up', or `scroll-down' -responses, perform the requested window recentering or scrolling -and ask again. If the user enters `edit', start a recursive -edit. When the user exit the recursive edit, the multiple choice -prompt gains focus again. - -When `use-dialog-box' is t (the default), this function can pop -up a dialog window to collect the user input. That functionality -requires `display-popup-menus-p' to return t. Otherwise, a -text dialog will be used. +that variable for more information. The relevant bindings for the +purposes of this function are `recenter', `scroll-up', `scroll-down', +and `edit'. +If the user types the `recenter', `scroll-up', or `scroll-down' +responses, the function performs the requested window recentering or +scrolling, and then asks the question again. If the user enters `edit', +the function starts a recursive edit. When the user exit the recursive +edit, the multiple-choice prompt gains focus again. + +When `use-dialog-box' is t (the default), and the command using this +function was invoked via the mouse, this function pops up a GUI dialog +to collect the user input, but only if Emacs is capable of using GUI +dialogs. Otherwise, the function will always use text-mode dialogs. The return value is the matching entry from the CHOICES list. @@ -146,7 +147,7 @@ Usage example: (save-excursion (message "%s" (substitute-command-keys - "Recursive edit. Resume with \\[exit-recursive-edit]")) + "Recursive edit; type \\[exit-recursive-edit] to return to help screen")) (recursive-edit)))) (t tchar))) (when (eq tchar t) -- cgit v1.2.3 From fdeb1a3dc77ccac28e6cf91b9cc4aa43f3060e7a Mon Sep 17 00:00:00 2001 From: dalanicolai Date: Sat, 8 May 2021 13:59:03 +0200 Subject: Mention that Emacs is usually case-insensitive in a couple of places * doc/lispref/searching.texi (Regular Expressions): Mention `case-fold-search'. * lisp/emacs-lisp/re-builder.el (re-builder): Mention case sensitivity toggles (bug#47534). Copyright-paperwork-exempt: yes --- doc/lispref/searching.texi | 5 +++++ lisp/emacs-lisp/re-builder.el | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'lisp/emacs-lisp') diff --git a/doc/lispref/searching.texi b/doc/lispref/searching.texi index 16a8e56e90a..99451d0bc66 100644 --- a/doc/lispref/searching.texi +++ b/doc/lispref/searching.texi @@ -251,6 +251,11 @@ matches in the target buffer are highlighted. Each parenthesized sub-expression of the regexp is shown in a distinct face, which makes it easier to verify even very complex regexps. + Note that by default Emacs search ignores case (@xref{Searching and +Case}). To enable case-sensitive regexp search and match, bind +@code{case-fold-search} to @code{nil} around the code you want to be +case-sensitive. + @menu * Syntax of Regexps:: Rules for writing regular expressions. * Regexp Example:: Illustrates regular expression syntax. diff --git a/lisp/emacs-lisp/re-builder.el b/lisp/emacs-lisp/re-builder.el index 455fcac701f..b695dff55a4 100644 --- a/lisp/emacs-lisp/re-builder.el +++ b/lisp/emacs-lisp/re-builder.el @@ -341,7 +341,12 @@ the regexp builder. It displays a buffer named \"*RE-Builder*\" in another window, initially containing an empty regexp. As you edit the regexp in the \"*RE-Builder*\" buffer, the -matching parts of the target buffer will be highlighted." +matching parts of the target buffer will be highlighted. + +Case-sensitivity can be toggled with \\[reb-toggle-case]. The +regexp builder supports three different forms of input which can +be set with \\[reb-change-syntax]. More options and details are +provided in the initial comment of`re-builder.el'." (interactive) (if (and (string= (buffer-name) reb-buffer) (reb-mode-buffer-p)) -- cgit v1.2.3 From d3344e0a7fc9435910a600d831ebdb8b2953b2a5 Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" Date: Sat, 8 May 2021 15:07:38 +0100 Subject: ; Fix recent re-builder doc changes. --- doc/lispref/searching.texi | 2 +- lisp/emacs-lisp/re-builder.el | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/doc/lispref/searching.texi b/doc/lispref/searching.texi index 99451d0bc66..b38ee995abe 100644 --- a/doc/lispref/searching.texi +++ b/doc/lispref/searching.texi @@ -251,7 +251,7 @@ matches in the target buffer are highlighted. Each parenthesized sub-expression of the regexp is shown in a distinct face, which makes it easier to verify even very complex regexps. - Note that by default Emacs search ignores case (@xref{Searching and + Note that by default Emacs search ignores case (@pxref{Searching and Case}). To enable case-sensitive regexp search and match, bind @code{case-fold-search} to @code{nil} around the code you want to be case-sensitive. diff --git a/lisp/emacs-lisp/re-builder.el b/lisp/emacs-lisp/re-builder.el index b695dff55a4..7d042a9102e 100644 --- a/lisp/emacs-lisp/re-builder.el +++ b/lisp/emacs-lisp/re-builder.el @@ -346,7 +346,7 @@ matching parts of the target buffer will be highlighted. Case-sensitivity can be toggled with \\[reb-toggle-case]. The regexp builder supports three different forms of input which can be set with \\[reb-change-syntax]. More options and details are -provided in the initial comment of`re-builder.el'." +provided in the Commentary section of this library." (interactive) (if (and (string= (buffer-name) reb-buffer) (reb-mode-buffer-p)) -- cgit v1.2.3 From af529f777c965fc347ec0d9144f5b9babce66d08 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Sun, 9 May 2021 11:47:01 +0200 Subject: Reintroduce autoloads for edebug-all-defs/edebug-all-forms * lisp/emacs-lisp/edebug.el (edebug-all-defs, edebug-all-forms): Reintroduce ;;;###autoload of these user options that were removed in bae2cfe63c, because this leads to errors in a common (and recommended) use case (bug#47516). --- lisp/emacs-lisp/edebug.el | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el index b08ee3c4a17..2aec8197dc9 100644 --- a/lisp/emacs-lisp/edebug.el +++ b/lisp/emacs-lisp/edebug.el @@ -88,6 +88,7 @@ using, but only when you also use Edebug." ;; because the byte compiler binds them; as a result, if edebug ;; is first loaded for a require in a compilation, they will be left unbound. +;;;###autoload (defcustom edebug-all-defs nil "If non-nil, evaluating defining forms instruments for Edebug. This applies to `eval-defun', `eval-region', `eval-buffer', and @@ -100,6 +101,7 @@ variable. You may wish to make it local to each buffer with `emacs-lisp-mode-hook'." :type 'boolean) +;;;###autoload (defcustom edebug-all-forms nil "Non-nil means evaluation of all forms will instrument for Edebug. This doesn't apply to loading or evaluations in the minibuffer. -- cgit v1.2.3 From 6d225d82c8b472ff23525e9047d8a2dc8c363a43 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Tue, 11 May 2021 14:30:00 +0200 Subject: `text-property-search-forward' doc string improvement * lisp/emacs-lisp/text-property-search.el (text-property-search-forward): Correct and clarify the doc string (bug#48317). --- lisp/emacs-lisp/text-property-search.el | 35 +++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 13 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/text-property-search.el b/lisp/emacs-lisp/text-property-search.el index 69943a83f1c..49e196d3bfc 100644 --- a/lisp/emacs-lisp/text-property-search.el +++ b/lisp/emacs-lisp/text-property-search.el @@ -32,27 +32,36 @@ (defun text-property-search-forward (property &optional value predicate not-current) "Search for the next region of text whose PROPERTY matches VALUE. - -If not found, return nil and don't move point. -If found, move point to the start of the region and return a -`prop-match' object describing the match. To access the details -of the match, use `prop-match-beginning' and `prop-match-end' for -the buffer positions that limit the region, and -`prop-match-value' for the value of PROPERTY in the region. - PREDICATE is used to decide whether a value of PROPERTY should be considered as matching VALUE. -If PREDICATE is t, that means a value must `equal' VALUE to be -considered a match. -If PREDICATE is nil, a value will match if it is non-nil and -is NOT `equal' to VALUE. + If PREDICATE is a function, it will be called with two arguments: VALUE and the value of PROPERTY. The function should return non-nil if these two values are to be considered a match. +Two special values of PREDICATE can also be used: +If PREDICATE is t, that means a value must `equal' VALUE to be +considered a match. +If PREDICATE is nil, a value will match if is not `equal' to +VALUE. Furthermore, the match region is ended if the value +changes. For instance, this means that if you loop with + + (while (text-property-search-forward 'face) + ...) + +you will get all distinct regions with different `face' values in +the buffer. + If NOT-CURRENT is non-nil, the function will search for the first region that doesn't include point and has a value of PROPERTY -that matches VALUE." +that matches VALUE. + +If no matches can be found, return nil and don't move point. +If found, move point to the start of the region and return a +`prop-match' object describing the match. To access the details +of the match, use `prop-match-beginning' and `prop-match-end' for +the buffer positions that limit the region, and +`prop-match-value' for the value of PROPERTY in the region." (interactive (list (let ((string (completing-read "Search for property: " obarray))) -- cgit v1.2.3 From 8bc91a6a3f6cc84f549d24467832f67b3130201d Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Tue, 11 May 2021 18:07:19 +0200 Subject: * Rename comp-deferred-compilation-deny-list * lisp/emacs-lisp/comp.el (native-comp-deferred-compilation-deny-list) (native-compile-async-skip-p): Rename comp-deferred-compilation-deny-list -> native-comp-deferred-compilation-deny-list. --- lisp/emacs-lisp/comp.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index 684b814292f..3e7f17ef1cc 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -83,7 +83,7 @@ This is intended for debugging the compiler itself. :type 'boolean :version "28.1") -(defcustom comp-deferred-compilation-deny-list +(defcustom native-comp-deferred-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." @@ -4044,11 +4044,11 @@ LOAD and SELECTOR work as described in `native--compile-async'." (t (error "SELECTOR must be a function a regexp or nil"))) ;; Also exclude files from deferred compilation if ;; any of the regexps in - ;; `comp-deferred-compilation-deny-list' matches. + ;; `native-comp-deferred-compilation-deny-list' matches. (and (eq load 'late) (cl-some (lambda (re) (string-match-p re file)) - comp-deferred-compilation-deny-list)))) + native-comp-deferred-compilation-deny-list)))) (defun native--compile-async (files &optional recursively load selector) "Compile FILES asynchronously. -- cgit v1.2.3 From 98e5639c3c3caf2424f35e4a9f9c53ff48f43897 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Wed, 12 May 2021 16:41:03 +0300 Subject: Fix the tests for 'string-limit' * test/lisp/emacs-lisp/subr-x-tests.el (subr-string-limit-coding): Fix the expected results of string-limit when encoding with UTF-16. Add tests for UTF-8 with BOM. (Bug#48324) * lisp/emacs-lisp/subr-x.el (string-limit): Add FIXME comment about the current implementation, which is faulty by design. --- lisp/emacs-lisp/subr-x.el | 12 ++++++++++++ test/lisp/emacs-lisp/subr-x-tests.el | 7 +++++-- 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/subr-x.el b/lisp/emacs-lisp/subr-x.el index 9c8c967ee9c..5a8885c0427 100644 --- a/lisp/emacs-lisp/subr-x.el +++ b/lisp/emacs-lisp/subr-x.el @@ -289,6 +289,18 @@ than this function." (let ((result nil) (result-length 0) (index (if end (1- (length string)) 0))) + ;; FIXME: This implementation, which uses encode-coding-char + ;; to encode the string one character at a time, is in general + ;; incorrect: coding-systems that produce prefix or suffix + ;; bytes, such as ISO-2022-based or UTF-8/16 with BOM, will + ;; produce those bytes for each character, instead of just + ;; once for the entire string. encode-coding-char attempts to + ;; remove those extra bytes at least in some situations, but + ;; it cannot do that in all cases. And in any case, producing + ;; what is supposed to be a UTF-16 or ISO-2022-CN encoded + ;; string which lacks the BOM bytes at the beginning and the + ;; charset designation sequences at the head and tail of the + ;; result will definitely surprise the callers in some cases. (while (let ((encoded (encode-coding-char (aref string index) coding-system))) (and (<= (+ (length encoded) result-length) length) diff --git a/test/lisp/emacs-lisp/subr-x-tests.el b/test/lisp/emacs-lisp/subr-x-tests.el index 112f3c1dac1..ef04cde3867 100644 --- a/test/lisp/emacs-lisp/subr-x-tests.el +++ b/test/lisp/emacs-lisp/subr-x-tests.el @@ -607,18 +607,21 @@ (should (equal (string-limit "foó" 4 nil 'utf-8) "fo\303\263")) (should (equal (string-limit "foóa" 4 nil 'utf-8) "fo\303\263")) (should (equal (string-limit "foóá" 4 nil 'utf-8) "fo\303\263")) + (should (equal (string-limit "foóá" 4 nil 'utf-8-with-signature) + "fo\303\263")) (should (equal (string-limit "foóa" 4 nil 'iso-8859-1) "fo\363a")) (should (equal (string-limit "foóá" 4 nil 'iso-8859-1) "fo\363\341")) - (should (equal (string-limit "foóá" 4 nil 'utf-16) "\376\377\000f")) + (should (equal (string-limit "foóá" 4 nil 'utf-16) "\000f\000o")) (should (equal (string-limit "foó" 10 t 'utf-8) "fo\303\263")) (should (equal (string-limit "foó" 3 t 'utf-8) "o\303\263")) (should (equal (string-limit "foó" 4 t 'utf-8) "fo\303\263")) (should (equal (string-limit "foóa" 4 t 'utf-8) "o\303\263a")) (should (equal (string-limit "foóá" 4 t 'utf-8) "\303\263\303\241")) + (should (equal (string-limit "foóá" 2 t 'utf-8-with-signature) "\303\241")) (should (equal (string-limit "foóa" 4 t 'iso-8859-1) "fo\363a")) (should (equal (string-limit "foóá" 4 t 'iso-8859-1) "fo\363\341")) - (should (equal (string-limit "foóá" 4 t 'utf-16) "\376\377\000\341"))) + (should (equal (string-limit "foóá" 4 t 'utf-16) "\000\363\000\341"))) (ert-deftest subr-string-lines () (should (equal (string-lines "foo") '("foo"))) -- cgit v1.2.3 From bc1a01172e2725503628914f019192c0e59260a3 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Wed, 12 May 2021 16:17:50 +0200 Subject: Further corrections for the text-property-search doc strings * lisp/emacs-lisp/text-property-search.el (text-property-search-forward): Correct doc string. (text-property-search-backward): Ditto. --- lisp/emacs-lisp/text-property-search.el | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/text-property-search.el b/lisp/emacs-lisp/text-property-search.el index 49e196d3bfc..1f2dcfe9dd0 100644 --- a/lisp/emacs-lisp/text-property-search.el +++ b/lisp/emacs-lisp/text-property-search.el @@ -46,18 +46,19 @@ If PREDICATE is nil, a value will match if is not `equal' to VALUE. Furthermore, the match region is ended if the value changes. For instance, this means that if you loop with - (while (text-property-search-forward 'face) + (while (setq prop (text-property-search-forward 'face)) ...) you will get all distinct regions with different `face' values in -the buffer. +the buffer, and the `prop' object will have the details about the +match. If NOT-CURRENT is non-nil, the function will search for the first region that doesn't include point and has a value of PROPERTY that matches VALUE. If no matches can be found, return nil and don't move point. -If found, move point to the start of the region and return a +If found, move point to the end of the region and return a `prop-match' object describing the match. To access the details of the match, use `prop-match-beginning' and `prop-match-end' for the buffer positions that limit the region, and @@ -134,7 +135,7 @@ the buffer positions that limit the region, and "Search for the previous region of text whose PROPERTY matches VALUE. Like `text-property-search-forward', which see, but searches backward, -and if a matching region is found, place point at its end." +and if a matching region is found, place point at the start of the region." (interactive (list (let ((string (completing-read "Search for property: " obarray))) -- cgit v1.2.3 From 43da7f838f7132340fe241298193ac4f6ae2fe09 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Wed, 12 May 2021 19:01:53 +0200 Subject: Even further `text-property-search-forward' clarifications * lisp/emacs-lisp/text-property-search.el (text-property-search-forward): Further doc string clarifications. --- lisp/emacs-lisp/text-property-search.el | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/text-property-search.el b/lisp/emacs-lisp/text-property-search.el index 1f2dcfe9dd0..7da02a9cb2d 100644 --- a/lisp/emacs-lisp/text-property-search.el +++ b/lisp/emacs-lisp/text-property-search.el @@ -31,7 +31,7 @@ (defun text-property-search-forward (property &optional value predicate not-current) - "Search for the next region of text whose PROPERTY matches VALUE. + "Search for the next region of text where PREDICATE is true. PREDICATE is used to decide whether a value of PROPERTY should be considered as matching VALUE. @@ -42,16 +42,18 @@ non-nil if these two values are to be considered a match. Two special values of PREDICATE can also be used: If PREDICATE is t, that means a value must `equal' VALUE to be considered a match. -If PREDICATE is nil, a value will match if is not `equal' to -VALUE. Furthermore, the match region is ended if the value -changes. For instance, this means that if you loop with +If PREDICATE is nil (which is the default value), a value will +match if is not `equal' to VALUE. Furthermore, a nil PREDICATE +means that the match region is ended if the value changes. For +instance, this means that if you loop with (while (setq prop (text-property-search-forward 'face)) ...) -you will get all distinct regions with different `face' values in +you will get all distinct regions with non-nil `face' values in the buffer, and the `prop' object will have the details about the -match. +match. See the manual for more details and examples about how +VALUE and PREDICATE interact. If NOT-CURRENT is non-nil, the function will search for the first region that doesn't include point and has a value of PROPERTY -- cgit v1.2.3 From 01bd4d1a824816fba34571623a65c9c1541c27e5 Mon Sep 17 00:00:00 2001 From: Philipp Stephani Date: Thu, 6 May 2021 19:13:00 +0200 Subject: Optimize calls to 'eql', 'memql' and similar for fixnums. It's good practice to compare integers using 'eql' because two bignum objects representing the same integer might not be 'eq'. However, 'eql' is slower and doesn't have its own byte code. Therefore, replace it with 'eq' if one argument is guaranteed to be a fixnum on all platforms. * lisp/emacs-lisp/byte-opt.el (byte-optimize--fixnump): New helper function. (byte-optimize-equal, byte-optimize-member, byte-optimize-assoc): Use it to optimize 'eql' etc. to 'eq' if it will always compare fixnums. --- lisp/emacs-lisp/byte-opt.el | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el index 33b4d4b3c87..28b53d05890 100644 --- a/lisp/emacs-lisp/byte-opt.el +++ b/lisp/emacs-lisp/byte-opt.el @@ -951,12 +951,20 @@ Same format as `byte-optimize--lexvars', with shared structure and contents.") "Whether EXPR is a constant symbol." (and (macroexp-const-p expr) (symbolp (eval expr)))) +(defun byte-optimize--fixnump (o) + "Return whether O is guaranteed to be a fixnum in all Emacsen. +See Info node `(elisp) Integer Basics'." + (and (fixnump o) (<= -536870912 o 536870911))) + (defun byte-optimize-equal (form) - ;; Replace `equal' or `eql' with `eq' if at least one arg is a symbol. + ;; Replace `equal' or `eql' with `eq' if at least one arg is a + ;; symbol or fixnum. (byte-optimize-binary-predicate (if (= (length (cdr form)) 2) (if (or (byte-optimize--constant-symbol-p (nth 1 form)) - (byte-optimize--constant-symbol-p (nth 2 form))) + (byte-optimize--constant-symbol-p (nth 2 form)) + (byte-optimize--fixnump (nth 1 form)) + (byte-optimize--fixnump (nth 2 form))) (cons 'eq (cdr form)) form) ;; Arity errors reported elsewhere. @@ -964,14 +972,19 @@ Same format as `byte-optimize--lexvars', with shared structure and contents.") (defun byte-optimize-member (form) ;; Replace `member' or `memql' with `memq' if the first arg is a symbol, - ;; or the second arg is a list of symbols. + ;; or the second arg is a list of symbols. Same with fixnums. (if (= (length (cdr form)) 2) (if (or (byte-optimize--constant-symbol-p (nth 1 form)) + (byte-optimize--fixnump (nth 1 form)) (let ((arg2 (nth 2 form))) (and (macroexp-const-p arg2) (let ((listval (eval arg2))) (and (listp listval) - (not (memq nil (mapcar #'symbolp listval)))))))) + (not (memq nil (mapcar + (lambda (o) + (or (symbolp o) + (byte-optimize--fixnump o))) + listval)))))))) (cons 'memq (cdr form)) form) ;; Arity errors reported elsewhere. @@ -979,11 +992,12 @@ Same format as `byte-optimize--lexvars', with shared structure and contents.") (defun byte-optimize-assoc (form) ;; Replace 2-argument `assoc' with `assq', `rassoc' with `rassq', - ;; if the first arg is a symbol. + ;; if the first arg is a symbol or fixnum. (cond ((/= (length form) 3) form) - ((byte-optimize--constant-symbol-p (nth 1 form)) + ((or (byte-optimize--constant-symbol-p (nth 1 form)) + (byte-optimize--fixnump (nth 1 form))) (cons (if (eq (car form) 'assoc) 'assq 'rassq) (cdr form))) (t (byte-optimize-constant-args form)))) -- cgit v1.2.3 From e761e12498ff108c3b82e9d27843baec6670447c Mon Sep 17 00:00:00 2001 From: Eric Abrahamsen Date: Sat, 15 May 2021 09:36:05 -0700 Subject: Add a 'silent option for native-comp-async-report-warnings-errors * lisp/emacs-lisp/comp.el (native-comp-async-report-warnings-errors): Set to 'silent to log warnings, but not pop up the *Warnings* buffer. * lisp/emacs-lisp/comp.el (comp-accept-and-process-async-output): Check value. --- lisp/emacs-lisp/comp.el | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index 3e7f17ef1cc..8c638312b05 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -148,8 +148,13 @@ As asynchronous native compilation always starts from a pristine environment, it is more sensitive to such omissions, and might be unable to compile such Lisp source files correctly. -Set this variable to nil if these warnings annoy you." - :type 'boolean +Set this variable to nil to suppress warnings altogether, or to +the symbol `silent' to log warnings but not pop up the *Warnings* +buffer." + :type '(choice + (const :tag "Do not report warnings" nil) + (const :tag "Report and display warnings" t) + (const :tag "Report but do not display warnings" 'silent)) :version "28.1") (defcustom native-comp-async-query-on-exit nil @@ -3874,14 +3879,18 @@ processes from `comp-async-compilations'" (defun comp-accept-and-process-async-output (process) "Accept PROCESS output and check for diagnostic messages." (if native-comp-async-report-warnings-errors - (with-current-buffer (process-buffer process) - (save-excursion - (accept-process-output process) - (goto-char (or comp-last-scanned-async-output (point-min))) - (while (re-search-forward "^.*?\\(?:Error\\|Warning\\): .*$" - nil t) - (display-warning 'comp (match-string 0))) - (setq comp-last-scanned-async-output (point-max)))) + (let ((warning-suppress-types + (if (eq native-comp-async-report-warnings-errors 'silent) + (cons '(comp) warning-suppress-types) + warning-suppress-types))) + (with-current-buffer (process-buffer process) + (save-excursion + (accept-process-output process) + (goto-char (or comp-last-scanned-async-output (point-min))) + (while (re-search-forward "^.*?\\(?:Error\\|Warning\\): .*$" + nil t) + (display-warning 'comp (match-string 0))) + (setq comp-last-scanned-async-output (point-max))))) (accept-process-output process))) (defun comp-run-async-workers () -- cgit v1.2.3 From 42950e9e4647c28f56c72cc27ef96edbafcbe5cd Mon Sep 17 00:00:00 2001 From: Philipp Stephani Date: Mon, 17 May 2021 10:00:36 +0200 Subject: Fix a few Edebug specifications where code is wrapped in lambdas. As the Info node `(elisp) Specification List' explains, it is not correct to use `body' or t for a piece of code that the macro wraps in a `lambda' form. These should use `def-body' instead. * lisp/info-xref.el (info-xref-with-file): * lisp/subr.el (subr--with-wrapper-hook-no-warnings, track-mouse) (combine-change-calls, with-eval-after-load): * lisp/emacs-lisp/bytecomp.el (displaying-byte-compile-warnings): * lisp/emacs-lisp/cl-macs.el (cl-do-symbols, cl-progv): * lisp/emacs-lisp/ert-x.el (ert-with-test-buffer): * lisp/emacs-lisp/gv.el (gv-letplace): * lisp/emacs-lisp/nadvice.el (define-advice): * lisp/emacs-lisp/thunk.el (thunk-delay): * lisp/vc/vc-dispatcher.el (vc-run-delayed): Use 'def-body' instead of t or 'body' where applicable. * lisp/emacs-lisp/package.el (package--with-response-buffer): Remove evaluation of the body altogether. I have no idea how to write it correctly in this case. --- lisp/emacs-lisp/bytecomp.el | 2 +- lisp/emacs-lisp/cl-macs.el | 5 +++-- lisp/emacs-lisp/ert-x.el | 2 +- lisp/emacs-lisp/gv.el | 2 +- lisp/emacs-lisp/nadvice.el | 2 +- lisp/emacs-lisp/package.el | 5 ++++- lisp/emacs-lisp/thunk.el | 2 +- lisp/info-xref.el | 2 +- lisp/subr.el | 8 ++++---- lisp/vc/vc-dispatcher.el | 2 +- 10 files changed, 18 insertions(+), 14 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 114c264fee3..86c5d32c726 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -1758,7 +1758,7 @@ It is too wide if it has any lines longer than the largest of overriding-plist-environment))))) (defmacro displaying-byte-compile-warnings (&rest body) - (declare (debug t)) + (declare (debug (def-body))) `(let* ((--displaying-byte-compile-warnings-fn (lambda () ,@body)) (warning-series-started (and (markerp warning-series) diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el index d7e6c307ed3..283c5e4a74e 100644 --- a/lisp/emacs-lisp/cl-macs.el +++ b/lisp/emacs-lisp/cl-macs.el @@ -1924,7 +1924,8 @@ from OBARRAY. \(fn (VAR [OBARRAY [RESULT]]) BODY...)" (declare (indent 1) - (debug ((symbolp &optional form form) cl-declarations body))) + (debug ((symbolp &optional form form) cl-declarations + def-body))) ;; Apparently this doesn't have an implicit block. `(cl-block nil (let (,(car spec)) @@ -1964,7 +1965,7 @@ Each symbol in the first list is bound to the corresponding value in the second list (or to nil if VALUES is shorter than SYMBOLS); then the BODY forms are executed and their result is returned. This is much like a `let' form, except that the list of symbols can be computed at run-time." - (declare (indent 2) (debug (form form body))) + (declare (indent 2) (debug (form form def-body))) (let ((bodyfun (make-symbol "body")) (binds (make-symbol "binds")) (syms (make-symbol "syms")) diff --git a/lisp/emacs-lisp/ert-x.el b/lisp/emacs-lisp/ert-x.el index 1191fb8f8de..59ec4d24849 100644 --- a/lisp/emacs-lisp/ert-x.el +++ b/lisp/emacs-lisp/ert-x.el @@ -98,7 +98,7 @@ To be used in ERT tests. If BODY finishes successfully, the test buffer is killed; if there is an error, the test buffer is kept around on error for further inspection. Its name is derived from the name of the test and the result of NAME-FORM." - (declare (debug ((":name" form) body)) + (declare (debug ((":name" form) def-body)) (indent 1)) `(ert--call-with-test-buffer ,name-form (lambda () ,@body))) diff --git a/lisp/emacs-lisp/gv.el b/lisp/emacs-lisp/gv.el index ce48e578e0b..f08f7ac1153 100644 --- a/lisp/emacs-lisp/gv.el +++ b/lisp/emacs-lisp/gv.el @@ -135,7 +135,7 @@ The returned value will then be an Elisp expression that first evaluates all the parts of PLACE that can be evaluated and then runs E. \(fn (GETTER SETTER) PLACE &rest BODY)" - (declare (indent 2) (debug (sexp form body))) + (declare (indent 2) (debug (sexp form def-body))) `(gv-get ,place (lambda ,vars ,@body))) ;; Different ways to declare a generalized variable. diff --git a/lisp/emacs-lisp/nadvice.el b/lisp/emacs-lisp/nadvice.el index bf3e9446399..4804e859ebe 100644 --- a/lisp/emacs-lisp/nadvice.el +++ b/lisp/emacs-lisp/nadvice.el @@ -503,7 +503,7 @@ arguments. Note if NAME is nil the advice is anonymous; otherwise it is named `SYMBOL@NAME'. \(fn SYMBOL (WHERE LAMBDA-LIST &optional NAME DEPTH) &rest BODY)" - (declare (indent 2) (doc-string 3) (debug (sexp sexp body))) + (declare (indent 2) (doc-string 3) (debug (sexp sexp def-body))) (or (listp args) (signal 'wrong-type-argument (list 'listp args))) (or (<= 2 (length args) 4) (signal 'wrong-number-of-arguments (list 2 4 (length args)))) diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index b68ebfbd887..5df9b53657b 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -1305,7 +1305,10 @@ is non-nil, don't propagate connection errors (does not apply to errors signaled by ERROR-FORM or by BODY). \(fn URL &key ASYNC FILE ERROR-FORM NOERROR &rest BODY)" - (declare (indent defun) (debug t)) + (declare (indent defun) + ;; FIXME: This should be something like + ;; `form def-body &rest form', but that doesn't work. + (debug (form &rest sexp))) (while (keywordp (car body)) (setq body (cdr (cdr body)))) `(package--with-response-buffer-1 ,url (lambda () ,@body) diff --git a/lisp/emacs-lisp/thunk.el b/lisp/emacs-lisp/thunk.el index 83e0fa75aa7..7e349d22a49 100644 --- a/lisp/emacs-lisp/thunk.el +++ b/lisp/emacs-lisp/thunk.el @@ -52,7 +52,7 @@ (defmacro thunk-delay (&rest body) "Delay the evaluation of BODY." - (declare (debug t)) + (declare (debug (def-body))) (cl-assert lexical-binding) `(let (forced (val (lambda () ,@body))) diff --git a/lisp/info-xref.el b/lisp/info-xref.el index be1928d692b..538a017f3c0 100644 --- a/lisp/info-xref.el +++ b/lisp/info-xref.el @@ -95,7 +95,7 @@ about local variables or possible weirdness in a major mode. `lm-with-file' does a similar thing, but it sets `emacs-lisp-mode' which is not wanted here." - (declare (debug t) (indent 1)) + (declare (debug (form def-body)) (indent 1)) `(let* ((info-xref-with-file--filename ,filename) (info-xref-with-file--body (lambda () ,@body)) (info-xref-with-file--existing diff --git a/lisp/subr.el b/lisp/subr.el index 7a055f2ba1e..82c2d221a68 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -2030,7 +2030,7 @@ FUN is then called once." (defmacro subr--with-wrapper-hook-no-warnings (hook args &rest body) "Like (with-wrapper-hook HOOK ARGS BODY), but without warnings." - (declare (debug (form sexp body))) + (declare (debug (form sexp def-body))) ;; We need those two gensyms because CL's lexical scoping is not available ;; for function arguments :-( (let ((funs (make-symbol "funs")) @@ -3951,7 +3951,7 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you quit again." Within a `track-mouse' form, mouse motion generates input events that you can read with `read-event'. Normally, mouse motion is ignored." - (declare (debug t) (indent 0)) + (declare (debug (def-body)) (indent 0)) `(internal--track-mouse (lambda () ,@body))) (defmacro with-current-buffer (buffer-or-name &rest body) @@ -4455,7 +4455,7 @@ change `before-change-functions' or `after-change-functions'. Additionally, the buffer modifications of BODY are recorded on the buffer's undo list as a single \(apply ...) entry containing the function `undo--wrap-and-run-primitive-undo'." - (declare (debug t) (indent 2)) + (declare (debug (form form def-body)) (indent 2)) `(combine-change-calls-1 ,beg ,end (lambda () ,@body))) (defun undo--wrap-and-run-primitive-undo (beg end list) @@ -5046,7 +5046,7 @@ See also `with-eval-after-load'." FILE is normally a feature name, but it can also be a file name, in case that file does not provide any feature. See `eval-after-load' for more details about the different forms of FILE and their semantics." - (declare (indent 1) (debug t)) + (declare (indent 1) (debug (form def-body))) `(eval-after-load ,file (lambda () ,@body))) (defvar after-load-functions nil diff --git a/lisp/vc/vc-dispatcher.el b/lisp/vc/vc-dispatcher.el index 87ca542f1c2..c29458620e9 100644 --- a/lisp/vc/vc-dispatcher.el +++ b/lisp/vc/vc-dispatcher.el @@ -254,7 +254,7 @@ CODE should be a function of no arguments." nil) (defmacro vc-run-delayed (&rest body) - (declare (indent 0) (debug t)) + (declare (indent 0) (debug (def-body))) `(vc-exec-after (lambda () ,@body))) (defvar vc-post-command-functions nil -- cgit v1.2.3 From 9676d41b8301b84e07717e633059a3f2b5c4c9d8 Mon Sep 17 00:00:00 2001 From: Philipp Stephani Date: Tue, 18 May 2021 09:25:54 +0200 Subject: * lisp/emacs-lisp/subr-x.el (if-let): Swap &or branches (Bug#48489) --- lisp/emacs-lisp/subr-x.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/subr-x.el b/lisp/emacs-lisp/subr-x.el index 5a8885c0427..fb890509ad7 100644 --- a/lisp/emacs-lisp/subr-x.el +++ b/lisp/emacs-lisp/subr-x.el @@ -174,8 +174,8 @@ As a special case, interprets a SPEC of the form \(SYMBOL SOMETHING) like \((SYMBOL SOMETHING)). This exists for backward compatibility with an old syntax that accepted only one binding." (declare (indent 2) - (debug ([&or (&rest [&or symbolp (symbolp form) (form)]) - (symbolp form)] + (debug ([&or (symbolp form) ; must be first, Bug#48489 + (&rest [&or symbolp (symbolp form) (form)])] form body))) (when (and (<= (length spec) 2) (not (listp (car spec)))) -- cgit v1.2.3 From be9db2b94d31a0afe3f93302558b3a78605244c7 Mon Sep 17 00:00:00 2001 From: Mattias Engdegård Date: Tue, 18 May 2021 12:03:11 +0200 Subject: Fix pcase 'rx' patterns with a single named submatch (bug#48477) pcase 'rx' patterns with a single named submatch, like (rx (let x "a")) would always succeed because of an over-optimistic transformation. Patterns with 0 or more than 1 named submatches were not affected. Reported by Philipp Stephani. * lisp/emacs-lisp/rx.el (rx--pcase-macroexpander): Special case for a single named submatch. * test/lisp/emacs-lisp/rx-tests.el (rx-pcase): Add tests. --- lisp/emacs-lisp/rx.el | 21 ++++++++++++++++----- test/lisp/emacs-lisp/rx-tests.el | 14 ++++++++++++++ 2 files changed, 30 insertions(+), 5 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/rx.el b/lisp/emacs-lisp/rx.el index 1e3eb9c12b1..43bd84d9990 100644 --- a/lisp/emacs-lisp/rx.el +++ b/lisp/emacs-lisp/rx.el @@ -1445,12 +1445,23 @@ following constructs: (regexp (rx--to-expr (rx--pcase-transform (cons 'seq regexps)))) (nvars (length rx--pcase-vars))) `(and (pred stringp) - ,(if (zerop nvars) - ;; No variables bound: a single predicate suffices. - `(pred (string-match ,regexp)) + ,(pcase nvars + (0 + ;; No variables bound: a single predicate suffices. + `(pred (string-match ,regexp))) + (1 + ;; Create a match value that on a successful regexp match + ;; is the submatch value, 0 on failure. We can't use nil + ;; for failure because it is a valid submatch value. + `(app (lambda (s) + (if (string-match ,regexp s) + (match-string 1 s) + 0)) + (and ,(car rx--pcase-vars) (pred (not numberp))))) + (_ ;; Pack the submatches into a dotted list which is then ;; immediately destructured into individual variables again. - ;; This is of course slightly inefficient when NVARS > 1. + ;; This is of course slightly inefficient. ;; A dotted list is used to reduce the number of conses ;; to create and take apart. `(app (lambda (s) @@ -1463,7 +1474,7 @@ following constructs: (rx--reduce-right #'cons (mapcar (lambda (name) (list '\, name)) - (reverse rx--pcase-vars))))))))) + (reverse rx--pcase-vars)))))))))) ;; Obsolete internal symbol, used in old versions of the `flycheck' package. (define-obsolete-function-alias 'rx-submatch-n 'rx-to-string "27.1") diff --git a/test/lisp/emacs-lisp/rx-tests.el b/test/lisp/emacs-lisp/rx-tests.el index 2dd1bca22d1..4828df0de92 100644 --- a/test/lisp/emacs-lisp/rx-tests.el +++ b/test/lisp/emacs-lisp/rx-tests.el @@ -166,6 +166,20 @@ (backref 1)) (list u v))) '("1" "3"))) + (should (equal (pcase "bz" + ((rx "a" (let x nonl)) (list 1 x)) + (_ 'no)) + 'no)) + (should (equal (pcase "az" + ((rx "a" (let x nonl)) (list 1 x)) + ((rx "b" (let x nonl)) (list 2 x)) + (_ 'no)) + '(1 "z"))) + (should (equal (pcase "bz" + ((rx "a" (let x nonl)) (list 1 x)) + ((rx "b" (let x nonl)) (list 2 x)) + (_ 'no)) + '(2 "z"))) (let ((k "blue")) (should (equal (pcase "" ((rx "<" (literal k) ">") 'ok)) -- cgit v1.2.3 From 2c90aa93a9d4d53c090dbb8a33501fa4e8cefc64 Mon Sep 17 00:00:00 2001 From: Alexandr Vityazev Date: Tue, 18 May 2021 15:36:25 +0200 Subject: Fix the length= shortdoc example * lisp/emacs-lisp/shortdoc.el (list): Fix the length= example (bug#48495). Copyright-paperwork-exempt: yes --- lisp/emacs-lisp/shortdoc.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/shortdoc.el b/lisp/emacs-lisp/shortdoc.el index 9b31d687035..0320e171825 100644 --- a/lisp/emacs-lisp/shortdoc.el +++ b/lisp/emacs-lisp/shortdoc.el @@ -625,7 +625,7 @@ There can be any number of :example/:result elements." (length> :eval (length> '(a b c) 1)) (length= - :eval (length> '(a b c) 3)) + :eval (length= '(a b c) 3)) (safe-length :eval (safe-length '(a b c)))) -- cgit v1.2.3 From 33c0994c7cbb6a5048db10b3b05d31e8d72f220a Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" Date: Tue, 18 May 2021 16:28:42 +0100 Subject: Look for ElDoc buffer in all visible frames * lisp/emacs-lisp/eldoc.el (eldoc--echo-area-prefer-doc-buffer-p): Look for a window displaying the ElDoc documentation buffer in all visible frames, as promised by the user option eldoc-echo-area-prefer-doc-buffer (bug#48278). --- lisp/emacs-lisp/eldoc.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el index b4f068cf3ae..cec89cf3bc5 100644 --- a/lisp/emacs-lisp/eldoc.el +++ b/lisp/emacs-lisp/eldoc.el @@ -538,7 +538,7 @@ documentation to potentially appear in the echo are is truncated." (and truncatedp (eq eldoc-echo-area-prefer-doc-buffer 'maybe))) - (get-buffer-window eldoc--doc-buffer))) + (get-buffer-window eldoc--doc-buffer 'visible))) (defun eldoc-display-in-echo-area (docs _interactive) "Display DOCS in echo area. -- cgit v1.2.3 From 502e3ce614ce9cec60a9f8fb9b6beb216131e362 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Tue, 18 May 2021 23:35:57 +0300 Subject: * lisp/emacs-lisp/lisp-mode.el (lisp-outline-level): Fix imprecise numbers. (lisp-outline-level): Return right levels starting from 1 instead of 5. Suggested by Howard Melman in bug#46878. --- lisp/emacs-lisp/lisp-mode.el | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index 67b75460941..59325d647d8 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -682,10 +682,16 @@ font-lock keywords will not be case sensitive." (defun lisp-outline-level () "Lisp mode `outline-level' function." + ;; Expects outline-regexp is ";;;\\(;* [^ \t\n]\\|###autoload\\)\\|(" + ;; and point is at the beginning of a matching line. (let ((len (- (match-end 0) (match-beginning 0)))) - (if (looking-at "(\\|;;;###autoload") - 1000 - len))) + (cond ((looking-at "(\\|;;;###autoload") + 1000) + ((looking-at ";;\\(;+\\) ") + (- (match-end 1) (match-beginning 1))) + ;; Above should match everything but just in case. + (t + len)))) (defun lisp-current-defun-name () "Return the name of the defun at point, or nil." -- cgit v1.2.3 From 2c47eaa18a4a3f7eb53ed826d8c5d018ac843586 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Tue, 18 May 2021 17:13:37 -0400 Subject: * lisp/emacs-lisp/eieio-core.el (eieio-defclass-internal): Use a closure --- lisp/emacs-lisp/eieio-core.el | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/eieio-core.el b/lisp/emacs-lisp/eieio-core.el index 2923dffd951..34b4575182e 100644 --- a/lisp/emacs-lisp/eieio-core.el +++ b/lisp/emacs-lisp/eieio-core.el @@ -347,19 +347,20 @@ See `defclass' for more information." (when eieio-backward-compatibility (let ((csym (intern (concat (symbol-name cname) "-list-p")))) (defalias csym - `(lambda (obj) - ,(format - "Test OBJ to see if it a list of objects which are a child of type %s" - cname) - (when (listp obj) - (let ((ans t)) ;; nil is valid - ;; Loop over all the elements of the input list, test - ;; each to make sure it is a child of the desired object class. - (while (and obj ans) - (setq ans (and (eieio-object-p (car obj)) - (object-of-class-p (car obj) ,cname))) - (setq obj (cdr obj))) - ans)))) + (lambda (obj) + (:documentation + (format + "Test OBJ to see if it a list of objects which are a child of type %s" + cname)) + (when (listp obj) + (let ((ans t)) ;; nil is valid + ;; Loop over all the elements of the input list, test + ;; each to make sure it is a child of the desired object class. + (while (and obj ans) + (setq ans (and (eieio-object-p (car obj)) + (object-of-class-p (car obj) 'cname))) + (setq obj (cdr obj))) + ans)))) (make-obsolete csym (format "use (cl-typep ... \\='(list-of %s)) instead" cname) -- cgit v1.2.3