From 8c4294f370f432b0df402dd5b9f074de3eca26f2 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 15 Feb 2025 12:08:41 +0200 Subject: [PATCH 01/56] ; Move index entries in user manual * doc/emacs/package.texi (Packages): Move index entries from here... (Package Installation): ...to here. Index entries should be where the main description of the subject can be found. --- doc/emacs/package.texi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/emacs/package.texi b/doc/emacs/package.texi index 9b6f7cd8f31..30cdfc6dd75 100644 --- a/doc/emacs/package.texi +++ b/doc/emacs/package.texi @@ -35,8 +35,6 @@ install or uninstall packages via this buffer. @xref{Package Menu}. name of a package, and displays a help buffer describing the attributes of the package and the features that it implements. -@cindex GNU ELPA -@cindex NonGNU ELPA By default, Emacs downloads packages from two archives: @url{https://elpa.gnu.org/, GNU ELPA} and @url{https://elpa.nongnu.org/, NonGNU ELPA}. These are maintained by the Emacs developers and hosted @@ -400,6 +398,8 @@ package is somehow unavailable, Emacs signals an error and stops installation.) A package's requirements list is shown in its help buffer. +@cindex GNU ELPA +@cindex NonGNU ELPA By default, Emacs downloads packages from two archives: @url{https://elpa.gnu.org/, GNU ELPA} and @url{https://elpa.nongnu.org/, NonGNU ELPA}. These are maintained by the Emacs developers and hosted From e9c4f642b9dca399cbcab2ff59636d12b89cc8fc Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 15 Feb 2025 12:12:30 +0200 Subject: [PATCH 02/56] ; * doc/emacs/package.texi (Package Installation): Add omitted index entry. --- doc/emacs/package.texi | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/emacs/package.texi b/doc/emacs/package.texi index 30cdfc6dd75..857584b9933 100644 --- a/doc/emacs/package.texi +++ b/doc/emacs/package.texi @@ -420,6 +420,7 @@ name of the package archive directory. You can alter this list if you wish to use third party package archives---but do so at your own risk, and use only third parties that you think you can trust! +@cindex base location, package archive @defopt package-archives The value of this variable is an alist of package archives recognized by the Emacs package manager. From 6491fee366f58a831689c57aa31493dd70bc2245 Mon Sep 17 00:00:00 2001 From: kobarity Date: Mon, 13 Jan 2025 22:38:42 +0900 Subject: [PATCH 03/56] Fix string end search in python-nav-end-of-statement * lisp/progmodes/python.el (python-nav-end-of-statement): Change to look for string delimiter characters and check syntax, instead of looking for string-delimiter syntax. * test/lisp/progmodes/python-tests.el (python-nav-end-of-statement-5): New test. (Bug#75387) --- lisp/progmodes/python.el | 7 +++++-- test/lisp/progmodes/python-tests.el | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 8a99ff0434d..a42e2b2a28a 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -2328,8 +2328,11 @@ of the statement." (setq last-string-end (or (if (eq t (nth 3 (syntax-ppss))) - (re-search-forward - (rx (syntax string-delimiter)) nil t) + (cl-loop + while (re-search-forward + (rx (or "\"\"\"" "'''")) nil t) + unless (python-syntax-context 'string) + return (point)) (ignore-error scan-error (goto-char string-start) (python-nav--lisp-forward-sexp) diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el index ec0a836cb8f..898e2b036e0 100644 --- a/test/lisp/progmodes/python-tests.el +++ b/test/lisp/progmodes/python-tests.el @@ -3204,6 +3204,30 @@ d = '''d''' (python-tests-look-at "c'") (pos-eol)))))) +(ert-deftest python-nav-end-of-statement-5 () + "Test long multi-line string (Bug#75387)." + (let* ((line (format "%s\n" (make-string 80 ?a))) + (lines (apply #'concat (make-list 50 line)))) + (python-tests-with-temp-buffer + (concat + " +s = ''' +" + lines + "\\'''" + lines + "''' +a = 1 +") + (python-tests-look-at "s = '''") + (should (= (save-excursion + (python-nav-end-of-statement) + (point)) + (save-excursion + (python-tests-look-at "a = 1") + (forward-line -1) + (pos-eol))))))) + (ert-deftest python-nav-forward-statement-1 () (python-tests-with-temp-buffer " From a8a4c3a091bc6ebab40db3b33f4d15bb1040dbcb Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Mon, 3 Feb 2025 16:39:49 +0100 Subject: [PATCH 04/56] completing-read-multiple: CRM indication and prompt customization The `completing-read-multiple' prompt indicates multi completion. The customization option `crm-prompt' configures the formatting of the prompt. The variable can be set to "%p" in order to only display the original prompt, to "[%d] %p" to display the separator description and the prompt, or to "[CRM%s] %p" to display a shorter indicator of only the separator string and the prompt. * lisp/emacs-lisp/crm.el (crm-prompt): New user option. (crm-separator): Update value and docstring. (completing-read-multiple): Use `crm-prompt' to format the prompt. * etc/NEWS: Announce the change. (Bug#76028) --- etc/NEWS | 8 ++++++++ lisp/emacs-lisp/crm.el | 30 ++++++++++++++++++++++++++---- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 51f481c763c..6d934b2029c 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -176,6 +176,14 @@ will still be on that candidate after "*Completions*" is updated with a new list of completions. The candidate is automatically deselected when the "*Completions*" buffer is hidden. +--- +*** New user option 'crm-prompt' for 'completing-read-multiple'. +This option configures the prompt format of 'completing-read-multiple'. +By default the prompt indicates to the user that the completion command +accepts a comma-separated list. The prompt format can include the +separator description and the separator string, which are both stored as +text properties of the 'crm-separator' regular expression. + ** Windows +++ diff --git a/lisp/emacs-lisp/crm.el b/lisp/emacs-lisp/crm.el index a371a8e14de..676252ae126 100644 --- a/lisp/emacs-lisp/crm.el +++ b/lisp/emacs-lisp/crm.el @@ -79,9 +79,25 @@ (define-obsolete-variable-alias 'crm-default-separator 'crm-separator "29.1") -(defvar crm-separator "[ \t]*,[ \t]*" +(defvar crm-separator + (propertize "[ \t]*,[ \t]*" 'separator "," 'description "comma-separated list") "Separator regexp used for separating strings in `completing-read-multiple'. -It should be a regexp that does not match the list of completion candidates.") +It should be a regexp that does not match the list of completion +candidates. The regexp string can carry the text properties `separator' +and `description', which if present `completing-read-multiple' will show +as part of the prompt. See the user option `crm-prompt'.") + +(defcustom crm-prompt "[%d] %p" + "Prompt format for `completing-read-multiple'. +The prompt is formatted by `format-spec' with the keys %d, %s and %p +standing for the separator description, the separator itself and the +original prompt respectively." + :type '(choice (const :tag "Original prompt" "%p") + (const :tag "Description and prompt" "[%d] %p") + (const :tag "Short CRM indication" "[CRM%s] %p") + (string :tag "Custom string")) + :group 'minibuffer + :version "31.1") (defvar-keymap crm-local-completion-map :doc "Local keymap for minibuffer multiple input with completion. @@ -266,8 +282,14 @@ with empty strings removed." (unless (eq require-match t) require-match)) (setq-local crm-completion-table table)) (setq input (read-from-minibuffer - prompt initial-input map - nil hist def inherit-input-method))) + (format-spec + crm-prompt + (let* ((sep (or (get-text-property 0 'separator crm-separator) + (string-replace "[ \t]*" "" crm-separator))) + (desc (or (get-text-property 0 'description crm-separator) + (concat "list separated by " sep)))) + `((?s . ,sep) (?d . ,desc) (?p . ,prompt)))) + initial-input map nil hist def inherit-input-method))) ;; If the user enters empty input, `read-from-minibuffer' ;; returns the empty string, not DEF. (when (and def (string-equal input "")) From 7ad139d72108df78763b570b376fbe4aad952f72 Mon Sep 17 00:00:00 2001 From: David Ponce Date: Sat, 8 Feb 2025 13:55:16 +0100 Subject: [PATCH 05/56] Fix DOM printing Fix DOM printing when an attribute value is not a string, which is often the case in SVG DOM. Don't print attributes without a value. Refresh the list of HTML boolean attributes. * lisp/dom.el (dom--html-boolean-attribute-p): New function. (dom-print): Use it. Convert attribute value to string before to call `url-insert-entities-in-string'. Don't print attribute without a value. Compute indentation column outside of loop and call `indent-line-to' to indent line. (Bug#5928) * test/lisp/dom-tests.el (dom-tests-print-svg) (dom-tests-print-html-boolean): New tests. --- lisp/dom.el | 60 ++++++++++++++++++++++++------------------ test/lisp/dom-tests.el | 54 +++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 26 deletions(-) diff --git a/lisp/dom.el b/lisp/dom.el index fc032058e9f..4d904c92de9 100644 --- a/lisp/dom.el +++ b/lisp/dom.el @@ -258,31 +258,41 @@ white-space." (insert ")") (insert "\n" (make-string (1+ column) ?\s)))))))) +(define-inline dom--html-boolean-attribute-p (attr) + "Return non-nil if ATTR is an HTML boolean attribute." + (inline-quote + (memq ,attr + ;; Extracted from the HTML Living Standard list of attributes + ;; at . + '( allowfullscreen alpha async autofocus autoplay checked + controls default defer disabled formnovalidate inert ismap + itemscope loop multiple muted nomodule novalidate open + playsinline readonly required reversed selected + shadowrootclonable shadowrootdelegatesfocus + shadowrootserializable)))) + (defun dom-print (dom &optional pretty xml) "Print DOM at point as HTML/XML. If PRETTY, indent the HTML/XML logically. If XML, generate XML instead of HTML." - (let ((column (current-column))) + (let ((column (current-column)) + (indent-tabs-mode nil)) ;; Indent with spaces (insert (format "<%s" (dom-tag dom))) - (let ((attr (dom-attributes dom))) - (dolist (elem attr) - ;; In HTML, these are boolean attributes that should not have - ;; an = value. - (insert (if (and (memq (car elem) - '(async autofocus autoplay checked - contenteditable controls default - defer disabled formNoValidate frameborder - hidden ismap itemscope loop - multiple muted nomodule novalidate open - readonly required reversed - scoped selected typemustmatch)) - (cdr elem) - (not xml)) - (format " %s" (car elem)) - (format " %s=\"%s\"" (car elem) - (url-insert-entities-in-string (cdr elem))))))) + (pcase-dolist (`(,attr . ,value) (dom-attributes dom)) + ;; Don't print attributes without a value. + (when value + (insert + ;; HTML boolean attributes should not have an = value. The + ;; presence of a boolean attribute on an element represents + ;; the true value, and the absence of the attribute + ;; represents the false value. + (if (and (not xml) (dom--html-boolean-attribute-p attr)) + (format " %s" attr) + (format " %s=%S" attr (url-insert-entities-in-string + (format "%s" value))))))) (let* ((children (dom-children dom)) - (non-text nil)) + (non-text nil) + (indent (+ column 2))) (if (null children) (insert " />") (insert ">") @@ -291,16 +301,14 @@ If XML, generate XML instead of HTML." (insert (url-insert-entities-in-string child)) (setq non-text t) (when pretty - (insert "\n" (make-string (+ column 2) ?\s))) + (insert "\n") + (indent-line-to indent)) (dom-print child pretty xml))) ;; If we inserted non-text child nodes, or a text node that ;; ends with a newline, then we indent the end tag. - (when (and pretty - (or (bolp) - non-text)) - (unless (bolp) - (insert "\n")) - (insert (make-string column ?\s))) + (when (and pretty (or (bolp) non-text)) + (or (bolp) (insert "\n")) + (indent-line-to column)) (insert (format "" (dom-tag dom))))))) (provide 'dom) diff --git a/test/lisp/dom-tests.el b/test/lisp/dom-tests.el index 47c2a7bb569..eecc4f39808 100644 --- a/test/lisp/dom-tests.el +++ b/test/lisp/dom-tests.el @@ -27,6 +27,7 @@ ;;; Code: (require 'dom) +(require 'svg) (require 'ert) ;; `defsubst's are not inlined inside `ert-deftest' (see Bug#24402), @@ -219,6 +220,59 @@ child results in an error." "<div class="default"> </div>" ""))))) +(ert-deftest dom-tests-print-svg () + "Test that `dom-print' correctly print a SVG DOM." + (let ((svg (svg-create 100 100))) + (svg-rectangle svg 0 0 "100%" "100%" :fill "blue") + (svg-text svg "A text" :x 0 :y 55 :stroke "yellow" :fill "yellow") + (with-temp-buffer + (dom-print svg t t) + (should + (equal + (buffer-string) + (concat + "\n" + " \n" + " A text\n" + "")))))) + +(ert-deftest dom-tests-print-html-boolean () + "Test that `dom-print' correctly print HTML boolean attributes." + (let ((dom (dom-node + "html" nil + (dom-node "head" nil + (dom-node "title" nil + "Test boolean attributes")) + (dom-node "body" nil + ;; The following checkboxes are checked + (dom-node "input" '((type . "checkbox") + (checked . ""))) + (dom-node "input" '((type . "checkbox") + (checked . "checked"))) + (dom-node "input" '((type . "checkbox") + (checked . "true"))) + (dom-node "input" '((type . "checkbox") + (checked . "false"))) + ;; The following checkbox is not checked + (dom-node "input" '((type . "checkbox") + (checked))) + )))) + (with-temp-buffer + (dom-print dom) + (should + (equal + (buffer-string) + (concat + "Test boolean attributes" + "" + "" + "" + "" + "" + "")))))) + (ert-deftest dom-test-search () (let ((dom '(a nil (b nil (c nil))))) (should (equal (dom-search dom (lambda (d) (eq (dom-tag d) 'a))) From b8b7c6fbfdd62dd830a3a946db1746821e1aec3f Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 15 Feb 2025 14:53:59 +0200 Subject: [PATCH 06/56] ; Declare treesit.c functions * lisp/textmodes/html-ts-mode.el (treesit-search-subtree): * lisp/textmodes/yaml-ts-mode.el (treesit-node-child-by-field-name): Declare. --- lisp/textmodes/html-ts-mode.el | 1 + lisp/textmodes/yaml-ts-mode.el | 1 + 2 files changed, 2 insertions(+) diff --git a/lisp/textmodes/html-ts-mode.el b/lisp/textmodes/html-ts-mode.el index 7e6c3e0b7d1..0f07fbedeed 100644 --- a/lisp/textmodes/html-ts-mode.el +++ b/lisp/textmodes/html-ts-mode.el @@ -41,6 +41,7 @@ (declare-function treesit-parser-create "treesit.c") (declare-function treesit-node-type "treesit.c") +(declare-function treesit-search-subtree "treesit.c") (defcustom html-ts-mode-indent-offset 2 "Number of spaces for each indentation step in `html-ts-mode'." diff --git a/lisp/textmodes/yaml-ts-mode.el b/lisp/textmodes/yaml-ts-mode.el index 72285d570f1..9b211902e14 100644 --- a/lisp/textmodes/yaml-ts-mode.el +++ b/lisp/textmodes/yaml-ts-mode.el @@ -33,6 +33,7 @@ (declare-function treesit-node-start "treesit.c") (declare-function treesit-node-end "treesit.c") (declare-function treesit-node-type "treesit.c") +(declare-function treesit-node-child-by-field-name "treesit.c") (defvar yaml-ts-mode--syntax-table (let ((table (make-syntax-table))) From 7f2508e6e1176f16e9e6ac5b1aae43f07bb2cd8a Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Sat, 15 Feb 2025 11:12:36 -0500 Subject: [PATCH 07/56] (diff-mode-test-font-lock): Fix spurious test failure * test/lisp/vc/diff-mode-tests.el (diff-mode-test-font-lock): Don't nitpick about non-face-affecting overlays. --- test/lisp/vc/diff-mode-tests.el | 38 ++++++++++++++++----------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/test/lisp/vc/diff-mode-tests.el b/test/lisp/vc/diff-mode-tests.el index 06309160e52..cd3f613f532 100644 --- a/test/lisp/vc/diff-mode-tests.el +++ b/test/lisp/vc/diff-mode-tests.el @@ -389,26 +389,26 @@ baz")))) 124 127 (face diff-context)))) ;; Test diff-font-lock-syntax. - (should (equal (mapcar (lambda (o) - (list (- (overlay-start o) diff-beg) - (- (overlay-end o) diff-beg) - (append (and (overlay-get o 'diff-mode) - `(diff-mode ,(overlay-get o 'diff-mode))) - (and (overlay-get o 'face) - `(face ,(overlay-get o 'face)))))) + (should (equal + (delq nil + (mapcar (lambda (o) + (when (overlay-get o 'face) + (list (- (overlay-start o) diff-beg) + (- (overlay-end o) diff-beg) + `( diff-mode ,(overlay-get o 'diff-mode) + face ,(overlay-get o 'face))))) (sort (overlays-in (point-min) (point-max)) - (lambda (a b) (< (overlay-start a) (overlay-start b))))) - '((0 127 (diff-mode fine)) - (0 127 (diff-mode syntax)) - (17 25 (diff-mode syntax face font-lock-preprocessor-face)) - (26 35 (diff-mode syntax face font-lock-string-face)) - (37 40 (diff-mode syntax face font-lock-type-face)) - (41 45 (diff-mode syntax face font-lock-function-name-face)) - (61 78 (diff-mode syntax face font-lock-string-face)) - (69 74 (diff-mode fine face diff-refine-removed)) - (91 108 (diff-mode syntax face font-lock-string-face)) - (99 104 (diff-mode fine face diff-refine-added)) - (114 120 (diff-mode syntax face font-lock-keyword-face)))))))) + (lambda (a b) + (< (overlay-start a) (overlay-start b)))))) + '((17 25 (diff-mode syntax face font-lock-preprocessor-face)) + (26 35 (diff-mode syntax face font-lock-string-face)) + (37 40 (diff-mode syntax face font-lock-type-face)) + (41 45 (diff-mode syntax face font-lock-function-name-face)) + (61 78 (diff-mode syntax face font-lock-string-face)) + (69 74 (diff-mode fine face diff-refine-removed)) + (91 108 (diff-mode syntax face font-lock-string-face)) + (99 104 (diff-mode fine face diff-refine-added)) + (114 120 (diff-mode syntax face font-lock-keyword-face)))))))) (ert-deftest diff-mode-test-font-lock-syntax-one-line () "Check diff syntax highlighting for one line with no newline at end." From 5fcf07ac096a588a561fae07d8177acd8e45498b Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Sat, 15 Feb 2025 17:12:52 +0100 Subject: [PATCH 08/56] Tramp: Don't require PuTTY 0.82 anymore * doc/misc/tramp.texi: Revert last change. * lisp/net/tramp-cache.el (with-tramp-saved-connection-properties): Adapt `tramp-verbose' when completing host names. * lisp/net/tramp-sh.el (tramp-methods) : Adapt `tramp-login-args' and `tramp-copy-args' arguments. (tramp-plink-option-exists-p): New defun. (tramp-ssh-or-plink-options): Rename from `tramp-ssh-controlmaster-options'. Adapt further plink options. (tramp-do-copy-or-rename-file-out-of-band) (tramp-maybe-open-connection): Adapt calls. * lisp/net/tramp.el (tramp-file-name-handler): Don't touch `tramp-verbose'. * test/lisp/net/tramp-tests.el (top): Set `vc-handled-backends' to nil. (tramp--test-enabled): Rearrange code. --- doc/misc/tramp.texi | 10 ++--- lisp/net/tramp-cache.el | 4 +- lisp/net/tramp-sh.el | 85 +++++++++++++++++++----------------- lisp/net/tramp.el | 12 ++--- test/lisp/net/tramp-tests.el | 29 ++++++------ 5 files changed, 71 insertions(+), 69 deletions(-) diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi index ac0bb63335c..86ffba29744 100644 --- a/doc/misc/tramp.texi +++ b/doc/misc/tramp.texi @@ -955,10 +955,9 @@ This is another method from the Kerberos suite. It behaves like @cindex @option{plink} method @item @option{plink} -@option{plink} method is for MS Windows users with the -PuTTY@footnote{It requires at least PuTTY 0.82.} implementation of -SSH@. It uses @samp{plink -ssh} to log in to the remote host. It -supports changing the remote login shell @command{/bin/sh}. +@option{plink} method is for MS Windows users with the PuTTY +implementation of SSH@. It uses @samp{plink -ssh} to log in to the +remote host. It supports changing the remote login shell @command{/bin/sh}. Check the @samp{Share SSH connections if possible} control for that session. @@ -1191,8 +1190,7 @@ This method supports the @samp{-p} argument. These methods are similar to @option{scp} or @option{sftp}, but they use the @command{plink} command to connect to the remote host, and they use @command{pscp} or @command{psftp} for transferring the files. -These programs are part of PuTTY@footnote{It requires at least PuTTY -0.82.}, an SSH implementation for MS Windows. +These programs are part of PuTTY, an SSH implementation for MS Windows. They support changing the remote login shell @command{/bin/sh}. diff --git a/lisp/net/tramp-cache.el b/lisp/net/tramp-cache.el index e7ad565dc30..0c1f6181bf9 100644 --- a/lisp/net/tramp-cache.el +++ b/lisp/net/tramp-cache.el @@ -502,7 +502,9 @@ PROPERTIES is a list of file properties (strings)." (mapcar (lambda (property) (cons property (gethash property hash tramp-cache-undefined))) - ,properties))) + ,properties)) + ;; Avoid superfluous debug buffers during host name completion. + (tramp-verbose (if minibuffer-completing-file-name 0 tramp-verbose))) (tramp-message key 7 "Saved %s" values) (unwind-protect (progn ,@body) ;; Reset PROPERTIES. Recompute hash, it could have been flushed. diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index f85a371cded..ca890854f85 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -322,8 +322,6 @@ The string is used in `tramp-methods'.") `("plink" (tramp-login-program "plink") (tramp-login-args (("-l" "%u") ("-P" "%p") ("-ssh") ("%c") - ;; Since PuTTY 0.82. - ("-legacy-stdio-prompts") ("-t") ("%h") ("\"") (,(format "env 'TERM=%s' 'PROMPT_COMMAND=' 'PS1=%s'" @@ -337,8 +335,6 @@ The string is used in `tramp-methods'.") `("plinkx" (tramp-login-program "plink") (tramp-login-args (("-load") ("%h") ("%c") ("-t") ("\"") - ;; Since PuTTY 0.82. - ("-legacy-stdio-prompts") (,(format "env 'TERM=%s' 'PROMPT_COMMAND=' 'PS1=%s'" tramp-terminal-type @@ -351,8 +347,6 @@ The string is used in `tramp-methods'.") `("pscp" (tramp-login-program "plink") (tramp-login-args (("-l" "%u") ("-P" "%p") ("-ssh") ("%c") - ;; Since PuTTY 0.82. - ("-legacy-stdio-prompts") ("-t") ("%h") ("\"") (,(format "env 'TERM=%s' 'PROMPT_COMMAND=' 'PS1=%s'" @@ -363,9 +357,7 @@ The string is used in `tramp-methods'.") (tramp-remote-shell-login ("-l")) (tramp-remote-shell-args ("-c")) (tramp-copy-program "pscp") - (tramp-copy-args (("-l" "%u") ("-P" "%p") ("-scp") - ;; Since PuTTY 0.82. - ("-legacy-stdio-prompts") + (tramp-copy-args (("-l" "%u") ("-P" "%p") ("-scp") ("%c") ("-p" "%k") ("-q") ("-r"))) (tramp-copy-keep-date t) (tramp-copy-recursive t))) @@ -373,8 +365,6 @@ The string is used in `tramp-methods'.") `("psftp" (tramp-login-program "plink") (tramp-login-args (("-l" "%u") ("-P" "%p") ("-ssh") ("%c") - ;; Since PuTTY 0.82. - ("-legacy-stdio-prompts") ("-t") ("%h") ("\"") (,(format "env 'TERM=%s' 'PROMPT_COMMAND=' 'PS1=%s'" @@ -385,9 +375,7 @@ The string is used in `tramp-methods'.") (tramp-remote-shell-login ("-l")) (tramp-remote-shell-args ("-c")) (tramp-copy-program "pscp") - (tramp-copy-args (("-l" "%u") ("-P" "%p") ("-sftp") - ;; Since PuTTY 0.82. - ("-legacy-stdio-prompts") + (tramp-copy-args (("-l" "%u") ("-P" "%p") ("-sftp") ("%c") ("-p" "%k"))) (tramp-copy-keep-date t))) @@ -2497,7 +2485,7 @@ The method used must be an out-of-band method." ;; Compose copy command. (setq options (format-spec - (tramp-ssh-controlmaster-options v) + (tramp-ssh-or-plink-options v) (format-spec-make ?t (tramp-get-connection-property (tramp-get-connection-process v) "temp-file" ""))) @@ -4909,41 +4897,60 @@ Goes through the list `tramp-inline-compress-commands'." (zerop (tramp-call-process vec "ssh" nil nil nil "-G" "-o" option "0.0.0.1")))) -(defun tramp-ssh-controlmaster-options (vec) - "Return the Control* arguments of the local ssh." +(defun tramp-plink-option-exists-p (vec option) + "Check, whether local plink OPTION is applicable." + ;; We don't want to cache it persistently. + (with-tramp-connection-property nil option + ;; "plink" with valid options returns "plink: no valid host name + ;; provided". We xcheck for this error message." + (with-temp-buffer + (tramp-call-process vec "plink" nil t nil option) + (not + (string-match-p + (rx (| (: "plink: unknown option \"" (literal option) "\"" ) + (: "plink: option \"" (literal option) + "\" not available in this tool" ))) + (buffer-string)))))) + +(defun tramp-ssh-or-plink-options (vec) + "Return additional arguments of the local ssh or plink." (cond ;; No options to be computed. - ((or (null tramp-use-connection-share) - (null (assoc "%c" (tramp-get-method-parameter vec 'tramp-login-args)))) - "") + ((null (assoc "%c" (tramp-get-method-parameter vec 'tramp-login-args))) "") - ;; Use plink option. + ;; Use plink options. ((string-match-p (rx "plink" (? ".exe") eol) (tramp-get-method-parameter vec 'tramp-login-program)) - (if (eq tramp-use-connection-share 'suppress) - "-noshare" "-share")) + (concat + (if (eq tramp-use-connection-share 'suppress) + "-noshare" "-share") + ;; Since PuTTY 0.82. + (when (tramp-plink-option-exists-p vec "-legacy-stdio-prompts") + " -legacy-stdio-prompts"))) ;; There is already a value to be used. ((and (eq tramp-use-connection-share t) (stringp tramp-ssh-controlmaster-options)) tramp-ssh-controlmaster-options) - ;; We can't auto-compute the options. - ((ignore-errors - (not (tramp-ssh-option-exists-p vec "ControlMaster=auto"))) - "") + ;; Use ssh options. + (tramp-use-connection-share + ;; We can't auto-compute the options. + (if (ignore-errors + (not (tramp-ssh-option-exists-p vec "ControlMaster=auto"))) + "" - ;; Determine the options. - (t (ignore-errors - ;; ControlMaster and ControlPath options are introduced in OpenSSH 3.9. - (concat - "-o ControlMaster=" - (if (eq tramp-use-connection-share 'suppress) + ;; Determine the options. + (ignore-errors + ;; ControlMaster and ControlPath options are introduced in OpenSSH 3.9. + (concat + "-o ControlMaster=" + (if (eq tramp-use-connection-share 'suppress) "no" "auto") - " -o ControlPath=" - (if (eq tramp-use-connection-share 'suppress) + " -o ControlPath=" + (if (eq tramp-use-connection-share 'suppress) "none" ;; Hashed tokens are introduced in OpenSSH 6.7. On macOS ;; we cannot use an absolute file name, it is too long. @@ -4957,10 +4964,10 @@ Goes through the list `tramp-inline-compress-commands'." (or small-temporary-file-directory tramp-compat-temporary-file-directory)))) - ;; ControlPersist option is introduced in OpenSSH 5.6. + ;; ControlPersist option is introduced in OpenSSH 5.6. (when (and (not (eq tramp-use-connection-share 'suppress)) (tramp-ssh-option-exists-p vec "ControlPersist=no")) - " -o ControlPersist=no")))))) + " -o ControlPersist=no"))))))) (defun tramp-scp-strict-file-name-checking (vec) "Return the strict file name checking argument of the local scp." @@ -5176,9 +5183,9 @@ connection if a previous connection has died for some reason." (let* ((current-host tramp-system-name) (target-alist (tramp-compute-multi-hops vec)) (previous-hop tramp-null-hop) - ;; We will apply `tramp-ssh-controlmaster-options' + ;; We will apply `tramp-ssh-or-plink-options' ;; only for the first hop. - (options (tramp-ssh-controlmaster-options vec)) + (options (tramp-ssh-or-plink-options vec)) (process-connection-type tramp-process-connection-type) (process-adaptive-read-buffering nil) ;; There are unfortunate settings for "cmdproxy" diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index be761a71fa7..a199417b12a 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -2534,10 +2534,7 @@ Fall back to normal file name handler if no Tramp file name handler exists." ;; We flush connection properties ;; " process-name" and " process-buffer", ;; because the operations shall be applied - ;; in the main connection process. In order - ;; to avoid superfluous debug buffers during - ;; host name completion, we adapt - ;; `tramp-verbose'. + ;; in the main connection process. ;; If `non-essential' is non-nil, Tramp shall ;; not open a new connection. ;; If Tramp detects that it shouldn't continue @@ -2548,11 +2545,8 @@ Fall back to normal file name handler if no Tramp file name handler exists." ;; In both cases, we try the default handler then. (with-tramp-saved-connection-properties v '(" process-name" " process-buffer") - (let ((tramp-verbose - (if minibuffer-completing-file-name - 0 tramp-verbose))) - (tramp-flush-connection-property v " process-name") - (tramp-flush-connection-property v " process-buffer")) + (tramp-flush-connection-property v " process-name") + (tramp-flush-connection-property v " process-buffer") (setq result (catch 'non-essential (catch 'suppress diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 1077b944f0a..3be81449c9c 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -152,7 +152,8 @@ tramp-copy-size-limit nil tramp-error-show-message-timeout nil tramp-persistency-file-name nil - tramp-verbose 0) + tramp-verbose 0 + vc-handled-backends nil) (defconst tramp-test-name-prefix "tramp-test" "Prefix to use for temporary test files.") @@ -251,20 +252,20 @@ being the result.") (file-writable-p ert-remote-temporary-file-directory)))))) (when (cdr tramp--test-enabled-checked) - ;; Remove old test files. - (dolist (dir `(,temporary-file-directory - ,tramp-compat-temporary-file-directory - ,ert-remote-temporary-file-directory)) - (dolist (file (directory-files - dir 'full - (rx-to-string - `(: bos (? ".#") - (| ,tramp-test-name-prefix - ,(if (getenv "TRAMP_TEST_CLEANUP_TEMP_FILES") - tramp-temp-name-prefix 'unmatchable)))))) + (ignore-errors + ;; Remove old test files. + (dolist (dir `(,temporary-file-directory + ,tramp-compat-temporary-file-directory + ,ert-remote-temporary-file-directory)) + (dolist (file (directory-files + dir 'full + (rx-to-string + `(: bos (? ".#") + (| ,tramp-test-name-prefix + ,(if (getenv "TRAMP_TEST_CLEANUP_TEMP_FILES") + tramp-temp-name-prefix 'unmatchable)))))) - ;; Exclude sockets and FUSE mount points. - (ignore-errors + ;; Exclude sockets and FUSE mount points. (unless (or (string-prefix-p "srw" (file-attribute-modes (file-attributes file))) From 4cf53c436159ea54dbfe1a1e24515e2e6fbf9a6f Mon Sep 17 00:00:00 2001 From: Stephen Gildea Date: Sat, 15 Feb 2025 07:33:29 -0800 Subject: [PATCH 09/56] ; Info: time-stamp is documented best in the Emacs manual * lisp/info.el (Info-file-list-for-emacs): Remove entry pointing Info at time-stamp discussion in the Autotype document. --- lisp/info.el | 1 - 1 file changed, 1 deletion(-) diff --git a/lisp/info.el b/lisp/info.el index 7a34b43369e..b8ab5b19776 100644 --- a/lisp/info.el +++ b/lisp/info.el @@ -4678,7 +4678,6 @@ Advanced commands: ("java" . "ccmode") ("idl" . "ccmode") ("pike" . "ccmode") ("skeleton" . "autotype") ("auto-insert" . "autotype") ("copyright" . "autotype") ("executable" . "autotype") - ("time-stamp" . "autotype") ("tempo" . "autotype") ("hippie-expand" . "autotype") ("cvs" . "pcl-cvs") ("ada" . "ada-mode") "calc" ("calcAlg" . "calc") ("calcDigit" . "calc") ("calcVar" . "calc") From 0bc7b5a389b4a164448ab3ba981ca70a90dbb0b0 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sun, 16 Feb 2025 08:49:12 +0200 Subject: [PATCH 10/56] =?UTF-8?q?;=20*=20admin/authors.el=20(authors-alias?= =?UTF-8?q?es):=20Add=20"El=C3=ADas=20Gabriel=20P=C3=A9rez"=20(bug#76319).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/authors.el | 1 + 1 file changed, 1 insertion(+) diff --git a/admin/authors.el b/admin/authors.el index 9f0ff678b23..9de96ef5e14 100644 --- a/admin/authors.el +++ b/admin/authors.el @@ -97,6 +97,7 @@ files.") ("Earl Hyatt" "Earl" "ej32u@protonmail\\.com") ("Ed L. Cashin" "Ed L Cashin") ("Edward M. Reingold" "Ed\\(ward\\( M\\)?\\)? Reingold" "Reingold Edward M") + ("Elías Gabriel Pérez" "eg642616@gmail\\.com") ; bug#76319 ("Emilio C. Lopes" "Emilio Lopes") ("Eric M. Ludlam" "Eric Ludlam") ("Eric S. Raymond" "Eric Raymond") From 7016c13e5e6b136736f477fda67a7b9c26fbea6f Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sun, 16 Feb 2025 02:03:06 -0500 Subject: [PATCH 11/56] ; Update etc/AUTHORS (bug#76319). --- etc/AUTHORS | 180 ++++++++++++++++++++++++++-------------------------- 1 file changed, 90 insertions(+), 90 deletions(-) diff --git a/etc/AUTHORS b/etc/AUTHORS index 03f6b15a1a2..576dfa2e087 100644 --- a/etc/AUTHORS +++ b/etc/AUTHORS @@ -355,7 +355,7 @@ Andreas Rottmann: changed emacsclient.1 emacsclient.c misc.texi server.el Andreas Schwab: changed configure.ac lisp.h xdisp.c process.c alloc.c coding.c Makefile.in emacs.c files.el fileio.c keyboard.c fns.c lread.c xterm.c src/Makefile.in editfns.c print.c eval.c font.c xfns.c sysdep.c - and 663 other files + and 664 other files Andreas Seltenreich: changed nnweb.el gnus.texi message.el gnus-sum.el gnus.el nnslashdot.el gnus-srvr.el gnus-util.el mm-url.el mm-uu.el @@ -474,11 +474,11 @@ Antoine Beaupré: changed vc-git.el Antoine Kalmbach: changed README.md eglot.el -Antoine Levitt: changed gnus-group.el gnus-sum.el message.texi +Antoine Levitt: changed gnus-group.el gnus-sum.el message.texi ada-prj.el ange-ftp.el cus-edit.el dired-x.el ebnf2ps.el emerge.el erc-button.el erc-goodies.el erc-stamp.el erc-track.el files.el find-file.el gnus-art.el gnus-uu.el gnus.el gnus.texi message.el mh-funcs.el - mh-mime.el and 8 other files + and 9 other files Antonin Houska: changed newcomment.el @@ -748,7 +748,7 @@ and changed fill.el simple.el indent.el paragraphs.el cmds.c intervals.c text-mode.el textprop.c ada.el allout.el awk-mode.el bibtex.el buffer.c buffer.h c-mode.el and 38 other files -Boris Samorodov: changed net/imap.el +Boris Samorodov: changed imap.el Boruch Baum: co-wrote footnote.el and changed bookmark.el apropos.el autorevert.el calc.el cua-rect.el @@ -932,7 +932,7 @@ and co-wrote longlines.el tango-dark-theme.el tango-theme.el and changed simple.el display.texi xdisp.c files.el frames.texi cus-edit.el files.texi custom.el subr.el text.texi faces.el keyboard.c startup.el package.el misc.texi emacs.texi modes.texi mouse.el - custom.texi image.c window.el and 932 other files + custom.texi image.c window.el and 934 other files Chris Chase: co-wrote idlw-shell.el idlwave.el @@ -1288,7 +1288,7 @@ and co-wrote hideshow.el and changed vc.el configure.ac vc-hg.el vc-git.el src/Makefile.in vc-bzr.el sysdep.c emacs.c process.c vc-cvs.el lisp.h term.c vc-hooks.el xterm.c keyboard.c vc-svn.el xterm.el callproc.c darwin.h - term.el gnu-linux.h and 918 other files + term.el gnu-linux.h and 920 other files Danny Freeman: changed treesit-tests.el treesit.el @@ -1328,7 +1328,7 @@ and co-wrote latin-ltx.el socks.el and changed configure.ac help.el mule-cmds.el fortran.el mule-conf.el xterm.c browse-url.el mule.el coding.c src/Makefile.in european.el fns.c mule-diag.el simple.el wid-edit.el cus-edit.el cus-start.el - files.el keyboard.c byte-opt.el info.el and 772 other files + files.el keyboard.c byte-opt.el info.el and 771 other files Dave Pearson: wrote 5x5.el quickurl.el @@ -1364,7 +1364,7 @@ David De La Harpe Golden: changed files.el mouse.el simple.el fileio.c cus-start.el nsselect.m select.el w32-fns.el x-win.el xterm.c David Edmondson: changed message.el erc.el mml2015.el process.c - gnus-cite.el gnus-cloud.el gnus.texi mm-uu.el mm-view.el net/imap.el + gnus-cite.el gnus-cloud.el gnus.texi imap.el mm-uu.el mm-view.el nnfolder.el nnimap.el nnml.el rcirc.el shr.el Davide Masserut: changed sh-script.el bindings.el Makefile.in basic.texi @@ -1415,7 +1415,7 @@ David J. Biesack: changed antlr-mode.el quickurl.el David J. MacKenzie: changed configure.ac Makefile.in etags.c fakemail.c cvtmail.c movemail.c termcap.c wakeup.c yow.c Makefile avoid.el b2m.c config.in digest-doc.c emacsclient.c emacsserver.c emacstool.c - etags-vmslib.c fortran.el hexl.c isearch.el and 13 other files + etags-vmslib.c fortran.el hexl.c isearch.el and 14 other files David Kågedal: wrote tempo.el and changed sendmail.el xmenu.c @@ -1460,8 +1460,8 @@ and changed gnus-xmas.el David Mosberger-Tang: changed alpha.h unexelf.c cm.h config.in configure.ac cvtmail.c data.c dispnew.c emacsserver.c etags.c - fakemail.c keyboard.c mem-limits.h process.c sorted-doc.c sysdep.c - terminfo.c unexelf1.c yow.c + fakemail.c keyboard.c mem-limits.h process.c profile.c sorted-doc.c + sysdep.c terminfo.c unexelf1.c yow.c David M. Smith: wrote ielm.el and changed imenu.el pgg-def.el xterm.c @@ -1509,10 +1509,10 @@ Debarshi Ray: changed erc-backend.el erc.el Decklin Foster: changed nngateway.el -Deepak Goel: changed idlw-shell.el feedmail.el files.el find-func.el - flymake.el mh-search.el mh-seq.el mh-thread.el mh-xface.el org.el - simple.el vc.el vhdl-mode.el wdired.el README allout.el appt.el - apropos.el artist.el bibtex.el bindings.el and 82 other files +Deepak Goel: changed idlw-shell.el ada-xref.el feedmail.el files.el + find-func.el flymake.el mh-search.el mh-seq.el mh-thread.el mh-xface.el + org.el simple.el vc.el vhdl-mode.el wdired.el README ada-mode.el + allout.el appt.el apropos.el artist.el and 85 other files D. E. Evans: changed basic.texi @@ -1541,7 +1541,7 @@ Denys Duchier: changed pop3.el Denys Nykula: changed TUTORIAL.uk language/cyrillic.el -Derek Atkins: changed net/imap.el pgg-pgp.el +Derek Atkins: changed imap.el pgg-pgp.el Derek L. Davies: changed gud.el @@ -1681,7 +1681,7 @@ Editorconfig Team: wrote editorconfig-conf-mode.el editorconfig-core-handle.el editorconfig-core.el editorconfig-fnmatch.el editorconfig-tools.el editorconfig.el -Ed L. Cashin: changed gnus-sum.el net/imap.el +Ed L. Cashin: changed gnus-sum.el imap.el Ed Swarthout: changed hexl.el textmodes/table.el @@ -1716,9 +1716,8 @@ E. Jay Berkenbilt: changed b2m.c flyspell.el ispell.el unrmail.el Elad Lahav: changed configure.ac -Elias G. B. Perez: changed flymake.el flymake.texi - -Elias G. Perez: changed flymake.el image.c w32term.c w32term.h +Elías Gabriel Pérez: changed flymake.el flymake.texi image.c w32term.c + w32term.h Elias Oltmanns: changed tls.el gnus-agent.el gnus-cite.el gnus-int.el gnus-srvr.el gnus.el nnimap.el @@ -1736,9 +1735,9 @@ Eli Zaretskii: wrote [bidirectional display in xdisp.c] chartab-tests.el coding-tests.el etags-tests.el rxvt.el tty-colors.el and co-wrote help-tests.el and changed xdisp.c display.texi w32.c msdos.c simple.el w32fns.c - files.el fileio.c keyboard.c emacs.c configure.ac text.texi w32term.c + files.el fileio.c keyboard.c configure.ac emacs.c text.texi w32term.c dispnew.c frames.texi files.texi w32proc.c xfaces.c window.c - dispextern.h lisp.h and 1400 other files + dispextern.h lisp.h and 1404 other files Eliza Velasquez: changed server.el simple.el @@ -1762,6 +1761,7 @@ Emilio C. Lopes: changed woman.el cmuscheme.el help.el vc.el advice.el and 58 other files Emmanuel Briot: wrote xml.el +and changed ada-mode.el ada-stmt.el ada-prj.el ada-xref.el Era Eriksson: changed bibtex.el dired.el json.el ses.el ses.texi shell.el tramp.el tramp.texi @@ -1830,10 +1830,10 @@ Eric M. Ludlam: wrote analyze.el analyze/complete.el analyze/debug.el tag-ls.el tag-write.el tag.el test.el and co-wrote db-ebrowse.el srecode/cpp.el util-modes.el and changed c.srt ede.texi info.el rmail.el speedbspec.el cedet.el - ede-autoconf.srt ede-make.srt eieio.texi gud.el - lisp/obsolete/inversion.el sb-dir-minus.xpm sb-dir-plus.xpm sb-dir.xpm - sb-mail.xpm sb-pg-minus.xpm sb-pg-plus.xpm sb-pg.xpm sb-tag-gt.xpm - sb-tag-minus.xpm and 37 other files + ede-autoconf.srt ede-make.srt eieio.texi gud.el sb-dir-minus.xpm + sb-dir-plus.xpm sb-dir.xpm sb-mail.xpm sb-pg-minus.xpm sb-pg-plus.xpm + sb-pg.xpm sb-tag-gt.xpm sb-tag-minus.xpm sb-tag-plus.xpm + and 35 other files Eric Schulte: wrote ob-awk.el ob-calc.el ob-comint.el ob-css.el ob-ditaa.el ob-dot.el ob-emacs-lisp.el ob-eval.el ob-forth.el @@ -1897,8 +1897,8 @@ Espen Skoglund: wrote pascal.el Espen Wiborg: changed utf-7.el -Ethan Bradford: changed ispell.el ange-ftp.el gnus.el gnuspost.el - lisp/obsolete/vt-control.el lpr.el mailalias.el +Ethan Bradford: changed ispell.el ange-ftp.el gnus.el gnuspost.el lpr.el + mailalias.el vt-control.el Ethan Ligon: changed org-docbook.el ox-html.el @@ -2139,8 +2139,7 @@ Gary Oberbrunner: changed eglot.el gud.el Gary Wong: changed termcap.c tparam.c -Gaute B Strokkenes: changed net/imap.el gnus-fun.el mail-source.el - process.c +Gaute B Strokkenes: changed imap.el gnus-fun.el mail-source.el process.c Gautier Ponsinet: changed calendar.texi @@ -2191,7 +2190,7 @@ Gerd Möllmann: wrote authors.el ebrowse.el jit-lock.el tooltip.el and changed xdisp.c xterm.c dispnew.c dispextern.h xfns.c xfaces.c window.c keyboard.c lisp.h faces.el alloc.c buffer.c startup.el xterm.h fns.c term.c configure.ac simple.el frame.c xmenu.c emacs.c - and 621 other files + and 626 other files Gergely Nagy: changed erc.el @@ -2221,7 +2220,7 @@ and changed configure.ac Makefile.in src/Makefile.in calendar.el lisp/Makefile.in diary-lib.el files.el make-dist rmail.el progmodes/f90.el bytecomp.el admin.el misc/Makefile.in simple.el authors.el startup.el emacs.texi lib-src/Makefile.in display.texi - ack.texi subr.el and 1790 other files + ack.texi subr.el and 1796 other files Glynn Clements: wrote gamegrid.el snake.el tetris.el @@ -2705,7 +2704,7 @@ Jason Kim: changed shell.el Jason L. Wright: changed smtpmail.el -Jason Merrill: changed gnus-sum.el add-log.el gnus-salt.el net/imap.el +Jason Merrill: changed gnus-sum.el add-log.el gnus-salt.el imap.el nnfolder.el Jason Riedy: changed org-table.el org.texi @@ -3162,7 +3161,7 @@ Jorge P. De Morais Neto: changed TUTORIAL cl.texi Jose A. Ortega Ruiz: changed doc-view.el misc.texi mixal-mode.el gnus-sum.el imenu.el url-http.el -Jose E. Marchesi: changed gomoku.el simple.el smtpmail.el +Jose E. Marchesi: changed ada-mode.el gomoku.el simple.el smtpmail.el José L. Doménech: changed dired-aux.el @@ -3215,11 +3214,11 @@ and co-wrote help-tests.el keymap-tests.el and changed subr.el desktop.el w32fns.c bs.el faces.el simple.el emacsclient.c files.el server.el help-fns.el xdisp.c org.el w32term.c w32.c buffer.c keyboard.c ido.el image.c window.c eval.c allout.el - and 1222 other files + and 1228 other files Juan Pechiar: changed ob-octave.el -Juergen Kreileder: changed net/imap.el nnimap.el +Juergen Kreileder: changed imap.el nnimap.el Juergen Nickelsen: wrote ws-mode.el @@ -3266,7 +3265,7 @@ Juri Linkov: wrote compose.el emoji.el files-x.el misearch.el and changed isearch.el simple.el info.el replace.el dired.el dired-aux.el minibuffer.el window.el progmodes/grep.el outline.el subr.el vc.el mouse.el diff-mode.el repeat.el files.el image-mode.el menu-bar.el - vc-git.el project.el search.texi and 490 other files + vc-git.el project.el search.texi and 491 other files Jussi Lahdenniemi: changed w32fns.c ms-w32.h msdos.texi w32.c w32.h w32console.c w32heap.c w32inevt.c w32term.h @@ -3296,7 +3295,7 @@ and co-wrote longlines.el tramp-sh.el tramp.el and changed message.el gnus-agent.el gnus-sum.el files.el nnmail.el tramp.texi nntp.el gnus.el simple.el ange-ftp.el dired.el paragraphs.el bindings.el files.texi gnus-art.el gnus-group.el man.el INSTALL - Makefile.in crisp.el fileio.c and 44 other files + Makefile.in crisp.el fileio.c and 45 other files Kailash C. Chowksey: changed HELLO ind-util.el kannada.el knd-util.el lisp/Makefile.in loadup.el @@ -3342,7 +3341,7 @@ and changed simple.el files.el CONTRIBUTE doc-view.el image-mode.el Karl Heuer: changed keyboard.c lisp.h xdisp.c buffer.c xfns.c xterm.c alloc.c files.el frame.c configure.ac window.c data.c minibuf.c editfns.c fns.c process.c Makefile.in fileio.c simple.el keymap.c - indent.c and 445 other files + indent.c and 447 other files Karl Kleinpaste: changed gnus-sum.el gnus-art.el gnus-picon.el gnus-score.el gnus-uu.el gnus-xmas.el gnus.el mm-uu.el mml.el nnmail.el @@ -3372,7 +3371,7 @@ Katsumi Yamaoka: wrote canlock.el and changed gnus-art.el gnus-sum.el message.el mm-decode.el gnus.texi mm-util.el mm-view.el gnus-group.el gnus-util.el gnus-msg.el mml.el shr.el rfc2047.el gnus-start.el gnus.el nntp.el gnus-agent.el nnrss.el - mm-uu.el nnmail.el emacs-mime.texi and 159 other files + mm-uu.el nnmail.el emacs-mime.texi and 158 other files Kaushal Modi: changed dired-aux.el files.el isearch.el apropos.el calc-yank.el custom.texi desktop.el dired.el dired.texi ediff-diff.el @@ -3389,7 +3388,7 @@ Kazuhiro Ito: changed coding.c epg.el japan-util.el uudecode.el flow-fill.el font.c image.c keyboard.c language/japanese.el make-mode.el starttls.el xdisp.c -Kazushi Marukawa: changed filelock.c hexl.c unexalpha.c +Kazushi Marukawa: changed filelock.c hexl.c profile.c unexalpha.c Keiichi Suzuki: changed nntp.el @@ -3509,12 +3508,12 @@ Kim F. Storm: wrote bindat.el cua-base.el cua-gmrk.el cua-rect.el ido.el and changed xdisp.c dispextern.h process.c simple.el window.c keyboard.c xterm.c dispnew.c subr.el w32term.c lisp.h fringe.c display.texi macterm.c alloc.c fns.c xfaces.c keymap.c xfns.c xterm.h .gdbinit - and 248 other files + and 249 other files Kimit Yada: changed copyright.el Kim-Minh Kaplan: changed gnus-picon.el gnus-sum.el gnus-start.el - gnus-win.el gnus-xmas.el gnus.texi message.el net/imap.el nndraft.el + gnus-win.el gnus-xmas.el gnus.texi imap.el message.el nndraft.el nnml.el Kira Bruneau: changed files.el pgtk-win.el @@ -3559,10 +3558,10 @@ Konrad Hinsen: wrote ol-eshell.el and changed ob-python.el Konstantin Kharlamov: changed smerge-mode.el diff-mode.el files.el - alloc.c autorevert.el calc-aent.el calc-ext.el calc-lang.el cc-mode.el - cperl-mode.el css-mode.el cua-rect.el dnd.el ebnf-abn.el ebnf-dtd.el - ebnf-ebx.el emacs-module-tests.el epg.el faces.el gnus-art.el gtkutil.c - and 30 other files + ada-mode.el alloc.c autorevert.el calc-aent.el calc-ext.el calc-lang.el + cc-mode.el cperl-mode.el css-mode.el cua-rect.el dnd.el ebnf-abn.el + ebnf-dtd.el ebnf-ebx.el emacs-module-tests.el epg.el faces.el + gnus-art.el and 31 other files Konstantin Kliakhandler: changed org-agenda.el @@ -3647,7 +3646,7 @@ and co-wrote gnus-kill.el gnus-mh.el gnus-msg.el gnus-score.el and changed subr.el simple.el gnus.texi files.el display.texi process.c help-fns.el text.texi image.c dired.el help.el image.el package.el edebug.el shortdoc.el dired-aux.el gnutls.c minibuffer.el subr-x.el - auth-source.el smtpmail.el and 1063 other files + auth-source.el smtpmail.el and 1061 other files Lars Rasmusson: changed ebrowse.c @@ -3683,11 +3682,11 @@ Lele Gaifax: changed progmodes/python.el TUTORIAL.it python-tests.el flymake-proc.el flymake.texi isearch.el pgtkfns.c xterm.c Lennart Borgman: co-wrote ert-x.el -and changed nxml-mode.el tutorial.el re-builder.el window.el buff-menu.el - emacs-lisp/debug.el emacsclient.c filesets.el flymake.el help-fns.el - isearch.el linum.el lisp-mode.el lisp.el mouse.el progmodes/grep.el - recentf.el remember.el replace.el reveal.el ruby-mode.el - and 5 other files +and changed nxml-mode.el tutorial.el re-builder.el window.el ada-xref.el + buff-menu.el emacs-lisp/debug.el emacsclient.c filesets.el flymake.el + help-fns.el isearch.el linum.el lisp-mode.el lisp.el mouse.el + progmodes/grep.el recentf.el remember.el replace.el reveal.el + and 6 other files Lennart Staflin: changed dired.el diary-ins.el diary-lib.el tq.el xdisp.c @@ -3790,7 +3789,7 @@ Lute Kamstra: changed modes.texi emacs-lisp/debug.el generic-x.el generic.el font-lock.el simple.el subr.el battery.el debugging.texi easy-mmode.el elisp.texi emacs-lisp/generic.el hl-line.el info.el octave.el basic.texi bindings.el calc.el cmdargs.texi diff-mode.el - doclicense.texi and 288 other files + doclicense.texi and 289 other files Lynn Slater: wrote help-macro.el @@ -3952,7 +3951,7 @@ and changed cus-edit.el files.el progmodes/compile.el rmail.el tex-mode.el find-func.el rmailsum.el simple.el cus-dep.el dired.el mule-cmds.el rmailout.el checkdoc.el configure.ac custom.el emacsbug.el gnus.el help-fns.el ls-lisp.el mwheel.el sendmail.el - and 124 other files + and 126 other files Markus Sauermann: changed lisp-mode.el @@ -4001,7 +4000,7 @@ Martin Pohlack: changed iimage.el pc-select.el Martin Rudalics: changed window.el window.c windows.texi frame.c xdisp.c xterm.c frames.texi w32fns.c w32term.c xfns.c frame.el display.texi frame.h help.el cus-start.el buffer.c window.h mouse.el dispnew.c - keyboard.c nsfns.m and 215 other files + keyboard.c nsfns.m and 216 other files Martin Stjernholm: wrote cc-bytecomp.el and co-wrote cc-align.el cc-cmds.el cc-compat.el cc-defs.el cc-engine.el @@ -4058,7 +4057,7 @@ Mats Lidell: changed TUTORIAL.sv european.el gnus-art.el org-element.el Matt Armstrong: changed itree.c buffer-tests.el itree.h buffer.c alloc.c buffer.h display.texi editfns.c filelock-tests.el package.el pdumper.c .clang-format coding.c commands.texi eval.c filelock.c files.el - gnus-topic.el gnus.el lisp-mnt.el lisp.h and 12 other files + gnus-topic.el gnus.el imap.el lisp-mnt.el and 12 other files Matt Beshara: changed js.el nsfns.m @@ -4175,7 +4174,7 @@ and changed tramp.texi tramp-adb.el trampver.el trampver.texi files.el dbusbind.c gitlab-ci.yml files.texi ange-ftp.el file-notify-tests.el dbus.texi Dockerfile.emba autorevert.el tramp-container.el tramp-fish.el kqueue.c os.texi files-x.el shell.el simple.el README - and 329 other files + and 330 other files Michael Ben-Gershon: changed acorn.h configure.ac riscix1-1.h riscix1-2.h unexec.c @@ -4391,7 +4390,7 @@ Miles Bader: wrote button.el face-remap.el image-file.el macroexp.el and changed comint.el faces.el simple.el editfns.c xfaces.c xdisp.c info.el minibuf.c display.texi quick-install-emacs wid-edit.el xterm.c dispextern.h subr.el window.el cus-edit.el diff-mode.el xfns.c - bytecomp.el help.el lisp.h and 271 other files + bytecomp.el help.el lisp.h and 272 other files Milton Wulei: changed gdb-ui.el @@ -4457,7 +4456,7 @@ Nacho Barrientos: changed url-http.el bindat-tests.el bindat.el Nachum Dershowitz: co-wrote cal-hebrew.el Nagy Andras: co-wrote gnus-sieve.el -and changed net/imap.el gnus.el +and changed imap.el gnus.el Nakagawa Makoto: changed ldap.el @@ -4580,7 +4579,7 @@ and changed README authors.el configure.ac sed2v2.inp sequences.texi README.W32 emacs.png HISTORY emacs23.png arc-mode.el cl-extra.el emacs.svg manoj-dark-theme.el Emacs.icns Makefile.in auth-source.el emacs.ico fns.c make-tarball.txt obarray-tests.el obarray.el - and 36 other files + and 37 other files Nicolas Richard: wrote cl-seq-tests.el cmds-tests.el replace-tests.el and changed ffap.el package.el use-package.el byte-run.el help.el @@ -4771,7 +4770,7 @@ and co-wrote cal-dst.el and changed lisp.h configure.ac alloc.c fileio.c process.c editfns.c sysdep.c xdisp.c fns.c image.c data.c emacs.c keyboard.c lread.c xterm.c eval.c gnulib-comp.m4 merge-gnulib callproc.c Makefile.in - buffer.c and 1887 other files + buffer.c and 1892 other files Paul Fisher: changed fns.c @@ -4799,7 +4798,7 @@ Paul Reilly: changed dgux.h lwlib-Xm.c lwlib.c xlwmenu.c configure.ac lwlib/Makefile.in mail/rmailmm.el rmailedit.el rmailkwd.el and 10 other files -Paul Rivier: changed mixal-mode.el reftex-vars.el reftex.el +Paul Rivier: changed ada-mode.el mixal-mode.el reftex-vars.el reftex.el Paul Rubin: changed config.h sun2.h texinfmt.el window.c @@ -4821,7 +4820,7 @@ Pavel Janík: co-wrote eudc-bob.el eudc-export.el eudc-hotlist.el and changed keyboard.c xterm.c COPYING xdisp.c process.c emacs.c lisp.h menu-bar.el ldap.el make-dist xfns.c buffer.c coding.c eval.c fileio.c flyspell.el fns.c indent.c Makefile.in callint.c cus-start.el - and 697 other files + and 702 other files Pavel Kobiakov: wrote flymake-proc.el flymake.el and changed flymake.texi @@ -5177,7 +5176,7 @@ Reiner Steib: wrote gmm-utils.el and changed message.el gnus.texi gnus-art.el gnus-sum.el gnus-group.el gnus.el mml.el gnus-faq.texi mm-util.el gnus-score.el message.texi gnus-msg.el gnus-start.el gnus-util.el spam-report.el mm-uu.el spam.el - mm-decode.el files.el gnus-agent.el nnmail.el and 171 other files + mm-decode.el files.el gnus-agent.el nnmail.el and 170 other files Remek Trzaska: changed gnus-ems.el @@ -5197,9 +5196,9 @@ and changed vhdl-mode.texi Reuben Thomas: changed ispell.el whitespace.el dired-x.el files.el sh-script.el emacsclient-tests.el remember.el README emacsclient.c - misc.texi msdos.c simple.el INSTALL alloc.c arc-mode.el authors.el - config.bat copyright cperl-mode.el dired-x.texi dired.el - and 36 other files + misc.texi msdos.c simple.el INSTALL ada-mode.el ada-xref.el alloc.c + arc-mode.el authors.el config.bat copyright cperl-mode.el + and 38 other files Ricardo Martins: changed eglot.el @@ -5248,7 +5247,7 @@ and co-wrote cc-align.el cc-cmds.el cc-defs.el cc-engine.el cc-langs.el and changed files.el keyboard.c simple.el xterm.c xdisp.c rmail.el fileio.c process.c sysdep.c buffer.c xfns.c window.c subr.el configure.ac startup.el sendmail.el emacs.c Makefile.in editfns.c - info.el dired.el and 1336 other files + info.el dired.el and 1339 other files Richard Ryniker: changed sendmail.el @@ -5283,7 +5282,7 @@ Robert Cochran: changed tab-bar.el bytecomp.el checkdoc.el data.c Robert Fenk: changed desktop.el -Robert Jarzmik: changed ede/linux.el lisp/obsolete/inversion.el +Robert Jarzmik: changed ede/linux.el inversion.el Robert J. Chassell: wrote makeinfo.el page-ext.el texinfo.el texnfo-upd.el @@ -5320,7 +5319,6 @@ Rob Kaut: changed vhdl-mode.el Rob Riepel: wrote tpu-edt.doc tpu-edt.el tpu-extras.el tpu-mapper.el vt-control.el -and changed lisp/obsolete/vt-control.el Roderick Schertler: changed dgux.h dgux4.h gud.el sysdep.c @@ -5382,9 +5380,10 @@ R Primus: changed eglot.el Rüdiger Sonderfeld: wrote inotify-tests.el reftex-tests.el and changed eww.el octave.el shr.el bibtex.el configure.ac - misc/Makefile.in reftex-vars.el vc-git.el TUTORIAL.de autoinsert.el - building.texi bytecomp.el calc-lang.el cc-langs.el dired.texi editfns.c - emacs.c emacs.texi epa.el erc.el eww.texi and 39 other files + misc/Makefile.in reftex-vars.el vc-git.el TUTORIAL.de ada-mode.el + autoinsert.el building.texi bytecomp.el calc-lang.el cc-langs.el + dired.texi editfns.c emacs.c emacs.texi epa.el erc.el + and 40 other files Rudi Schlatte: changed iso-transl.el @@ -5457,7 +5456,7 @@ Sam Steingold: wrote gulp.el midnight.el and changed progmodes/compile.el cl-indent.el simple.el vc-cvs.el vc.el mouse.el vc-hg.el files.el gnus-sum.el tex-mode.el etags.el font-lock.el sgml-mode.el subr.el window.el ange-ftp.el inf-lisp.el - message.el package.el rcirc.el shell.el and 214 other files + message.el package.el rcirc.el shell.el and 216 other files Samuel Bronson: changed custom.el emacsclient.c keyboard.c progmodes/grep.el semantic/format.el unexmacosx.c @@ -5682,11 +5681,10 @@ Simon Josefsson: wrote dig.el dns-mode.el flow-fill.el fringe.el imap.el url-imap.el and co-wrote gnus-sieve.el gssapi.el mml1991.el nnfolder.el nnimap.el nnml.el rot13.el sieve-manage.el -and changed message.el gnus-sum.el net/imap.el gnus-art.el smtpmail.el - pgg-gpg.el pgg.el gnus-agent.el mml2015.el mml.el gnus-group.el - mm-decode.el gnus-msg.el gnus.texi pgg-pgp5.el browse-url.el - gnus-int.el gnus.el hashcash.el mm-view.el password.el - and 100 other files +and changed message.el gnus-sum.el gnus-art.el smtpmail.el pgg-gpg.el + pgg.el gnus-agent.el mml2015.el mml.el gnus-group.el mm-decode.el + gnus-msg.el gnus.texi pgg-pgp5.el browse-url.el gnus-int.el gnus.el + hashcash.el mm-view.el password.el gnus-cache.el and 99 other files Simon Lang: changed building.texi icomplete.el misterioso-theme.el progmodes/grep.el @@ -5771,7 +5769,7 @@ and co-wrote font-lock.el gitmerge.el pcvs.el visual-wrap.el and changed subr.el simple.el cl-macs.el bytecomp.el keyboard.c files.el lisp.h vc.el eval.c xdisp.c alloc.c buffer.c sh-script.el help-fns.el progmodes/compile.el tex-mode.el lread.c keymap.c package.el window.c - edebug.el and 1724 other files + edebug.el and 1726 other files Stefano Facchini: changed gtkutil.c @@ -5787,7 +5785,7 @@ Stefan-W. Hahn: changed org-bibtex.el ps-print.el simple.el subr.el Stefan Wiens: changed gnus-sum.el -Steinar Bang: changed gnus-setup.el net/imap.el +Steinar Bang: changed gnus-setup.el imap.el Štěpán Němec: changed loadhist.el files.el gnus-sum.el loading.texi subr.el INSTALL calc-ext.el checkdoc.el cl.texi comint.el edebug.texi @@ -5831,11 +5829,11 @@ and changed time-stamp.el time-stamp-tests.el mh-e.el mh-utils-tests.el Stephen J. Turnbull: changed ediff-init.el strings.texi subr.el Stephen Leake: wrote elisp-mode-tests.el -and changed elisp-mode.el xref.el eglot.el window.el mode-local.el - project.el CONTRIBUTE vc-mtn.el cedet-global.el ede/generic.el - simple.el autoload.el bytecomp.el cl-generic.el ede/locate.el - files.texi functions.texi package.el progmodes/grep.el windows.texi - INSTALL.REPO and 32 other files +and changed ada-mode.el ada-xref.el elisp-mode.el xref.el eglot.el + window.el mode-local.el project.el CONTRIBUTE ada-prj.el vc-mtn.el + ada-stmt.el cedet-global.el ede/generic.el simple.el autoload.el + bytecomp.el cl-generic.el ede/locate.el files.texi functions.texi + and 36 other files Stephen Pegoraro: changed xterm.c @@ -6036,7 +6034,7 @@ and co-wrote hideshow.el and changed ewoc.el vc.el info.el processes.texi zone.el lisp-mode.el scheme.el text.texi vc-rcs.el display.texi fileio.c files.el vc-git.el TUTORIAL.it bindat.el cc-vars.el configure.ac dcl-mode.el diff-mode.el - dired.el elisp.texi and 167 other files + dired.el elisp.texi and 169 other files Thierry Banel: co-wrote ob-C.el and changed calc-arith.el @@ -6339,6 +6337,9 @@ Ulrich Ölmann: changed misc.texi Ulrik Vieth: wrote meta-mode.el and changed files.el +Umut Tuna Akgül: changed tabulated-list.el cal-julian-tests.el + cl-preloaded.el image-file.el parse-time.el rcirc.el + Ury Marshak: changed nsfns.m Usami Kenta: changed browse-url.el eglot.el htmlfontify.el @@ -6628,8 +6629,7 @@ Yilkal Argaw: changed manoj-dark-theme.el Yoav Marco: changed sqlite-mode.el -Yoichi Nakayama: changed browse-url.el finder.el - lisp/obsolete/mail/rfc2368.el man.el +Yoichi Nakayama: changed browse-url.el finder.el man.el rfc2368.el Yong Lu: changed charset.c coding.c language/greek.el From 48f9d6aafea0a9790d1f78d4a4037cbcff4f799a Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Sun, 16 Feb 2025 11:00:46 +0100 Subject: [PATCH 12/56] * lisp/man.el (Man-shell-file-name): Ensure a Bourne shell. (Bug#75308) --- lisp/man.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/man.el b/lisp/man.el index 75f87feb8e8..dcfab8d2035 100644 --- a/lisp/man.el +++ b/lisp/man.el @@ -578,9 +578,9 @@ Otherwise, the value is whatever the function (defun Man-shell-file-name () "Return a proper shell file name, respecting remote directories." - (or ; This works also in the local case. + (if (connection-local-p shell-file-name) (connection-local-value shell-file-name) - "/bin/sh")) + "/bin/sh")) (defun Man-header-file-path () "Return the C header file search path that Man should use. From 504bdce73168257af14cd3b0200638fe9dd5c367 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Sun, 16 Feb 2025 11:49:16 -0500 Subject: [PATCH 13/56] (set-auto-mode--find-matching-alist-entry): Fix bug#75961 * lisp/files.el (set-auto-mode--find-matching-alist-entry): Run the MODE found in (REGEXP MODE t) before we replace it with something else. * test/lisp/files-tests.el (files-tests--bug75961): New test. --- lisp/files.el | 50 ++++++++++++++++++++++++---------------- test/lisp/files-tests.el | 16 +++++++++++++ 2 files changed, 46 insertions(+), 20 deletions(-) diff --git a/lisp/files.el b/lisp/files.el index a71d0c5c9d0..bf05939ebeb 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -3469,27 +3469,37 @@ Also applies to `magic-fallback-mode-alist'.") If CASE-INSENSITIVE, the file system of file NAME is case-insensitive." (let (mode) (while name - (setq mode - (if case-insensitive - ;; Filesystem is case-insensitive. - (let ((case-fold-search t)) + (let ((newmode + (if case-insensitive + ;; Filesystem is case-insensitive. + (let ((case-fold-search t)) + (assoc-default name alist 'string-match)) + ;; Filesystem is case-sensitive. + (or + ;; First match case-sensitively. + (let ((case-fold-search nil)) (assoc-default name alist 'string-match)) - ;; Filesystem is case-sensitive. - (or - ;; First match case-sensitively. - (let ((case-fold-search nil)) - (assoc-default name alist 'string-match)) - ;; Fallback to case-insensitive match. - (and auto-mode-case-fold - (let ((case-fold-search t)) - (assoc-default name alist 'string-match)))))) - (if (and mode - (not (functionp mode)) - (consp mode) - (cadr mode)) - (setq mode (car mode) - name (substring name 0 (match-beginning 0))) - (setq name nil))) + ;; Fallback to case-insensitive match. + (and auto-mode-case-fold + (let ((case-fold-search t)) + (assoc-default name alist 'string-match))))))) + (when newmode + (when mode + ;; We had already found a mode but in a (REGEXP MODE t) + ;; entry, so we still have to run MODE. Let's do it now. + ;; FIXME: It's kind of ugly to run the function here. + ;; An alternative could be to return a list of functions and + ;; callers. + (set-auto-mode-0 mode t)) + (setq mode newmode)) + (if (and newmode + (not (functionp newmode)) + (consp newmode) + (cadr newmode)) + ;; It's a (REGEXP MODE t): Keep looking but remember the MODE. + (setq mode (car newmode) + name (substring name 0 (match-beginning 0))) + (setq name nil)))) mode)) (defun set-auto-mode--apply-alist (alist keep-mode-if-same dir-local) diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el index 5e2c4eb2669..7f06c37a408 100644 --- a/test/lisp/files-tests.el +++ b/test/lisp/files-tests.el @@ -1680,6 +1680,22 @@ The door of all subtleties! (should-not (eq (files-tests--check-mode "gdbinit.5") #'gdb-script-mode)) (should-not (eq (files-tests--check-mode ".gdbinit.py.in") #'gdb-script-mode))) +(ert-deftest files-tests--bug75961 () + (let* ((auto-mode-alist (cons '("\\.text\\'" text-mode t) auto-mode-alist)) + (called-fun nil) + (fun (lambda () (setq called-fun t)))) + (with-temp-buffer + (setq buffer-file-name "foo.text") + (normal-mode) + (should (derived-mode-p 'text-mode)) + (add-hook 'text-mode-hook fun) + (setq buffer-file-name "foo.html.text") + (should (not called-fun)) + (normal-mode) + (remove-hook 'text-mode-hook fun) + (should called-fun) + (should (derived-mode-p 'html-mode))))) + (defvar sh-shell) (defun files-tests--check-shebang (shebang expected-mode &optional expected-dialect) From e8470b79f1d56c4c887c0b5d2c326ad6449cbbea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Sun, 16 Feb 2025 13:52:28 +0000 Subject: [PATCH 14/56] Eglot: Improve fix to bug#66144 The :exit notification should also take an empty JSON object instead of JSON null as its parameters. * lisp/progmodes/eglot.el (eglot-shutdown): Use eglot--{} in :exit notifcation, too. --- lisp/progmodes/eglot.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index afa7d7b7e54..bd28174e7da 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -1259,7 +1259,7 @@ SERVER." (progn (setf (eglot--shutdown-requested server) t) (eglot--request server :shutdown eglot--{} :timeout (or timeout 1.5)) - (jsonrpc-notify server :exit nil)) + (jsonrpc-notify server :exit eglot--{})) ;; Now ask jsonrpc.el to shut down the server. (jsonrpc-shutdown server (not preserve-buffers)) (unless preserve-buffers (kill-buffer (jsonrpc-events-buffer server))))) From fc189cb83cf7284344a737e75b3ee56487b1c386 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?El=C3=ADas=20Gabriel=20P=C3=A9rez?= Date: Sun, 16 Feb 2025 13:21:52 -0600 Subject: [PATCH 15/56] Add gtk-redo icon to x-gtk-stock-map * lisp/term/pgtk-win.el (x-gtk-stock-map): Add gtk-redo. (Bug#76349) --- lisp/term/pgtk-win.el | 1 + 1 file changed, 1 insertion(+) diff --git a/lisp/term/pgtk-win.el b/lisp/term/pgtk-win.el index fe9807f8c52..1c15234c49c 100644 --- a/lisp/term/pgtk-win.el +++ b/lisp/term/pgtk-win.el @@ -194,6 +194,7 @@ EVENT is a `preedit-text' event." ("etc/images/save" . ("document-save" "gtk-save")) ("etc/images/saveas" . ("document-save-as" "gtk-save-as")) ("etc/images/undo" . ("edit-undo" "gtk-undo")) + ("etc/images/redo" . ("edit-redo" "gtk-redo")) ("etc/images/cut" . ("edit-cut" "gtk-cut")) ("etc/images/copy" . ("edit-copy" "gtk-copy")) ("etc/images/paste" . ("edit-paste" "gtk-paste")) From 35d4316101752fc45bfd2301d891fb7b64060500 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?El=C3=ADas=20Gabriel=20P=C3=A9rez?= Date: Sun, 16 Feb 2025 13:21:52 -0600 Subject: [PATCH 16/56] Add gtk-redo icon to x-gtk-stock-map to x-win.el * lisp/term/x-win.el (x-gtk-stock-map): Add gtk-redo. --- lisp/term/x-win.el | 1 + 1 file changed, 1 insertion(+) diff --git a/lisp/term/x-win.el b/lisp/term/x-win.el index debcb669b76..91b5bd5838a 100644 --- a/lisp/term/x-win.el +++ b/lisp/term/x-win.el @@ -1383,6 +1383,7 @@ This returns an error if any Emacs frames are X frames." ("etc/images/save" . ("document-save" "gtk-save")) ("etc/images/saveas" . ("document-save-as" "gtk-save-as")) ("etc/images/undo" . ("edit-undo" "gtk-undo")) + ("etc/images/redo" . ("edit-redo" "gtk-redo")) ("etc/images/cut" . ("edit-cut" "gtk-cut")) ("etc/images/copy" . ("edit-copy" "gtk-copy")) ("etc/images/paste" . ("edit-paste" "gtk-paste")) From 9efd11e5fd4324fb1686b802c15ae36046b0939a Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Mon, 17 Feb 2025 01:57:22 +0100 Subject: [PATCH 17/56] Prefer cl-evenp/cl-oddp in some places * lisp/erc/erc.el (erc-format-message): * lisp/obsolete/thumbs.el (thumbs-emboss-image): * lisp/org/org-capture.el (org-capture-escaped-%): * lisp/org/org-element-ast.el (org-element-create): * lisp/org/org-macro.el (org-macro-extract-arguments): * lisp/org/org-persist.el (org-persist--get-collection): * lisp/org/ox-odt.el (org-odt-get-table-cell-styles): * lisp/org/ox.el (org-export--dispatch-ui): * lisp/progmodes/cperl-mode.el (cperl-forward-re) (cperl-find-pods-heres): Prefer 'cl-evenp/'cl-oddp' to free-coding them in some files that already depend on cl-lib in run-time. --- lisp/erc/erc.el | 2 +- lisp/obsolete/thumbs.el | 2 +- lisp/org/org-capture.el | 2 +- lisp/org/org-element-ast.el | 2 +- lisp/org/org-macro.el | 2 +- lisp/org/org-persist.el | 2 +- lisp/org/ox-odt.el | 8 ++++---- lisp/org/ox.el | 4 ++-- lisp/progmodes/cperl-mode.el | 4 ++-- 9 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index 0d72b46360e..e9e643a3df7 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -9735,7 +9735,7 @@ if yet untried." "Format MSG according to ARGS. See also `format-spec'." - (when (eq (logand (length args) 1) 1) ; oddp + (unless (cl-evenp (length args)) (error "Obscure usage of this function appeared")) (let ((entry (erc-retrieve-catalog-entry msg))) (when (not entry) diff --git a/lisp/obsolete/thumbs.el b/lisp/obsolete/thumbs.el index 582bb7f0caf..a4f28ce97c5 100644 --- a/lisp/obsolete/thumbs.el +++ b/lisp/obsolete/thumbs.el @@ -628,7 +628,7 @@ ACTION and ARG should be a valid convert command." (defun thumbs-emboss-image (emboss) "Emboss the image with value EMBOSS." (interactive "nEmboss value: ") - (if (or (< emboss 3) (> emboss 31) (zerop (% emboss 2))) + (if (or (< emboss 3) (> emboss 31) (cl-evenp emboss)) (error "Arg must be an odd number between 3 and 31")) (thumbs-modify-image "emboss" (number-to-string emboss))) diff --git a/lisp/org/org-capture.el b/lisp/org/org-capture.el index 0720ad53cc7..d4ae0207c36 100644 --- a/lisp/org/org-capture.el +++ b/lisp/org/org-capture.el @@ -1920,7 +1920,7 @@ placeholder to check." (goto-char (match-beginning 0)) (let ((n (abs (skip-chars-backward "\\\\")))) (delete-char (/ (1+ n) 2)) - (= (% n 2) 1)))) + (cl-oddp n)))) (defun org-capture-expand-embedded-elisp (&optional mark) "Evaluate embedded elisp %(sexp) and replace with the result. diff --git a/lisp/org/org-element-ast.el b/lisp/org/org-element-ast.el index b91cf9fc65c..2322bc69fc4 100644 --- a/lisp/org/org-element-ast.el +++ b/lisp/org/org-element-ast.el @@ -734,7 +734,7 @@ string. Alternatively, TYPE can be a string. When TYPE is nil or (cl-assert ;; FIXME: Just use `plistp' from Emacs 29 when available. (let ((len (proper-list-p props))) - (and len (zerop (% len 2))))) + (and len (cl-evenp len)))) ;; Assign parray. (when (and props (not (stringp type)) (not (eq type 'plain-text))) (let ((node (list 'dummy props))) diff --git a/lisp/org/org-macro.el b/lisp/org/org-macro.el index 66ae4d7af68..500dfbc545d 100644 --- a/lisp/org/org-macro.el +++ b/lisp/org/org-macro.el @@ -329,7 +329,7 @@ Return a list of arguments, as strings. This is the opposite of (lambda (str) (let ((len (length (match-string 1 str)))) (concat (make-string (/ len 2) ?\\) - (if (zerop (mod len 2)) "\000" ",")))) + (if (cl-evenp len) "\000" ",")))) s nil t) "\000")) diff --git a/lisp/org/org-persist.el b/lisp/org/org-persist.el index 104ad86d527..16ac13ae872 100644 --- a/lisp/org/org-persist.el +++ b/lisp/org/org-persist.el @@ -594,7 +594,7 @@ MISC, if non-nil will be appended to the collection. It must be a plist." (unless (and (listp container) (listp (car container))) (setq container (list container))) (setq associated (org-persist--normalize-associated associated)) - (when (and misc (or (not (listp misc)) (= 1 (% (length misc) 2)))) + (when (and misc (or (not (listp misc)) (cl-oddp (length misc)))) (error "org-persist: Not a plist: %S" misc)) (or (org-persist--find-index `( :container ,(org-persist--normalize-container container) diff --git a/lisp/org/ox-odt.el b/lisp/org/ox-odt.el index ba8b4d9d3bb..04c70c5b563 100644 --- a/lisp/org/ox-odt.el +++ b/lisp/org/ox-odt.el @@ -3293,13 +3293,13 @@ styles congruent with the ODF-1.2 specification." (= (1+ r) (car table-dimensions))) "LastRow") ((and (cdr (assq 'use-banding-rows-styles cell-style-selectors)) - (= (% r 2) 1)) "EvenRow") + (cl-oddp r)) "EvenRow") ((and (cdr (assq 'use-banding-rows-styles cell-style-selectors)) - (= (% r 2) 0)) "OddRow") + (cl-evenp r)) "OddRow") ((and (cdr (assq 'use-banding-columns-styles cell-style-selectors)) - (= (% c 2) 1)) "EvenColumn") + (cl-oddp c)) "EvenColumn") ((and (cdr (assq 'use-banding-columns-styles cell-style-selectors)) - (= (% c 2) 0)) "OddColumn") + (cl-evenp c)) "OddColumn") (t "")))) (concat template-name cell-type))))) diff --git a/lisp/org/ox.el b/lisp/org/ox.el index 7f3f66a6f26..a2a21a72c42 100644 --- a/lisp/org/ox.el +++ b/lisp/org/ox.el @@ -7287,14 +7287,14 @@ back to standard interface." (lambda (sub-entry) (cl-incf index) (format - (if (zerop (mod index 2)) " [%s] %-26s" + (if (cl-evenp index) " [%s] %-26s" "[%s] %s\n") (funcall fontify-key (char-to-string (car sub-entry)) top-key) (nth 1 sub-entry))) sub-menu "") - (when (zerop (mod index 2)) "\n")))))))) + (when (cl-evenp index) "\n")))))))) entries "")) ;; Publishing menu is hard-coded. (format "\n[%s] Publish diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el index e1ec4880058..e75cfd85c5f 100644 --- a/lisp/progmodes/cperl-mode.el +++ b/lisp/progmodes/cperl-mode.el @@ -3825,7 +3825,7 @@ modify syntax-type text property if the situation is too hard." (char-after (- (point) 2))) (save-excursion (forward-char -2) - (= 0 (% (skip-chars-backward "\\\\") 2))) + (cl-evenp (skip-chars-backward "\\\\"))) (forward-char -1))) ;; Now we are after the first part. (and is-2arg ; Have trailing part @@ -5164,7 +5164,7 @@ recursive calls in starting lines of here-documents." (or ; Should work with delim = \ (not (eq (preceding-char) ?\\ )) ;; XXXX Double \\ is needed with 19.33 - (= (% (skip-chars-backward "\\\\") 2) 0)) + (cl-evenp (skip-chars-backward "\\\\"))) (looking-at (cond ((eq (char-after b) ?\] ) From b417c0abebfa68d37dd07160b81ce5f7da6dd431 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Mon, 17 Feb 2025 02:04:31 +0100 Subject: [PATCH 18/56] Address FIXME in org-element-create * lisp/org/org-element-ast.el (org-element-create): Address FIXME. --- lisp/org/org-element-ast.el | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lisp/org/org-element-ast.el b/lisp/org/org-element-ast.el index 2322bc69fc4..60ecf34108c 100644 --- a/lisp/org/org-element-ast.el +++ b/lisp/org/org-element-ast.el @@ -731,10 +731,10 @@ a newly created one. When TYPE is `plain-text', CHILDREN must contain a single node - string. Alternatively, TYPE can be a string. When TYPE is nil or `anonymous', PROPS must be nil." - (cl-assert - ;; FIXME: Just use `plistp' from Emacs 29 when available. - (let ((len (proper-list-p props))) - (and len (cl-evenp len)))) + (cl-assert (if (fboundp 'plistp) ; Emacs 29.1 + (plistp props) + (let ((len (proper-list-p props))) + (and len (cl-evenp len))))) ;; Assign parray. (when (and props (not (stringp type)) (not (eq type 'plain-text))) (let ((node (list 'dummy props))) From 0d40deec20fb8e246b2bbc66afdcec37e3eecd4a Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Mon, 17 Feb 2025 01:53:55 +0100 Subject: [PATCH 19/56] Remove some details on which files are loaded from cl.texi * doc/misc/cl.texi (Naming Conventions): Remove section listing functions that do not cause other files than cl-lib.el to be loaded. It lacks practical relevance to the user, and is a hostage to changing implementation details. --- doc/misc/cl.texi | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/doc/misc/cl.texi b/doc/misc/cl.texi index 48b8ea09c65..fbed1265aa3 100644 --- a/doc/misc/cl.texi +++ b/doc/misc/cl.texi @@ -233,32 +233,6 @@ cl-callf cl-callf2 cl-defsubst cl-letf cl-letf* @end example -@c This is not uninteresting I suppose, but is of zero practical relevance -@c to the user, and seems like a hostage to changing implementation details. -The following simple functions and macros are defined in @file{cl-lib.el}; -they do not cause other components like @file{cl-extra} to be loaded. - -@example -cl-evenp cl-oddp cl-minusp -cl-plusp cl-endp cl-subst -cl-copy-list cl-list* cl-ldiff -cl-rest cl-decf [1] cl-incf [1] -cl-acons cl-adjoin [2] cl-pairlis -cl-pushnew [1,2] cl-declaim cl-proclaim -cl-caaar@dots{}cl-cddddr cl-first@dots{}cl-tenth -cl-mapcar [3] -@end example - -@noindent -[1] Only when @var{place} is a plain variable name. - -@noindent -[2] Only if @code{:test} is @code{eq}, @code{equal}, or unspecified, -and @code{:key} is not used. - -@noindent -[3] Only for one sequence argument or two list arguments. - @node Printing @chapter Printing From e779d60ea1d490f22cb5d0d729abedff8dc909d3 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Mon, 17 Feb 2025 02:14:17 +0100 Subject: [PATCH 20/56] ; * etc/symbol-releases.eld: Add plistp. --- etc/symbol-releases.eld | 1 + 1 file changed, 1 insertion(+) diff --git a/etc/symbol-releases.eld b/etc/symbol-releases.eld index 21bbe3c793c..645ab77972d 100644 --- a/etc/symbol-releases.eld +++ b/etc/symbol-releases.eld @@ -9,6 +9,7 @@ ;; TYPE being `fun' or `var'. ( + ("29.1" fun plistp) ("28.1" fun always) ("26.1" fun when-let*) ("26.1" fun and-let*) From f2fb19d008f57d83053e7981eecded6ace9ab6c7 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Mon, 17 Feb 2025 02:21:26 +0100 Subject: [PATCH 21/56] Add test for zerop * test/lisp/subr-tests.el (subr-test-zerop): New test. --- test/lisp/subr-tests.el | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el index 5b17c598efa..29767ed07b5 100644 --- a/test/lisp/subr-tests.el +++ b/test/lisp/subr-tests.el @@ -30,6 +30,21 @@ (require 'ert-x) (eval-when-compile (require 'cl-lib)) +(ert-deftest subr-test-zerop () + (should (zerop 0)) + (should (zerop 0.0)) + (should (zerop -0)) + (should (zerop -0.0)) + (should-not (zerop -0.0e+NaN)) + (should-not (zerop 0.0e+NaN)) + (should-not (zerop float-pi)) + (should-not (zerop 1.0e+INF)) + (should-not (zerop (random most-positive-fixnum))) + (should-not (zerop (- (random (- most-negative-fixnum))))) + (should-not (zerop (1+ most-positive-fixnum))) + (should-not (zerop (1- most-negative-fixnum))) + (should-error (zerop "-5") :type 'wrong-type-argument)) + (ert-deftest let-when-compile () ;; good case (should (equal (macroexpand '(let-when-compile ((foo (+ 2 3))) From e34ea5db5f1c09582e3779828ba248eec5769eb2 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Mon, 17 Feb 2025 10:56:37 +0800 Subject: [PATCH 22/56] * src/pgtkterm.c (pgtk_enumerate_devices): Circumvent bug#76239. --- src/pgtkterm.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/pgtkterm.c b/src/pgtkterm.c index 321514fbf79..617ed3c5135 100644 --- a/src/pgtkterm.c +++ b/src/pgtkterm.c @@ -181,13 +181,27 @@ pgtk_enumerate_devices (struct pgtk_display_info *dpyinfo, { rec = xmalloc (sizeof *rec); rec->seat = g_object_ref (seat); - rec->device = GDK_DEVICE (t1->data); - snprintf (printbuf, 1026, "%u:%s", - gdk_device_get_source (rec->device), - gdk_device_get_name (rec->device)); + if (t1->data) + { + rec->device = GDK_DEVICE (t1->data); + snprintf (printbuf, 1026, "%u:%s", + gdk_device_get_source (rec->device), + gdk_device_get_name (rec->device)); + + rec->name = build_string (printbuf); + } + else + { + /* GTK bug 7737 results in GDK seats being initialized + with NULL devices in some cirumstances. As events will + presumably also be delivered with their device fields + set to NULL, insert a ersatz device record associated + with NULL. (bug#76239) */ + rec->device = NULL; + rec->name = build_string ("0:unknown device"); + } - rec->name = build_string (printbuf); rec->next = dpyinfo->devices; dpyinfo->devices = rec; } From e3dc0ea2544dc09908546c6e6baba47371cbc176 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Mon, 17 Feb 2025 11:33:50 +0800 Subject: [PATCH 23/56] Fix crash in frame deletion on Android * java/org/gnu/emacs/EmacsWindow.java (destroyHandle): Invalidate the input focus in the UI thread, as is proper. --- java/org/gnu/emacs/EmacsWindow.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/java/org/gnu/emacs/EmacsWindow.java b/java/org/gnu/emacs/EmacsWindow.java index f935850b22b..fec95526835 100644 --- a/java/org/gnu/emacs/EmacsWindow.java +++ b/java/org/gnu/emacs/EmacsWindow.java @@ -271,20 +271,26 @@ private static class Coordinate } } - EmacsActivity.invalidateFocus (4); - + /* This is just a sanity test and is not reliable since `children' + may be modified between isEmpty and handle destruction. */ if (!children.isEmpty ()) throw new IllegalStateException ("Trying to destroy window with " + "children!"); /* Remove the view from its parent and make it invisible. */ EmacsService.SERVICE.runOnUiThread (new Runnable () { + @Override public void run () { ViewManager parent; EmacsWindowManager manager; + /* Invalidate the focus; this should transfer the input focus + to the next eligible window as this window is no longer + present in parent.children. */ + EmacsActivity.invalidateFocus (4); + if (EmacsActivity.focusedWindow == EmacsWindow.this) EmacsActivity.focusedWindow = null; From 0a6997b58d417043406dadf3d40e6f9de9ded6a8 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Mon, 17 Feb 2025 11:32:43 +0800 Subject: [PATCH 24/56] Synchronize frame placement logic with X * src/androidterm.c (android_calc_absolute_position): New function. (android_set_offset): Call android_calc_absolute_position. * src/pgtkterm.c (pgtk_calc_absolute_position): Synchronize with X. --- src/androidterm.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++ src/pgtkterm.c | 6 ++-- 2 files changed, 79 insertions(+), 3 deletions(-) diff --git a/src/androidterm.c b/src/androidterm.c index 3e367b391a8..5951135eaa6 100644 --- a/src/androidterm.c +++ b/src/androidterm.c @@ -2291,6 +2291,81 @@ android_set_window_size (struct frame *f, bool change_gravity, do_pending_window_change (false); } +/* Calculate the absolute position in frame F + from its current recorded position values and gravity. */ + +static void +android_calc_absolute_position (struct frame *f) +{ + int flags = f->size_hint_flags; + struct frame *p = FRAME_PARENT_FRAME (f); + + /* We have nothing to do if the current position + is already for the top-left corner. */ + if (!((flags & XNegative) || (flags & YNegative))) + return; + + /* Treat negative positions as relative to the leftmost bottommost + position that fits on the screen. */ + if (flags & XNegative) + { + int width = FRAME_PIXEL_WIDTH (f); + + /* A frame that has been visible at least once should have outer + edges. */ + if (f->output_data.android->has_been_visible && !p) + { + Lisp_Object frame; + Lisp_Object edges = Qnil; + + XSETFRAME (frame, f); + edges = Fandroid_frame_edges (frame, Qouter_edges); + if (!NILP (edges)) + width = (XFIXNUM (Fnth (make_fixnum (2), edges)) + - XFIXNUM (Fnth (make_fixnum (0), edges))); + } + + if (p) + f->left_pos = (FRAME_PIXEL_WIDTH (p) - width - 2 * f->border_width + + f->left_pos); + else + /* Not that this is of much significance, for Android programs + cannot position their windows at absolute positions in the + screen. */ + f->left_pos = (android_get_screen_width () - width + f->left_pos); + + } + + if (flags & YNegative) + { + int height = FRAME_PIXEL_HEIGHT (f); + + if (f->output_data.android->has_been_visible && !p) + { + Lisp_Object frame; + Lisp_Object edges = Qnil; + + XSETFRAME (frame, f); + if (NILP (edges)) + edges = Fandroid_frame_edges (frame, Qouter_edges); + if (!NILP (edges)) + height = (XFIXNUM (Fnth (make_fixnum (3), edges)) + - XFIXNUM (Fnth (make_fixnum (1), edges))); + } + + if (p) + f->top_pos = (FRAME_PIXEL_HEIGHT (p) - height - 2 * f->border_width + + f->top_pos); + else + f->top_pos = (android_get_screen_height () - height + f->top_pos); + } + + /* The left_pos and top_pos + are now relative to the top and left screen edges, + so the flags should correspond. */ + f->size_hint_flags &= ~(XNegative | YNegative); +} + static void android_set_offset (struct frame *f, int xoff, int yoff, int change_gravity) @@ -2307,6 +2382,7 @@ android_set_offset (struct frame *f, int xoff, int yoff, f->win_gravity = NorthWestGravity; } + android_calc_absolute_position (f); android_move_window (FRAME_ANDROID_WINDOW (f), xoff, yoff); } diff --git a/src/pgtkterm.c b/src/pgtkterm.c index d47b1da7262..095749cbfcc 100644 --- a/src/pgtkterm.c +++ b/src/pgtkterm.c @@ -553,12 +553,12 @@ pgtk_calc_absolute_position (struct frame *f) /* We have nothing to do if the current position is already for the top-left corner. */ - if (! ((flags & XNegative) || (flags & YNegative))) + if (!((flags & XNegative) || (flags & YNegative))) return; /* Treat negative positions as relative to the leftmost bottommost position that fits on the screen. */ - if ((flags & XNegative) && (f->left_pos <= 0)) + if (flags & XNegative) { int width = FRAME_PIXEL_WIDTH (f); @@ -585,7 +585,7 @@ pgtk_calc_absolute_position (struct frame *f) } - if ((flags & YNegative) && (f->top_pos <= 0)) + if (flags & YNegative) { int height = FRAME_PIXEL_HEIGHT (f); From 718a227f0fb926864c5224b5664b4b76c631039f Mon Sep 17 00:00:00 2001 From: Po Lu Date: Mon, 17 Feb 2025 11:36:41 +0800 Subject: [PATCH 25/56] ; Correct merge errors. --- src/pgtkterm.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/pgtkterm.c b/src/pgtkterm.c index 9f76e18f128..1cdf7877f60 100644 --- a/src/pgtkterm.c +++ b/src/pgtkterm.c @@ -193,9 +193,7 @@ pgtk_enumerate_devices (struct pgtk_display_info *dpyinfo, rec->device = GDK_DEVICE (t1->data); source = gdk_device_get_source (rec->device); name = gdk_device_get_name (rec->device); - rec->name = (make_formatted_string ("%u:%s", source, name); - - rec->name = build_string (printbuf); + rec->name = make_formatted_string ("%u:%s", source, name); } else { From 6c1e6ba83c471e6a3c233c611dfe9e88349d5a10 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Mon, 17 Feb 2025 12:02:05 +0800 Subject: [PATCH 26/56] ; * src/androidterm.c (android_set_offset): Apply correct frame offsets. --- src/androidterm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/androidterm.c b/src/androidterm.c index 5951135eaa6..3cb9eab3606 100644 --- a/src/androidterm.c +++ b/src/androidterm.c @@ -2383,7 +2383,8 @@ android_set_offset (struct frame *f, int xoff, int yoff, } android_calc_absolute_position (f); - android_move_window (FRAME_ANDROID_WINDOW (f), xoff, yoff); + android_move_window (FRAME_ANDROID_WINDOW (f), f->left_pos, + f->top_pos); } static void From a951dbcf162aaf06a134c597ca0ac59c479afc4b Mon Sep 17 00:00:00 2001 From: Po Lu Date: Mon, 17 Feb 2025 12:06:15 +0800 Subject: [PATCH 27/56] Implement `(- N)' frame position specifications on Haiku * src/haikuterm.c (haiku_calc_absolute_position): New function. (haiku_set_offset): Apply offsets configured by the said function. --- src/haikuterm.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 80 insertions(+), 1 deletion(-) diff --git a/src/haikuterm.c b/src/haikuterm.c index 4a217c9e0e2..5c0863d3509 100644 --- a/src/haikuterm.c +++ b/src/haikuterm.c @@ -4640,6 +4640,83 @@ haiku_scroll_bar_remove (struct scroll_bar *bar) unblock_input (); }; + + +/* Calculate the absolute position in frame F + from its current recorded position values and gravity. */ + +static void +haiku_calc_absolute_position (struct frame *f) +{ + int flags = f->size_hint_flags; + struct frame *p = FRAME_PARENT_FRAME (f); + int screen_width, screen_height; + + /* We have nothing to do if the current position + is already for the top-left corner. */ + if (!((flags & XNegative) || (flags & YNegative))) + return; + + be_get_screen_dimensions (&screen_width, &screen_height); + + /* Treat negative positions as relative to the leftmost bottommost + position that fits on the screen. */ + if (flags & XNegative) + { + int width = FRAME_PIXEL_WIDTH (f); + + /* A frame that has been visible at least once should have outer + edges. */ + if (!p) + { + Lisp_Object frame; + Lisp_Object edges = Qnil; + + XSETFRAME (frame, f); + edges = Fhaiku_frame_edges (frame, Qouter_edges); + if (!NILP (edges)) + width = (XFIXNUM (Fnth (make_fixnum (2), edges)) + - XFIXNUM (Fnth (make_fixnum (0), edges))); + } + + if (p) + f->left_pos = (FRAME_PIXEL_WIDTH (p) - width - 2 * f->border_width + + f->left_pos); + else + f->left_pos = (screen_width - width + f->left_pos); + + } + + if (flags & YNegative) + { + int height = FRAME_PIXEL_HEIGHT (f); + + if (!p) + { + Lisp_Object frame; + Lisp_Object edges = Qnil; + + XSETFRAME (frame, f); + if (NILP (edges)) + edges = Fhaiku_frame_edges (frame, Qouter_edges); + if (!NILP (edges)) + height = (XFIXNUM (Fnth (make_fixnum (3), edges)) + - XFIXNUM (Fnth (make_fixnum (1), edges))); + } + + if (p) + f->top_pos = (FRAME_PIXEL_HEIGHT (p) - height - 2 * f->border_width + + f->top_pos); + else + f->top_pos = (screen_height - height + f->top_pos); + } + + /* The left_pos and top_pos + are now relative to the top and left screen edges, + so the flags should correspond. */ + f->size_hint_flags &= ~(XNegative | YNegative); +} + void haiku_set_offset (struct frame *frame, int x, int y, int change_gravity) @@ -4673,10 +4750,12 @@ haiku_set_offset (struct frame *frame, int x, int y, } haiku_update_size_hints (frame); + haiku_calc_absolute_position (frame); block_input (); if (change_gravity) - BWindow_set_offset (FRAME_HAIKU_WINDOW (frame), x, y); + BWindow_set_offset (FRAME_HAIKU_WINDOW (frame), frame->left_pos, + frame->top_pos); unblock_input (); } From 667d011410d1ab53fb90a497eb07f0b65c933821 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Mon, 17 Feb 2025 00:52:45 +0100 Subject: [PATCH 28/56] New functions oddp and evenp * lisp/emacs-lisp/cl-lib.el (cl-oddp, cl-evenp): Move from here... * lisp/subr.el (oddp, evenp): ...to here. Make old names into aliases, documented as deprecated. Add type declarations. * lisp/obsolete/cl.el: Don't alias oddp and evenp. * test/lisp/emacs-lisp/cl-lib-tests.el (cl-lib-test-oddp) (cl-lib-test-evenp): Move tests from here... * test/lisp/subr-tests.el (subr-test-oddp, subr-test-evenp): ...to here. * lisp/emacs-lisp/shortdoc.el (number): Add oddp and evenp. (map): Prefer oddp and evenp to cl-oddp and cl-evenp. * doc/lispref/numbers.texi (Predicates on Numbers): Document above new functions oddp and evenp. * doc/misc/cl.texi (Predicates on Numbers): Delete cl-oddp and cl-evenp. (Other Clauses): Prefer oddp to cl-oddp. --- doc/lispref/numbers.texi | 10 ++++++++++ doc/misc/cl.texi | 14 ++------------ etc/NEWS | 6 ++++++ lisp/emacs-lisp/cl-lib.el | 20 ++++++++++---------- lisp/emacs-lisp/shortdoc.el | 24 ++++++++++++------------ lisp/obsolete/cl.el | 2 -- lisp/subr.el | 14 ++++++++++++++ test/lisp/emacs-lisp/cl-lib-tests.el | 20 -------------------- test/lisp/subr-tests.el | 20 ++++++++++++++++++++ 9 files changed, 74 insertions(+), 56 deletions(-) diff --git a/doc/lispref/numbers.texi b/doc/lispref/numbers.texi index fc52f11cf4a..ee43389399a 100644 --- a/doc/lispref/numbers.texi +++ b/doc/lispref/numbers.texi @@ -409,6 +409,16 @@ if so, @code{nil} otherwise. The argument must be a number. @code{(zerop x)} is equivalent to @code{(= x 0)}. @end defun +@defun oddp integer +This predicate tests whether its argument is an odd number, and returns +@code{t} if so, @code{nil} otherwise. The argument must be an integer. +@end defun + +@defun evenp integer +This predicate tests whether its argument is an even number, and returns +@code{t} if so, @code{nil} otherwise. The argument must be an integer. +@end defun + @node Comparison of Numbers @section Comparison of Numbers @cindex number comparison diff --git a/doc/misc/cl.texi b/doc/misc/cl.texi index fbed1265aa3..f481f6f2721 100644 --- a/doc/misc/cl.texi +++ b/doc/misc/cl.texi @@ -2450,7 +2450,7 @@ by the name @code{it} in the ``then'' part. For example: (setq funny-numbers '(6 13 -1)) @result{} (6 13 -1) (cl-loop for x below 10 - if (cl-oddp x) + if (oddp x) collect x into odds and if (memq x funny-numbers) return (cdr it) end else @@ -3055,7 +3055,7 @@ This section defines a few simple Common Lisp operations on numbers that were left out of Emacs Lisp. @menu -* Predicates on Numbers:: @code{cl-plusp}, @code{cl-oddp}, etc. +* Predicates on Numbers:: @code{cl-plusp}, @code{cl-minusp}, etc. * Numerical Functions:: @code{cl-floor}, @code{cl-ceiling}, etc. * Random Numbers:: @code{cl-random}, @code{cl-make-random-state}. * Implementation Parameters:: @code{cl-most-positive-float}, etc. @@ -3078,16 +3078,6 @@ This predicate tests whether @var{number} is negative. It is an error if the argument is not a number. @end defun -@defun cl-oddp integer -This predicate tests whether @var{integer} is odd. It is an -error if the argument is not an integer. -@end defun - -@defun cl-evenp integer -This predicate tests whether @var{integer} is even. It is an -error if the argument is not an integer. -@end defun - @defun cl-digit-char-p char radix Test if @var{char} is a digit in the specified @var{radix} (default is 10). If it is, return the numerical value of digit @var{char} in diff --git a/etc/NEWS b/etc/NEWS index 6d934b2029c..a0d0f8b9818 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1265,6 +1265,12 @@ restore the old behavior, you can set 'eshell-pwd-convert-function' to * Lisp Changes in Emacs 31.1 ++++ +** New functions 'oddp' and 'evenp'. +They return non-nil if an integer is odd or even, respectively, and +signal an error if they are given a non-integer. The 'cl-lib' functions +'cl-oddp' and 'cl-evenp' are now aliases for 'oddp' and 'evenp'. + ** Time & Date +++ diff --git a/lisp/emacs-lisp/cl-lib.el b/lisp/emacs-lisp/cl-lib.el index dba01b28325..1fc36517796 100644 --- a/lisp/emacs-lisp/cl-lib.el +++ b/lisp/emacs-lisp/cl-lib.el @@ -280,17 +280,17 @@ so that they are registered at compile-time as well as run-time." (declare (side-effect-free t)) (< number 0)) -(defun cl-oddp (integer) - "Return t if INTEGER is odd." - (declare (side-effect-free t) - (compiler-macro (lambda (_) `(eq (logand ,integer 1) 1)))) - (eq (logand integer 1) 1)) +(defalias 'cl-oddp #'oddp + "Return t if INTEGER is odd. -(defun cl-evenp (integer) - "Return t if INTEGER is even." - (declare (side-effect-free t) - (compiler-macro (lambda (_) `(eq (logand ,integer 1) 0)))) - (eq (logand integer 1) 0)) +This function is considered deprecated in favor of the built-in function +`evenp' that was added in Emacs 31.1.") + +(defalias 'cl-evenp #'evenp + "Return t if INTEGER is even. + +This function is considered deprecated in favor of the built-in function +`evenp' that was added in Emacs 31.1.") (defconst cl-digit-char-table (let* ((digits (make-vector 256 nil)) diff --git a/lisp/emacs-lisp/shortdoc.el b/lisp/emacs-lisp/shortdoc.el index cc9971b232f..af995123dc5 100644 --- a/lisp/emacs-lisp/shortdoc.el +++ b/lisp/emacs-lisp/shortdoc.el @@ -278,17 +278,17 @@ A FUNC form can have any number of `:no-eval' (or `:no-value'), :args (function map) :eval (map-values-apply #'1+ (list '(1 . 2) '(3 . 4)))) (map-filter - :eval (map-filter (lambda (k _) (cl-oddp k)) (list '(1 . 2) '(4 . 6))) - :eval (map-filter (lambda (k v) (cl-evenp (+ k v))) (list '(1 . 2) '(4 . 6)))) + :eval (map-filter (lambda (k _) (oddp k)) (list '(1 . 2) '(4 . 6))) + :eval (map-filter (lambda (k v) (evenp (+ k v))) (list '(1 . 2) '(4 . 6)))) (map-remove - :eval (map-remove (lambda (k _) (cl-oddp k)) (list '(1 . 2) '(4 . 6))) - :eval (map-remove (lambda (k v) (cl-evenp (+ k v))) (list '(1 . 2) '(4 . 6)))) + :eval (map-remove (lambda (k _) (oddp k)) (list '(1 . 2) '(4 . 6))) + :eval (map-remove (lambda (k v) (evenp (+ k v))) (list '(1 . 2) '(4 . 6)))) (map-some - :eval (map-some (lambda (k _) (cl-oddp k)) (list '(1 . 2) '(4 . 6))) - :eval (map-some (lambda (k v) (cl-evenp (+ k v))) (list '(1 . 2) '(4 . 6)))) + :eval (map-some (lambda (k _) (oddp k)) (list '(1 . 2) '(4 . 6))) + :eval (map-some (lambda (k v) (evenp (+ k v))) (list '(1 . 2) '(4 . 6)))) (map-every-p - :eval (map-every-p (lambda (k _) (cl-oddp k)) (list '(1 . 2) '(4 . 6))) - :eval (map-every-p (lambda (k v) (cl-evenp (+ k v))) (list '(1 . 3) '(4 . 6)))) + :eval (map-every-p (lambda (k _) (oddp k)) (list '(1 . 2) '(4 . 6))) + :eval (map-every-p (lambda (k v) (evenp (+ k v))) (list '(1 . 3) '(4 . 6)))) "Combining and changing maps" (map-merge :eval (map-merge 'alist '(1 2 3 4) #s(hash-table data (5 6 7 8))) @@ -1418,10 +1418,10 @@ A FUNC form can have any number of `:no-eval' (or `:no-value'), (cl-minusp :eval (cl-minusp 0) :eval (cl-minusp -1)) - (cl-oddp - :eval (cl-oddp 3)) - (cl-evenp - :eval (cl-evenp 6)) + (oddp + :eval (oddp 3)) + (evenp + :eval (evenp 6)) (bignump :eval (bignump 4) :eval (bignump (expt 2 90))) diff --git a/lisp/obsolete/cl.el b/lisp/obsolete/cl.el index 2ee7e70e4ea..4fb49b596e2 100644 --- a/lisp/obsolete/cl.el +++ b/lisp/obsolete/cl.el @@ -272,8 +272,6 @@ first svref copy-seq - evenp - oddp minusp plusp floatp-safe diff --git a/lisp/subr.el b/lisp/subr.el index 77e909d1bf6..173c69675aa 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -550,6 +550,20 @@ was called." (compiler-macro (lambda (_) `(= 0 ,number)))) (= 0 number)) +(defun oddp (integer) + "Return t if INTEGER is odd." + (declare (ftype (function (integer) boolean)) + (side-effect-free t) + (compiler-macro (lambda (_) `(eq (logand ,integer 1) 1)))) + (eq (logand integer 1) 1)) + +(defun evenp (integer) + "Return t if INTEGER is even." + (declare (ftype (function (integer) boolean)) + (side-effect-free t) + (compiler-macro (lambda (_) `(eq (logand ,integer 1) 0)))) + (eq (logand integer 1) 0)) + (defun fixnump (object) "Return t if OBJECT is a fixnum." (declare (ftype (function (t) boolean)) diff --git a/test/lisp/emacs-lisp/cl-lib-tests.el b/test/lisp/emacs-lisp/cl-lib-tests.el index 12de268bced..4121c1bfdb0 100644 --- a/test/lisp/emacs-lisp/cl-lib-tests.el +++ b/test/lisp/emacs-lisp/cl-lib-tests.el @@ -111,26 +111,6 @@ (should-not (cl-minusp 1.0e+INF)) (should-error (cl-minusp "-42") :type 'wrong-type-argument)) -(ert-deftest cl-lib-test-oddp () - (should (cl-oddp -3)) - (should (cl-oddp 3)) - (should-not (cl-oddp -2)) - (should-not (cl-oddp 0)) - (should-not (cl-oddp 2)) - (should-error (cl-oddp 3.0e+NaN) :type 'wrong-type-argument) - (should-error (cl-oddp 3.0) :type 'wrong-type-argument) - (should-error (cl-oddp "3") :type 'wrong-type-argument)) - -(ert-deftest cl-lib-test-evenp () - (should (cl-evenp -2)) - (should (cl-evenp 0)) - (should (cl-evenp 2)) - (should-not (cl-evenp -3)) - (should-not (cl-evenp 3)) - (should-error (cl-evenp 2.0e+NaN) :type 'wrong-type-argument) - (should-error (cl-evenp 2.0) :type 'wrong-type-argument) - (should-error (cl-evenp "2") :type 'wrong-type-argument)) - (ert-deftest cl-digit-char-p () (should (eql 3 (cl-digit-char-p ?3))) (should (eql 10 (cl-digit-char-p ?a 11))) diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el index 29767ed07b5..1b209ab6383 100644 --- a/test/lisp/subr-tests.el +++ b/test/lisp/subr-tests.el @@ -45,6 +45,26 @@ (should-not (zerop (1- most-negative-fixnum))) (should-error (zerop "-5") :type 'wrong-type-argument)) +(ert-deftest subr-test-oddp () + (should (oddp -3)) + (should (oddp 3)) + (should-not (oddp -2)) + (should-not (oddp 0)) + (should-not (oddp 2)) + (should-error (oddp 3.0e+NaN) :type 'wrong-type-argument) + (should-error (oddp 3.0) :type 'wrong-type-argument) + (should-error (oddp "3") :type 'wrong-type-argument)) + +(ert-deftest subr-test-evenp () + (should (evenp -2)) + (should (evenp 0)) + (should (evenp 2)) + (should-not (evenp -3)) + (should-not (evenp 3)) + (should-error (evenp 2.0e+NaN) :type 'wrong-type-argument) + (should-error (evenp 2.0) :type 'wrong-type-argument) + (should-error (evenp "2") :type 'wrong-type-argument)) + (ert-deftest let-when-compile () ;; good case (should (equal (macroexpand '(let-when-compile ((foo (+ 2 3))) From 657f4658a7141708adb7f3ca594145f2df569d4c Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Mon, 17 Feb 2025 03:33:54 +0100 Subject: [PATCH 29/56] Prefer oddp/evenp to cl-oddp/cl-evenp * lisp/calc/calc-ext.el (math-oddp): * lisp/calc/calc-misc.el (math-evenp): * lisp/calendar/todo-mode.el (todo-adjusted-category-label-length, todo-insert-category-line) (todo-update-categories-display): * lisp/emacs-lisp/cl-macs.el (cl-defstruct): * lisp/net/gnutls.el (open-gnutls-stream): * lisp/tab-line.el (tab-line-tab-face-inactive-alternating): * test/lisp/auth-source-tests.el (auth-source-test-macos-keychain-search): * test/lisp/emacs-lisp/cl-extra-tests.el (cl-extra-test-notany) (cl-extra-test-notevery): * test/lisp/emacs-lisp/cl-lib-tests.el (cl-lib-adjoin-test): * test/lisp/emacs-lisp/cl-macs-tests.el (cl-macs-loop-collect) (cl-macs-loop-append/nconc, cl-macs-loop-when) (cl-macs-loop-if): * test/lisp/emacs-lisp/cl-seq-tests.el (cl-seq-remove-test) (cl-remove-if-test, cl-remove-if-not-test, cl-seq-delete-test) (cl-delete-if-test, cl-delete-if-not-test) (cl-seq-substitute-if-test, cl-seq-substitute-if-not-test) (cl-find-if-test, cl-find-if-not-test, cl-position-if-test) (cl-seq-count-test, cl-count-if-test, cl-count-if-not-test) (cl-member-if-test, cl-member-if-not-test, cl-assoc-if-test) (cl-assoc-if-not-test, cl-rassoc-if-test) (cl-rassoc-if-not-test): * test/src/treesit-tests.el (treesit-search-forward-predicate): Prefer oddp/evenp to cl-oddp/cl-evenp where possible. * lisp/calc/calc-ext.el (cl-lib): * lisp/calc/calc-misc.el (cl-lib): Don't require. --- lisp/calc/calc-ext.el | 3 +- lisp/calc/calc-misc.el | 3 +- lisp/calendar/todo-mode.el | 8 +- lisp/emacs-lisp/cl-macs.el | 2 +- lisp/net/gnutls.el | 2 +- lisp/tab-line.el | 2 +- test/lisp/auth-source-tests.el | 2 +- test/lisp/emacs-lisp/cl-extra-tests.el | 12 +- test/lisp/emacs-lisp/cl-lib-tests.el | 4 +- test/lisp/emacs-lisp/cl-macs-tests.el | 12 +- test/lisp/emacs-lisp/cl-seq-tests.el | 160 ++++++++++++------------- test/src/treesit-tests.el | 2 +- 12 files changed, 105 insertions(+), 107 deletions(-) diff --git a/lisp/calc/calc-ext.el b/lisp/calc/calc-ext.el index 060d352fe66..71f07b2c93a 100644 --- a/lisp/calc/calc-ext.el +++ b/lisp/calc/calc-ext.el @@ -25,7 +25,6 @@ (require 'calc) (require 'calc-macs) -(require 'cl-lib) ;; Declare functions which are defined elsewhere. (declare-function math-clip "calc-bin" (a &optional w)) @@ -2111,7 +2110,7 @@ calc-kill calc-kill-region calc-yank)))) ;;; True if A is an odd integer. [P R R] [Public] (defun math-oddp (a) - (and (integerp a) (cl-oddp a))) + (and (integerp a) (oddp a))) ;;; True if A is an integer. [P x] [Public] (defalias 'math-integerp #'integerp) diff --git a/lisp/calc/calc-misc.el b/lisp/calc/calc-misc.el index 62d8f0093b1..0772b76409a 100644 --- a/lisp/calc/calc-misc.el +++ b/lisp/calc/calc-misc.el @@ -27,7 +27,6 @@ (require 'calc) (require 'calc-macs) -(require 'cl-lib) ;; Declare functions which are defined elsewhere. (declare-function calc-do-keypad "calc-keypd" (&optional full-display interactive)) @@ -736,7 +735,7 @@ loaded and the keystroke automatically re-typed." ;; True if A is an even integer. [P R R] [Public] ;;;###autoload (defun math-evenp (a) - (and (integerp a) (cl-evenp a))) + (and (integerp a) (evenp a))) ;; Compute A / 2, for small or big integer A. [I i] ;; If A is negative, type of truncation is undefined. diff --git a/lisp/calendar/todo-mode.el b/lisp/calendar/todo-mode.el index dc6f7345b21..4e4c388c84d 100644 --- a/lisp/calendar/todo-mode.el +++ b/lisp/calendar/todo-mode.el @@ -55,7 +55,7 @@ ;;; Code: (require 'diary-lib) -(require 'cl-lib) ; For cl-oddp and cl-assert. +(require 'cl-lib) ;; ----------------------------------------------------------------------------- ;;; Setting up todo files, categories, and items @@ -3742,7 +3742,7 @@ Categories mode." (longest (todo-longest-category-name-length categories)) (catlablen (length todo-categories-category-label)) (lc-diff (- longest catlablen))) - (if (and (natnump lc-diff) (cl-oddp lc-diff)) + (if (and (natnump lc-diff) (oddp lc-diff)) (1+ longest) (max longest catlablen)))) @@ -3870,7 +3870,7 @@ which is the value of the user option (make-string (1+ (/ (length (car elt)) 2)) 32) ; label (format "%3d" (todo-get-count (cdr elt) cat)) ; count ;; Add an extra space if label length is odd. - (when (cl-oddp (length (car elt))) " "))) + (when (oddp (length (car elt))) " "))) (if archive (list (cons todo-categories-done-label 'done)) (list (cons todo-categories-todo-label 'todo) @@ -3979,7 +3979,7 @@ which is the value of the user option (make-string (1+ (/ (length (car elt)) 2)) 32) (format "%3d" (nth (cdr elt) (todo-total-item-counts))) ;; Add an extra space if label length is odd. - (when (cl-oddp (length (car elt))) " "))) + (when (oddp (length (car elt))) " "))) (if archive (list (cons todo-categories-done-label 2)) (list (cons todo-categories-todo-label 0) diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el index caaffcf19be..eef69e6899e 100644 --- a/lisp/emacs-lisp/cl-macs.el +++ b/lisp/emacs-lisp/cl-macs.el @@ -3259,7 +3259,7 @@ To see the documentation for a defined struct type, use (declare (side-effect-free t)) ,access-body) forms) - (when (cl-oddp (length desc)) + (when (oddp (length desc)) (push (macroexp-warn-and-return (format-message diff --git a/lisp/net/gnutls.el b/lisp/net/gnutls.el index 8f00efaccfe..65382a12265 100644 --- a/lisp/net/gnutls.el +++ b/lisp/net/gnutls.el @@ -188,7 +188,7 @@ trust and key files, and priority string." (let* ((parameters (cond ((symbolp parameters) (list :nowait parameters)) - ((not (cl-evenp (length parameters))) + ((not (evenp (length parameters))) (error "Malformed keyword list")) ((consp parameters) parameters) diff --git a/lisp/tab-line.el b/lisp/tab-line.el index 5562f5caaf1..552c480725c 100644 --- a/lisp/tab-line.el +++ b/lisp/tab-line.el @@ -668,7 +668,7 @@ SELECTED-P nil means TAB is not the selected tab. When TAB is not selected and is even-numbered, make FACE inherit from `tab-line-tab-inactive-alternate'. For use in `tab-line-tab-face-functions'." - (when (and (not selected-p) (cl-evenp (cl-position tab tabs))) + (when (and (not selected-p) (evenp (cl-position tab tabs))) (setf face `(:inherit (tab-line-tab-inactive-alternate ,face)))) face) diff --git a/test/lisp/auth-source-tests.el b/test/lisp/auth-source-tests.el index 763e0b05245..584822e38f3 100644 --- a/test/lisp/auth-source-tests.el +++ b/test/lisp/auth-source-tests.el @@ -468,7 +468,7 @@ machine c1 port c2 user c3 password c4\n" ;; Arguments must be all strings. (should (cl-every #'stringp args)) ;; Argument number should be even. - (should (cl-evenp (length args))) + (should (evenp (length args))) (should (cond ((string= (car args) "find-internet-password") diff --git a/test/lisp/emacs-lisp/cl-extra-tests.el b/test/lisp/emacs-lisp/cl-extra-tests.el index 75533b36f29..c524f77f2bb 100644 --- a/test/lisp/emacs-lisp/cl-extra-tests.el +++ b/test/lisp/emacs-lisp/cl-extra-tests.el @@ -228,14 +228,14 @@ nil))) (ert-deftest cl-extra-test-notany () - (should (equal (cl-notany #'cl-oddp '(1 3 5)) nil)) - (should (equal (cl-notany #'cl-oddp '(2 4 6)) t)) - (should (equal (cl-notany #'cl-oddp '(1 2 3 4 5)) nil))) + (should (equal (cl-notany #'oddp '(1 3 5)) nil)) + (should (equal (cl-notany #'oddp '(2 4 6)) t)) + (should (equal (cl-notany #'oddp '(1 2 3 4 5)) nil))) (ert-deftest cl-extra-test-notevery () - (should (equal (cl-notevery #'cl-oddp '(1 3 5)) nil)) - (should (equal (cl-notevery #'cl-oddp '(2 4 6)) t)) - (should (equal (cl-notevery #'cl-oddp '(1 2 3 4 5)) t))) + (should (equal (cl-notevery #'oddp '(1 3 5)) nil)) + (should (equal (cl-notevery #'oddp '(2 4 6)) t)) + (should (equal (cl-notevery #'oddp '(1 2 3 4 5)) t))) (ert-deftest cl-extra-test-gcd () (should (equal (cl-gcd 4) 4)) diff --git a/test/lisp/emacs-lisp/cl-lib-tests.el b/test/lisp/emacs-lisp/cl-lib-tests.el index 4121c1bfdb0..607161c6a7c 100644 --- a/test/lisp/emacs-lisp/cl-lib-tests.el +++ b/test/lisp/emacs-lisp/cl-lib-tests.el @@ -288,8 +288,8 @@ ;;(should-error (cl-adjoin 3 nums :test 'myfn-p :test-not myfn-p)) ;; own :key fn - (should (eq nums (cl-adjoin 3 nums :key (lambda (x) (if (cl-evenp x) (1+ x) x))))) - (should (equal '(3 1 2) (cl-adjoin 3 nums :key (lambda (x) (if (cl-evenp x) (+ 2 x) x))))) + (should (eq nums (cl-adjoin 3 nums :key (lambda (x) (if (evenp x) (1+ x) x))))) + (should (equal '(3 1 2) (cl-adjoin 3 nums :key (lambda (x) (if (evenp x) (+ 2 x) x))))) ;; convert using :key, then compare with :test (should (eq nums (cl-adjoin 1 nums :key 'int-to-string :test 'string=))) diff --git a/test/lisp/emacs-lisp/cl-macs-tests.el b/test/lisp/emacs-lisp/cl-macs-tests.el index 4fa5c4edba1..bca5a12e398 100644 --- a/test/lisp/emacs-lisp/cl-macs-tests.el +++ b/test/lisp/emacs-lisp/cl-macs-tests.el @@ -212,7 +212,7 @@ when (symbolp i) collect i) '(bird turtle horse cat))) (should (equal (cl-loop for i from 1 to 10 - if (cl-oddp i) collect i) + if (oddp i) collect i) '(1 3 5 7 9))) (should (equal (cl-loop for i in '(a b c d e f g) by #'cddr collect i into my-list @@ -225,7 +225,7 @@ '(a b (c)))) (should (equal (cl-loop for i upfrom 0 as x in '(a b (c)) - nconc (if (cl-evenp i) (list x) nil)) + nconc (if (evenp i) (list x) nil)) '(a (c))))) (ert-deftest cl-macs-loop-count () @@ -346,7 +346,7 @@ collection clause." (should (equal (cl-loop for elt in '(1 a 2 "a" (3 4) 5 6) when (numberp elt) - when (cl-evenp elt) collect elt into even + when (evenp elt) collect elt into even else collect elt into odd else when (symbolp elt) collect elt into syms @@ -356,7 +356,7 @@ collection clause." (ert-deftest cl-macs-loop-if () (should (equal (cl-loop for i to 5 - if (cl-evenp i) + if (evenp i) collect i and when (and (= i 2) 'two) collect it @@ -364,7 +364,7 @@ collection clause." collect "low") '(0 2 two "low" 4))) (should (equal (cl-loop for i to 5 - if (cl-evenp i) + if (evenp i) collect i and when (and (= i 2) 'two) collect it @@ -374,7 +374,7 @@ collection clause." '(0 "low" 2 two "low" 4))) (should (equal (cl-loop with funny-numbers = '(6 13 -1) for x below 10 - if (cl-evenp x) + if (evenp x) collect x into evens else collect x into odds diff --git a/test/lisp/emacs-lisp/cl-seq-tests.el b/test/lisp/emacs-lisp/cl-seq-tests.el index f72596e4a4b..934304b878a 100644 --- a/test/lisp/emacs-lisp/cl-seq-tests.el +++ b/test/lisp/emacs-lisp/cl-seq-tests.el @@ -138,22 +138,22 @@ Additionally register an `ert-info' to help identify test failures." (should (equal '(1 3 4 5 6) (cl-remove 2 list :key #'identity :test #'eql))) (should (equal '(1 2 3 4 2) (cl-remove 4 list :test (lambda (a b) (> b a))))) (should (equal '(5 6) (cl-remove 4 list :test-not (lambda (a b) (> b a))))) - (should (equal '(1 3 5) (cl-remove 'foo list :if #'cl-evenp))) - (should (equal '(2 4 2 6) (cl-remove 'foo list :if-not #'cl-evenp))) - (should (equal '(1 2 3 4 5) (cl-remove 'foo list :if #'cl-evenp :start 4))) + (should (equal '(1 3 5) (cl-remove 'foo list :if #'evenp))) + (should (equal '(2 4 2 6) (cl-remove 'foo list :if-not #'evenp))) + (should (equal '(1 2 3 4 5) (cl-remove 'foo list :if #'evenp :start 4))) (should (equal '(1 2 3 4 5 6) (cl-remove 2 list :start 5 :end 6))) (should (equal '(1 3 4 5 2 6) (cl-remove 2 list :count 1))) (should (equal '(1 3 4 5 2 6) (cl-remove 2 list :from-end nil :count 1))) (should (equal '(1 2 3 4 5 6) (cl-remove 2 list :from-end t :count 1))))) (ert-deftest cl-remove-if-test () - (should (equal '(1 3) (cl-remove-if #'cl-evenp '(1 2 3 4)))) - (should (equal '(1 3) (cl-remove-if #'cl-evenp '(1 2 3 4) :count 2))) - (should (equal '(1 3 4) (cl-remove-if #'cl-evenp '(1 2 3 4) :start 1 :end 3))) - (should (equal '(1 3) (cl-remove-if #'cl-evenp '(1 2 3 4) :from-end t))) - (should (equal '(2 4) (cl-remove-if #'cl-oddp '(1 2 3 4)))) - (should (equal '() (cl-remove-if #'cl-evenp '()))) - (should (equal '() (cl-remove-if #'cl-evenp '(2))))) + (should (equal '(1 3) (cl-remove-if #'evenp '(1 2 3 4)))) + (should (equal '(1 3) (cl-remove-if #'evenp '(1 2 3 4) :count 2))) + (should (equal '(1 3 4) (cl-remove-if #'evenp '(1 2 3 4) :start 1 :end 3))) + (should (equal '(1 3) (cl-remove-if #'evenp '(1 2 3 4) :from-end t))) + (should (equal '(2 4) (cl-remove-if #'oddp '(1 2 3 4)))) + (should (equal '() (cl-remove-if #'evenp '()))) + (should (equal '() (cl-remove-if #'evenp '(2))))) (ert-deftest cl-lib-test-remove-if-not () (let ((list (list 'a 'b 'c 'd)) @@ -170,14 +170,14 @@ Additionally register an `ert-info' to help identify test failures." (cl-remove-if-not (lambda (_x) (should nil)) '())))) (ert-deftest cl-remove-if-not-test () - (should (equal '(2 4) (cl-remove-if-not #'cl-evenp '(1 2 3 4)))) - (should (equal '(2 4) (cl-remove-if-not #'cl-evenp '(1 2 3 4) :count 2))) - (should (equal '(1 2 4) (cl-remove-if-not #'cl-evenp '(1 2 3 4) :start 1 :end 3))) - (should (equal '(2 4) (cl-remove-if-not #'cl-evenp '(1 2 3 4) :from-end t))) - (should (equal '(1 3) (cl-remove-if-not #'cl-oddp '(1 2 3 4)))) - (should (equal '() (cl-remove-if-not #'cl-evenp '()))) - (should (equal '(2) (cl-remove-if-not #'cl-evenp '(2)))) - (should (equal '(2) (cl-remove-if-not #'cl-evenp '(2) :key #'-)))) + (should (equal '(2 4) (cl-remove-if-not #'evenp '(1 2 3 4)))) + (should (equal '(2 4) (cl-remove-if-not #'evenp '(1 2 3 4) :count 2))) + (should (equal '(1 2 4) (cl-remove-if-not #'evenp '(1 2 3 4) :start 1 :end 3))) + (should (equal '(2 4) (cl-remove-if-not #'evenp '(1 2 3 4) :from-end t))) + (should (equal '(1 3) (cl-remove-if-not #'oddp '(1 2 3 4)))) + (should (equal '() (cl-remove-if-not #'evenp '()))) + (should (equal '(2) (cl-remove-if-not #'evenp '(2)))) + (should (equal '(2) (cl-remove-if-not #'evenp '(2) :key #'-)))) ;; keywords supported: :test :test-not :key :count :start :end :from-end (ert-deftest cl-seq-delete-test () @@ -188,9 +188,9 @@ Additionally register an `ert-info' to help identify test failures." (should (equal '(1 3 4 5 6) (cl-delete 2 l :key #'identity :test #'eql))) (should (equal '(1 2 3 4 2) (cl-delete 4 l :test (lambda (a b) (> b a))))) (should (equal '(5 6) (cl-delete 4 l :test-not (lambda (a b) (> b a))))) - (should (equal '(1 3 5) (cl-delete 'foo l :if #'cl-evenp))) - (should (equal '(2 4 2 6) (cl-delete 'foo l :if-not #'cl-evenp))) - (should (equal '(1 2 3 4 5) (cl-delete 'foo l :if #'cl-evenp :start 4))) + (should (equal '(1 3 5) (cl-delete 'foo l :if #'evenp))) + (should (equal '(2 4 2 6) (cl-delete 'foo l :if-not #'evenp))) + (should (equal '(1 2 3 4 5) (cl-delete 'foo l :if #'evenp :start 4))) (should (equal '(1 2 3 4 5 6) (cl-delete 2 l :start 5 :end 6))) (should (equal '(1 3 4 5 2 6) (cl-delete 2 l :count 1))) (should (equal '(1 3 4 5 2 6) (cl-delete 2 l :from-end nil :count 1))) @@ -198,17 +198,17 @@ Additionally register an `ert-info' to help identify test failures." (ert-deftest cl-delete-if-test () (cl-seq-tests--relet* ((l (list 1 2 3 4 5))) - (should (equal '(1 3 5) (cl-delete-if #'cl-evenp l))) - (should (equal '(1 3 5) (cl-delete-if #'cl-evenp l :start 0 :end 4))) - (should (equal '(1 3 5) (cl-delete-if #'cl-evenp l :from-end t))) - (should (equal '(2 4) (cl-delete-if #'cl-oddp l)))) - (should (equal '() (cl-delete-if #'cl-evenp '()))) - (should (equal '() (cl-delete-if #'cl-evenp (list 2))))) + (should (equal '(1 3 5) (cl-delete-if #'evenp l))) + (should (equal '(1 3 5) (cl-delete-if #'evenp l :start 0 :end 4))) + (should (equal '(1 3 5) (cl-delete-if #'evenp l :from-end t))) + (should (equal '(2 4) (cl-delete-if #'oddp l)))) + (should (equal '() (cl-delete-if #'evenp '()))) + (should (equal '() (cl-delete-if #'evenp (list 2))))) (ert-deftest cl-delete-if-not-test () - (should (equal '(2 4) (cl-delete-if-not #'cl-evenp (list 1 2 3 4 5)))) - (should (equal '() (cl-delete-if-not #'cl-evenp '()))) - (should (equal '() (cl-delete-if-not #'cl-evenp (list 1))))) + (should (equal '(2 4) (cl-delete-if-not #'evenp (list 1 2 3 4 5)))) + (should (equal '() (cl-delete-if-not #'evenp '()))) + (should (equal '() (cl-delete-if-not #'evenp (list 1))))) (ert-deftest cl-delete-duplicates-test () (should (equal '(3 2 1) (cl-delete-duplicates (list 1 2 3 2 1)))) @@ -263,63 +263,63 @@ Additionally register an `ert-info' to help identify test failures." (should (equal '(b 2 3 4 5 2 6) (cl-substitute 'b nil list :if-not pred)))))) (ert-deftest cl-seq-substitute-if-test () - (let ((result (cl-substitute-if 'x #'cl-evenp '(1 2 3 4 5)))) + (let ((result (cl-substitute-if 'x #'evenp '(1 2 3 4 5)))) (should (equal result '(1 x 3 x 5)))) - (let ((result (cl-substitute-if 'x #'cl-evenp '(1 3 5)))) + (let ((result (cl-substitute-if 'x #'evenp '(1 3 5)))) (should (equal result '(1 3 5)))) (let ((result (cl-substitute-if 'x #'always '(1 2 3 4 5)))) (should (equal result '(x x x x x)))) - (let ((result (cl-substitute-if 'x #'cl-evenp '(1 2 3 4 5) :start 1 :end 4))) + (let ((result (cl-substitute-if 'x #'evenp '(1 2 3 4 5) :start 1 :end 4))) (should (equal result '(1 x 3 x 5)))) - (let ((result (cl-substitute-if 'x #'cl-oddp '(1 2 3 4 5) :from-end t))) + (let ((result (cl-substitute-if 'x #'oddp '(1 2 3 4 5) :from-end t))) (should (equal result '(x 2 x 4 x)))) (let ((result (cl-substitute-if 'x (lambda (n) (= n 3)) '(1 2 3 4 5) :key #'identity))) (should (equal result '(1 2 x 4 5))))) (ert-deftest cl-seq-substitute-if-not-test () - (let ((result (cl-substitute-if-not 'x #'cl-evenp '(1 2 3 4 5)))) + (let ((result (cl-substitute-if-not 'x #'evenp '(1 2 3 4 5)))) (should (equal result '(x 2 x 4 x)))) - (let ((result (cl-substitute-if-not 'x #'cl-evenp '(2 4 6)))) + (let ((result (cl-substitute-if-not 'x #'evenp '(2 4 6)))) (should (equal result '(2 4 6)))) (let ((result (cl-substitute-if-not 'x (lambda (n) (> n 5)) '(1 2 3 4 5)))) (should (equal result '(x x x x x)))) - (let ((result (cl-substitute-if-not 'x #'cl-evenp '(1 2 3 4 5) :start 0 :end 4))) + (let ((result (cl-substitute-if-not 'x #'evenp '(1 2 3 4 5) :start 0 :end 4))) (should (equal result '(x 2 x 4 5)))) - (let ((result (cl-substitute-if-not 'x #'cl-oddp '(1 2 3 4 5) :from-end t))) + (let ((result (cl-substitute-if-not 'x #'oddp '(1 2 3 4 5) :from-end t))) (should (equal result '(1 x 3 x 5)))) (let ((result (cl-substitute-if-not 'x (lambda (n) (= n 3)) '(1 2 3 4 5) :key #'identity))) (should (equal result '(x x 3 x x))))) (ert-deftest cl-find-if-test () - (let ((result (cl-find-if #'cl-evenp '(1 2 3 4 5)))) + (let ((result (cl-find-if #'evenp '(1 2 3 4 5)))) (should (equal result 2))) (let ((result (cl-find-if (lambda (n) (> n 5)) '(1 2 3 4 5)))) (should (equal result nil))) (let ((result (cl-find-if (lambda (n) (> n 3)) '(1 2 3 4 5 6 7)))) (should (equal result 4))) - (let ((result (cl-find-if #'cl-evenp '(1 2 3 4 5) :start 2))) + (let ((result (cl-find-if #'evenp '(1 2 3 4 5) :start 2))) (should (equal result 4))) - (let ((result (cl-find-if #'cl-evenp '(1 2 3 4 5) :end 1))) + (let ((result (cl-find-if #'evenp '(1 2 3 4 5) :end 1))) (should (equal result nil))) - (let ((result (cl-find-if #'cl-oddp '(2 4 5 6 7) :from-end t))) + (let ((result (cl-find-if #'oddp '(2 4 5 6 7) :from-end t))) (should (equal result 7))) (let ((result (cl-find-if (lambda (n) (= n 4)) '(1 2 3 4 5) :key #'identity))) (should (equal result 4)))) (ert-deftest cl-find-if-not-test () - (let ((result (cl-find-if-not #'cl-evenp '(1 2 3 4 5)))) + (let ((result (cl-find-if-not #'evenp '(1 2 3 4 5)))) (should (equal result 1))) - (let ((result (cl-find-if-not #'cl-oddp '(1 3 5)))) + (let ((result (cl-find-if-not #'oddp '(1 3 5)))) (should (equal result nil))) (let ((result (cl-find-if-not (lambda (n) (< n 4)) '(1 2 3 4 5 6 7)))) (should (equal result 4))) - (let ((result (cl-find-if-not #'cl-evenp '(1 2 3 4 5) :start 2))) + (let ((result (cl-find-if-not #'evenp '(1 2 3 4 5) :start 2))) (should (equal result 3))) - (let ((result (cl-find-if-not #'cl-evenp '(1 2 3 4 5) :end 3))) + (let ((result (cl-find-if-not #'evenp '(1 2 3 4 5) :end 3))) (should (equal result 1))) - (let ((result (cl-find-if-not #'cl-oddp '(2 4 6 7 8) :from-end t))) + (let ((result (cl-find-if-not #'oddp '(2 4 6 7 8) :from-end t))) (should (equal result 8))) (let ((result (cl-find-if-not (lambda (n) (= n 4)) '(1 2 3 4 5) :key #'identity))) (should (equal result 1)))) @@ -383,17 +383,17 @@ Additionally register an `ert-info' to help identify test failures." (should (= 5 (cl-position 5 list :key (lambda (x) (1+ (* x x))) :from-end t))))) (ert-deftest cl-position-if-test () - (let ((result (cl-position-if #'cl-evenp '(1 2 3 4 5)))) + (let ((result (cl-position-if #'evenp '(1 2 3 4 5)))) (should (equal result 1))) (let ((result (cl-position-if (lambda (n) (> n 5)) '(1 2 3 4 5)))) (should (equal result nil))) (let ((result (cl-position-if (lambda (n) (> n 3)) '(1 2 3 4 5 6 7)))) (should (equal result 3))) - (let ((result (cl-position-if #'cl-evenp '(1 2 3 4 5) :start 2))) + (let ((result (cl-position-if #'evenp '(1 2 3 4 5) :start 2))) (should (equal result 3))) - (let ((result (cl-position-if #'cl-evenp '(1 2 3 4 5) :end 1))) + (let ((result (cl-position-if #'evenp '(1 2 3 4 5) :end 1))) (should (equal result nil))) - (let ((result (cl-position-if #'cl-oddp '(2 4 5 6 7) :from-end t))) + (let ((result (cl-position-if #'oddp '(2 4 5 6 7) :from-end t))) (should (equal result 4))) (let ((result (cl-position-if (lambda (n) (= n 4)) '(1 2 3 4 5) :key #'identity))) (should (equal result 3)))) @@ -406,15 +406,15 @@ Additionally register an `ert-info' to help identify test failures." (should (= 1 (cl-count 2 list :end 4))) (should (= 0 (cl-count -5 list))) (should (= 0 (cl-count 2 list :start 2 :end 4))) - (should (= 4 (cl-count 'foo list :key (lambda (x) (and (cl-evenp x) 'foo))))) - (should (= 4 (cl-count 'foo list :test (lambda (_a b) (cl-evenp b))))) - (should (equal (cl-count 'foo list :test (lambda (_a b) (cl-oddp b))) - (cl-count 'foo list :test-not (lambda (_a b) (cl-evenp b))))))) + (should (= 4 (cl-count 'foo list :key (lambda (x) (and (evenp x) 'foo))))) + (should (= 4 (cl-count 'foo list :test (lambda (_a b) (evenp b))))) + (should (equal (cl-count 'foo list :test (lambda (_a b) (oddp b))) + (cl-count 'foo list :test-not (lambda (_a b) (evenp b))))))) (ert-deftest cl-count-if-test () - (let ((result (cl-count-if #'cl-evenp '(1 2 3 4 5)))) + (let ((result (cl-count-if #'evenp '(1 2 3 4 5)))) (should (equal result 2))) - (let ((result (cl-count-if #'cl-oddp '(2 4 6 8)))) + (let ((result (cl-count-if #'oddp '(2 4 6 8)))) (should (equal result 0))) (let ((result (cl-count-if #'always '(1 2 3 4)))) (should (equal result 4))) @@ -422,11 +422,11 @@ Additionally register an `ert-info' to help identify test failures." (should (equal result 0))) (let ((result (cl-count-if (lambda (x) (> x 2)) '(1 2 3 4 5) :key #'identity))) (should (equal result 3))) - (let ((result (cl-count-if #'cl-evenp '(1 2 3 4 5) :start 2))) + (let ((result (cl-count-if #'evenp '(1 2 3 4 5) :start 2))) (should (equal result 1))) - (let ((result (cl-count-if #'cl-evenp '(1 2 3 4 5) :end 3))) + (let ((result (cl-count-if #'evenp '(1 2 3 4 5) :end 3))) (should (equal result 1))) - (let ((result (cl-count-if #'cl-evenp '()))) + (let ((result (cl-count-if #'evenp '()))) (should (equal result 0))) (let ((result (cl-count-if #'numberp '(1 "two" 3 4 "five" 6)))) (should (equal result 4))) @@ -434,9 +434,9 @@ Additionally register an `ert-info' to help identify test failures." (should (equal result 4)))) (ert-deftest cl-count-if-not-test () - (let ((result (cl-count-if-not #'cl-evenp '(1 2 3 4 5)))) + (let ((result (cl-count-if-not #'evenp '(1 2 3 4 5)))) (should (equal result 3))) - (let ((result (cl-count-if-not #'cl-oddp '(1 3 5)))) + (let ((result (cl-count-if-not #'oddp '(1 3 5)))) (should (equal result 0))) (let ((result (cl-count-if-not #'always '(1 2 3 4)))) (should (equal result 0))) @@ -444,11 +444,11 @@ Additionally register an `ert-info' to help identify test failures." (should (equal result 4))) (let ((result (cl-count-if-not (lambda (x) (> x 3)) '(1 2 3 4 5) :key #'identity))) (should (equal result 3))) - (let ((result (cl-count-if-not #'cl-evenp '(1 2 3 4 5) :start 2))) + (let ((result (cl-count-if-not #'evenp '(1 2 3 4 5) :start 2))) (should (equal result 2))) - (let ((result (cl-count-if-not #'cl-evenp '(1 2 3 4 5) :end 3))) + (let ((result (cl-count-if-not #'evenp '(1 2 3 4 5) :end 3))) (should (equal result 2))) - (let ((result (cl-count-if-not #'cl-evenp '()))) + (let ((result (cl-count-if-not #'evenp '()))) (should (equal result 0))) (let ((result (cl-count-if-not #'numberp '(1 "two" 3 4 "five" 6)))) (should (equal result 2))) @@ -627,7 +627,7 @@ Additionally register an `ert-info' to help identify test failures." (should (equal result '(2 3 4 5))))) (ert-deftest cl-member-if-test () - (let ((result (cl-member-if #'cl-evenp '(1 2 3 4 5)))) + (let ((result (cl-member-if #'evenp '(1 2 3 4 5)))) (should (equal result '(2 3 4 5)))) (let ((result (cl-member-if #'ignore '(1 2 3 4 5)))) (should (equal result nil))) @@ -635,7 +635,7 @@ Additionally register an `ert-info' to help identify test failures." (should (equal result '(1 2 3 4 5)))) (let ((result (cl-member-if (lambda (x) (= x 1)) '(1 2 3 4 5)))) (should (equal result '(1 2 3 4 5)))) - (let ((result (cl-member-if (lambda (x) (and (numberp x) (cl-evenp x))) + (let ((result (cl-member-if (lambda (x) (and (numberp x) (evenp x))) '(1 3 5 4 2)))) (should (equal result '(4 2)))) (let ((result (cl-member-if (lambda (x) (string= (number-to-string x) "3")) @@ -643,7 +643,7 @@ Additionally register an `ert-info' to help identify test failures." (should (equal result '(3 4 5)))) (let ((result (cl-member-if (lambda (x) (eq x 'a)) '(a a a a)))) (should (equal result '(a a a a)))) - (let ((result (cl-member-if #'cl-evenp '()))) + (let ((result (cl-member-if #'evenp '()))) (should (equal result nil))) (let ((result (cl-member-if #'cl-minusp '(1 2 3 4 5)))) (should (equal result nil))) @@ -655,9 +655,9 @@ Additionally register an `ert-info' to help identify test failures." (should (equal result '(6 7 8))))) (ert-deftest cl-member-if-not-test () - (let ((result (cl-member-if-not #'cl-evenp '(1 2 3 4 5)))) + (let ((result (cl-member-if-not #'evenp '(1 2 3 4 5)))) (should (equal result '(1 2 3 4 5)))) - (let ((result (cl-member-if-not #'cl-evenp '(2 4 6 8 10 11)))) + (let ((result (cl-member-if-not #'evenp '(2 4 6 8 10 11)))) (should (equal result '(11)))) (let ((result (cl-member-if-not (lambda (x) (> x 5)) '(1 2 3 4 5)))) (should (equal result '(1 2 3 4 5)))) @@ -668,7 +668,7 @@ Additionally register an `ert-info' to help identify test failures." (let ((result (cl-member-if-not (lambda (x) (string= (number-to-string x) "2")) '(1 2 3 4 5) :key #'identity))) (should (equal result '(1 2 3 4 5)))) - (let ((result (cl-member-if-not #'cl-evenp '()))) + (let ((result (cl-member-if-not #'evenp '()))) (should (equal result nil))) (let ((result (cl-member-if-not (lambda (x) (eq x 'a)) '(a a a a)))) (should (equal result nil))) @@ -701,7 +701,7 @@ Additionally register an `ert-info' to help identify test failures." (should (equal result '(b . 2))))) (ert-deftest cl-assoc-if-test () - (let ((result (cl-assoc-if #'cl-evenp + (let ((result (cl-assoc-if #'evenp '((1 . "odd") (2 . "even") (3 . "odd") (4 . "even"))))) (should (equal result '(2 . "even")))) (let ((result (cl-assoc-if (lambda (x) (= x 5)) @@ -719,7 +719,7 @@ Additionally register an `ert-info' to help identify test failures." (let ((result (cl-assoc-if (lambda (x) (> x 1)) '((0 . "zero") (1 . "one") (2 . "two"))))) (should (equal result '(2 . "two")))) - (let ((result (cl-assoc-if #'cl-evenp '()))) + (let ((result (cl-assoc-if #'evenp '()))) (should (equal result nil))) (let ((result (cl-assoc-if (lambda (x) (eq x 'a)) '((a . "first") (a . "second") (b . "third"))))) @@ -732,7 +732,7 @@ Additionally register an `ert-info' to help identify test failures." (ert-deftest cl-assoc-if-not-test () (let* ((alist '((1 . "odd") (2 . "even") (3 . "odd") (4 . "even"))) - (result (cl-assoc-if-not #'cl-evenp alist))) + (result (cl-assoc-if-not #'evenp alist))) (should (equal result '(1 . "odd")))) (let ((result (cl-assoc-if-not #'cl-plusp '((1 . "one") (2 . "two") (3 . "three"))))) @@ -753,7 +753,7 @@ Additionally register an `ert-info' to help identify test failures." (let ((result (cl-assoc-if-not #'symbolp '((1 . "one") (b . "bee") (2 . "two"))))) (should (equal result '(1 . "one")))) - (let ((result (cl-assoc-if-not #'cl-evenp '()))) + (let ((result (cl-assoc-if-not #'evenp '()))) (should (equal result nil))) (let ((result (cl-assoc-if-not (lambda (x) (eq x 'a)) '((a . "first") (a . "second") (b . "third"))))) @@ -781,10 +781,10 @@ Additionally register an `ert-info' to help identify test failures." (should (equal result nil)))) (ert-deftest cl-rassoc-if-test () - (let ((result (cl-rassoc-if #'cl-evenp + (let ((result (cl-rassoc-if #'evenp '(("one" . 1) ("two" . 2) ("three" . 3))))) (should (equal result '("two" . 2)))) - (let ((result (cl-rassoc-if #'cl-evenp + (let ((result (cl-rassoc-if #'evenp '(("one" . 1) ("three" . 3) ("five" . 5))))) (should (equal result nil))) (let ((result (cl-rassoc-if (lambda (x) (= x 1)) @@ -796,7 +796,7 @@ Additionally register an `ert-info' to help identify test failures." (let ((result (cl-rassoc-if (lambda (x) (and (numberp x) (< x 3))) '(("one" . 1) ("two" . 2) ("three" . 3))))) (should (equal result '("one" . 1)))) - (let ((result (cl-rassoc-if #'cl-evenp '()))) + (let ((result (cl-rassoc-if #'evenp '()))) (should (equal result nil))) (let ((result (cl-rassoc-if #'cl-plusp '(("first" . 1) ("second" . 2) ("third" . 3))))) @@ -809,7 +809,7 @@ Additionally register an `ert-info' to help identify test failures." (should (equal result nil)))) (ert-deftest cl-rassoc-if-not-test () - (let ((result (cl-rassoc-if-not #'cl-evenp + (let ((result (cl-rassoc-if-not #'evenp '(("one" . 1) ("two" . 2) ("three" . 3))))) (should (equal result '("one" . 1)))) (let ((result (cl-rassoc-if-not #'cl-plusp @@ -830,7 +830,7 @@ Additionally register an `ert-info' to help identify test failures." (let ((result (cl-rassoc-if-not (lambda (x) (equal x 2)) '(("one" . 1) ("two" . 2) ("three" . 3))))) (should (equal result '("one" . 1)))) - (let ((result (cl-rassoc-if-not #'cl-evenp '()))) + (let ((result (cl-rassoc-if-not #'evenp '()))) (should (equal result nil))) (let ((result (cl-rassoc-if-not #'numberp '(("one" . 1) ("two" . 2) ("three" . 3))))) diff --git a/test/src/treesit-tests.el b/test/src/treesit-tests.el index 22f53243274..8b24c5eb1fc 100644 --- a/test/src/treesit-tests.el +++ b/test/src/treesit-tests.el @@ -380,7 +380,7 @@ BODY is the test body." (let ((is-odd (lambda (node) (let ((string (treesit-node-text node))) (and (eq 1 (length string)) - (cl-oddp (string-to-number string))))))) + (oddp (string-to-number string))))))) (cl-loop for cursor = (treesit-node-child array 0) then (treesit-search-forward cursor `("number" . ,is-odd) nil t) From 5ce746c3b0fa3a0b73796182960ff06cf3f31473 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Mon, 17 Feb 2025 04:52:49 +0100 Subject: [PATCH 30/56] Prefer oddp/evenp to free-coding them in tests * test/lisp/emacs-lisp/bindat-tests.el (bindat-test--sint): * test/lisp/emacs-lisp/seq-tests.el (test-seq-drop-while) (test-seq-take-while, test-seq-filter, test-seq-remove) (test-seq-count, test-seq-some, test-seq-find, test-seq-every-p) (test-seq-group-by): * test/lisp/eshell/em-pred-tests.el (eshell-with-file-attributes-from-name): * test/lisp/filenotify-tests.el (file-notify-test07-many-events) (file-notify-test09-watched-file-in-watched-dir): * test/src/floatfns-tests.el (bignum-expt, bignum-round): * test/src/undo-tests.el (undo-test4): Prefer oddp/evenp to free-coding them. --- test/lisp/emacs-lisp/bindat-tests.el | 2 +- test/lisp/emacs-lisp/seq-tests.el | 60 ++++++++++++---------------- test/lisp/eshell/em-pred-tests.el | 2 +- test/lisp/filenotify-tests.el | 4 +- test/src/floatfns-tests.el | 4 +- test/src/undo-tests.el | 2 +- 6 files changed, 33 insertions(+), 41 deletions(-) diff --git a/test/lisp/emacs-lisp/bindat-tests.el b/test/lisp/emacs-lisp/bindat-tests.el index f5dacfeaa77..78021f0bc14 100644 --- a/test/lisp/emacs-lisp/bindat-tests.el +++ b/test/lisp/emacs-lisp/bindat-tests.el @@ -125,7 +125,7 @@ (ert-deftest bindat-test--sint () (dotimes (kind 32) (let ((bitlen (* 8 (/ kind 2))) - (r (zerop (% kind 2)))) + (r (evenp kind))) (dotimes (_ 100) (let* ((n (random (ash 1 bitlen))) (i (- n (ash 1 (1- bitlen)))) diff --git a/test/lisp/emacs-lisp/seq-tests.el b/test/lisp/emacs-lisp/seq-tests.el index ddca2d7ed93..a8ed51e8e70 100644 --- a/test/lisp/emacs-lisp/seq-tests.el +++ b/test/lisp/emacs-lisp/seq-tests.el @@ -49,14 +49,6 @@ Evaluate BODY for each created sequence. "Return t if SEQ1 and SEQ2 have the same contents, nil otherwise." (equal (append seq1 '()) (append seq2 '()))) -(defun test-sequences-evenp (integer) - "Return t if INTEGER is even." - (eq (logand integer 1) 0)) - -(defun test-sequences-oddp (integer) - "Return t if INTEGER is odd." - (not (test-sequences-evenp integer))) - (ert-deftest test-setf-seq-elt () (with-test-sequences (seq '(1 2 3)) (setf (seq-elt seq 1) 4) @@ -83,22 +75,22 @@ Evaluate BODY for each created sequence. (ert-deftest test-seq-drop-while () (with-test-sequences (seq '(1 3 2 4)) - (should (equal (seq-drop-while #'test-sequences-oddp seq) + (should (equal (seq-drop-while #'oddp seq) (seq-drop seq 2))) - (should (equal (seq-drop-while #'test-sequences-evenp seq) + (should (equal (seq-drop-while #'evenp seq) seq)) (should (seq-empty-p (seq-drop-while #'numberp seq)))) (with-test-sequences (seq '()) - (should (seq-empty-p (seq-drop-while #'test-sequences-oddp seq))))) + (should (seq-empty-p (seq-drop-while #'oddp seq))))) (ert-deftest test-seq-take-while () (with-test-sequences (seq '(1 3 2 4)) - (should (equal (seq-take-while #'test-sequences-oddp seq) + (should (equal (seq-take-while #'oddp seq) (seq-take seq 2))) - (should (seq-empty-p (seq-take-while #'test-sequences-evenp seq))) + (should (seq-empty-p (seq-take-while #'evenp seq))) (should (equal (seq-take-while #'numberp seq) seq))) (with-test-sequences (seq '()) - (should (seq-empty-p (seq-take-while #'test-sequences-oddp seq))))) + (should (seq-empty-p (seq-take-while #'oddp seq))))) (ert-deftest test-seq-map-indexed () (should (equal (seq-map-indexed (lambda (elt i) @@ -123,19 +115,19 @@ Evaluate BODY for each created sequence. (ert-deftest test-seq-filter () (with-test-sequences (seq '(6 7 8 9 10)) - (should (equal (seq-filter #'test-sequences-evenp seq) '(6 8 10))) - (should (equal (seq-filter #'test-sequences-oddp seq) '(7 9))) + (should (equal (seq-filter #'evenp seq) '(6 8 10))) + (should (equal (seq-filter #'oddp seq) '(7 9))) (should (equal (seq-filter (lambda (_) nil) seq) '()))) (with-test-sequences (seq '()) - (should (equal (seq-filter #'test-sequences-evenp seq) '())))) + (should (equal (seq-filter #'evenp seq) '())))) (ert-deftest test-seq-remove () (with-test-sequences (seq '(6 7 8 9 10)) - (should (equal (seq-remove #'test-sequences-evenp seq) '(7 9))) - (should (equal (seq-remove #'test-sequences-oddp seq) '(6 8 10))) + (should (equal (seq-remove #'evenp seq) '(7 9))) + (should (equal (seq-remove #'oddp seq) '(6 8 10))) (should (same-contents-p (seq-remove (lambda (_) nil) seq) seq))) (with-test-sequences (seq '()) - (should (equal (seq-remove #'test-sequences-evenp seq) '())))) + (should (equal (seq-remove #'evenp seq) '())))) (ert-deftest test-seq-remove-at-position () (with-test-sequences (seq '(1 2 3 4)) @@ -147,11 +139,11 @@ Evaluate BODY for each created sequence. (ert-deftest test-seq-count () (with-test-sequences (seq '(6 7 8 9 10)) - (should (equal (seq-count #'test-sequences-evenp seq) 3)) - (should (equal (seq-count #'test-sequences-oddp seq) 2)) + (should (equal (seq-count #'evenp seq) 3)) + (should (equal (seq-count #'oddp seq) 2)) (should (equal (seq-count (lambda (_) nil) seq) 0))) (with-test-sequences (seq '()) - (should (equal (seq-count #'test-sequences-evenp seq) 0)))) + (should (equal (seq-count #'evenp seq) 0)))) (ert-deftest test-seq-reduce () (with-test-sequences (seq '(1 2 3 4)) @@ -163,17 +155,17 @@ Evaluate BODY for each created sequence. (ert-deftest test-seq-some () (with-test-sequences (seq '(4 3 2 1)) - (should (seq-some #'test-sequences-evenp seq)) - (should (seq-some #'test-sequences-oddp seq)) + (should (seq-some #'evenp seq)) + (should (seq-some #'oddp seq)) (should-not (seq-some (lambda (elt) (> elt 10)) seq))) (with-test-sequences (seq '()) - (should-not (seq-some #'test-sequences-oddp seq))) + (should-not (seq-some #'oddp seq))) (should (seq-some #'null '(1 nil 2)))) (ert-deftest test-seq-find () (with-test-sequences (seq '(4 3 2 1)) - (should (= 4 (seq-find #'test-sequences-evenp seq))) - (should (= 3 (seq-find #'test-sequences-oddp seq))) + (should (= 4 (seq-find #'evenp seq))) + (should (= 3 (seq-find #'oddp seq))) (should-not (seq-find (lambda (elt) (> elt 10)) seq))) (should-not (seq-find #'null '(1 nil 2))) (should-not (seq-find #'null '(1 nil 2) t)) @@ -209,14 +201,14 @@ Evaluate BODY for each created sequence. (ert-deftest test-seq-every-p () (with-test-sequences (seq '(43 54 22 1)) (should (seq-every-p (lambda (_) t) seq)) - (should-not (seq-every-p #'test-sequences-oddp seq)) - (should-not (seq-every-p #'test-sequences-evenp seq))) + (should-not (seq-every-p #'oddp seq)) + (should-not (seq-every-p #'evenp seq))) (with-test-sequences (seq '(42 54 22 2)) - (should (seq-every-p #'test-sequences-evenp seq)) - (should-not (seq-every-p #'test-sequences-oddp seq))) + (should (seq-every-p #'evenp seq)) + (should-not (seq-every-p #'oddp seq))) (with-test-sequences (seq '()) (should (seq-every-p #'identity seq)) - (should (seq-every-p #'test-sequences-evenp seq)))) + (should (seq-every-p #'evenp seq)))) (ert-deftest test-seq-set-equal-p () (with-test-sequences (seq1 '(1 2 3)) @@ -340,7 +332,7 @@ Evaluate BODY for each created sequence. (ert-deftest test-seq-group-by () (with-test-sequences (seq '(1 2 3 4)) - (should (equal (seq-group-by #'test-sequences-oddp seq) + (should (equal (seq-group-by #'oddp seq) '((t 1 3) (nil 2 4))))) (should (equal (seq-group-by #'car '((a 1) (b 3) (c 4) (a 2))) '((b (b 3)) (c (c 4)) (a (a 1) (a 2)))))) diff --git a/test/lisp/eshell/em-pred-tests.el b/test/lisp/eshell/em-pred-tests.el index db8ce2c45a3..a050c6426e9 100644 --- a/test/lisp/eshell/em-pred-tests.el +++ b/test/lisp/eshell/em-pred-tests.el @@ -142,7 +142,7 @@ behavior for real files. (let ((attrs (eshell-parse-file-name-attributes file))) ;; For simplicity, just return whether the file is ;; world-executable. - (= (logand (or (alist-get 'modes attrs) 0) 1) 1))))) + (oddp (or (alist-get 'modes attrs) 0)))))) ,@body)) ;;; Tests: diff --git a/test/lisp/filenotify-tests.el b/test/lisp/filenotify-tests.el index 4b4f054bb33..8744dc4987a 100644 --- a/test/lisp/filenotify-tests.el +++ b/test/lisp/filenotify-tests.el @@ -1241,7 +1241,7 @@ delivered." ;; It matters which direction we rename, at least for ;; kqueue. This backend parses directories in alphabetic ;; order (x%d before y%d). So we rename into both directions. - (if (zerop (mod i 2)) + (if (evenp i) (progn (push (expand-file-name (format "x%d" i)) source-file-list) (push (expand-file-name (format "y%d" i)) target-file-list)) @@ -1469,7 +1469,7 @@ the file watch." (make-list (/ n 2) 'created))) (dotimes (i n) (file-notify--test-wait-event) - (if (zerop (mod i 2)) + (if (evenp i) (write-region "any text" nil file-notify--test-tmpfile1 t 'no-message) (let ((file-notify--test-tmpdir file-notify--test-tmpfile)) diff --git a/test/src/floatfns-tests.el b/test/src/floatfns-tests.el index 6820130a017..04ee97a6137 100644 --- a/test/src/floatfns-tests.el +++ b/test/src/floatfns-tests.el @@ -120,7 +120,7 @@ -2 -1 0 1 2)) (should (or (<= n 0) (= (expt 0 n) 0))) (should (= (expt 1 n) 1)) - (should (or (< n 0) (= (expt -1 n) (if (zerop (logand n 1)) 1 -1)))) + (should (or (< n 0) (= (expt -1 n) (if (evenp n) 1 -1)))) (should (= (expt n 0) 1)) (should (= (expt n 1) n)) (should (= (expt n 2) (* n n))) @@ -167,7 +167,7 @@ (should (if (zerop r) (= 0 cdelta fdelta rdelta) (or (/= cdelta fdelta) - (zerop (% (round n d) 2))))))))))) + (evenp (round n d))))))))))) (ert-deftest special-round () (dolist (f '(ceiling floor round truncate)) diff --git a/test/src/undo-tests.el b/test/src/undo-tests.el index 6150e09c52e..c0984c13ea6 100644 --- a/test/src/undo-tests.el +++ b/test/src/undo-tests.el @@ -150,7 +150,7 @@ (with-temp-buffer (buffer-enable-undo) (dotimes (i 1048576) - (if (zerop (% i 2)) + (if (evenp i) (insert "Evenses") (insert "Oddses"))) (undo-boundary) From e373a6e0d30c28045a0f33e662933c2c2660a220 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Mon, 17 Feb 2025 05:06:20 +0100 Subject: [PATCH 31/56] Prefer '(oddp A)' to '(= 1 (% A 2))' * lisp/align.el (align-match-tex-pattern): * lisp/calc/calc-funcs.el (math-bernoulli-number): * lisp/cedet/semantic/bovine/el.el (semantic-ctxt-current-assignment): * lisp/comint.el (comint-within-quotes): * lisp/emacs-lisp/chart.el (chart-axis-draw): * lisp/emacs-lisp/cl-extra.el (cl-round): * lisp/emacs-lisp/eieio.el (defclass): * lisp/emacs-lisp/elint.el (elint-check-setq-form): * lisp/emulation/cua-rect.el (cua--rectangle-right-side): * lisp/progmodes/gud.el (gud-gdb-completions-1): * lisp/ps-print.el (ps-end-job): * lisp/ses.el (ses-center): * lisp/vc/ediff-ptch.el (ediff-get-patch-buffer): Prefer '(oddp A)' to '(= 1 (% A 2))' and variations thereof. --- lisp/align.el | 2 +- lisp/calc/calc-funcs.el | 2 +- lisp/cedet/semantic/bovine/el.el | 2 +- lisp/comint.el | 2 +- lisp/emacs-lisp/chart.el | 2 +- lisp/emacs-lisp/cl-extra.el | 2 +- lisp/emacs-lisp/eieio.el | 2 +- lisp/emacs-lisp/elint.el | 2 +- lisp/emulation/cua-rect.el | 2 +- lisp/progmodes/gud.el | 2 +- lisp/ps-print.el | 2 +- lisp/ses.el | 2 +- lisp/vc/ediff-ptch.el | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lisp/align.el b/lisp/align.el index 6467c2b6f57..4263dfe0fa0 100644 --- a/lisp/align.el +++ b/lisp/align.el @@ -1076,7 +1076,7 @@ current position." (while (and (> pos (point-min)) (eq (char-before pos) ?\\)) (setq count (1+ count) pos (1- pos))) - (eq (mod count 2) 1)) + (oddp count)) (goto-char (match-beginning (if reverse 1 2))))) result)) diff --git a/lisp/calc/calc-funcs.el b/lisp/calc/calc-funcs.el index 28e9c1f30bb..8535e580da7 100644 --- a/lisp/calc/calc-funcs.el +++ b/lisp/calc/calc-funcs.el @@ -867,7 +867,7 @@ (nreverse coefs))) (defun math-bernoulli-number (n) - (if (= (% n 2) 1) + (if (oddp n) (if (= n 1) '(frac -1 2) 0) diff --git a/lisp/cedet/semantic/bovine/el.el b/lisp/cedet/semantic/bovine/el.el index 436db3c8381..2f1e818e079 100644 --- a/lisp/cedet/semantic/bovine/el.el +++ b/lisp/cedet/semantic/bovine/el.el @@ -765,7 +765,7 @@ In Emacs Lisp this is easily defined by parenthesis bounding." (forward-comment 1) (setq start (point)) (forward-sexp 1) - (if (= (% count 2) 1) + (if (oddp count) (setq lastodd (buffer-substring-no-properties start (point)))) ) diff --git a/lisp/comint.el b/lisp/comint.el index 5d6d02207ad..cece5545bfb 100644 --- a/lisp/comint.el +++ b/lisp/comint.el @@ -1756,7 +1756,7 @@ Go to the history element by the absolute history position HIST-POS." Quotes are single and double." (let ((countsq (comint-how-many-region "\\(^\\|[^\\]\\)'" beg end)) (countdq (comint-how-many-region "\\(^\\|[^\\]\\)\"" beg end))) - (or (= (mod countsq 2) 1) (= (mod countdq 2) 1)))) + (or (oddp countsq) (oddp countdq)))) (defun comint-how-many-region (regexp beg end) "Return number of matches for REGEXP from BEG to END." diff --git a/lisp/emacs-lisp/chart.el b/lisp/emacs-lisp/chart.el index 6f2f85fc765..2a01501f99e 100644 --- a/lisp/emacs-lisp/chart.el +++ b/lisp/emacs-lisp/chart.el @@ -347,7 +347,7 @@ of the drawing." (odd nil) p1) (while s - (setq odd (= (% (length s) 2) 1)) + (setq odd (oddp (length s))) (setq r (chart-translate-namezone (oref a chart) i)) (if (eq dir 'vertical) (setq p (/ (+ (car r) (cdr r)) 2)) diff --git a/lisp/emacs-lisp/cl-extra.el b/lisp/emacs-lisp/cl-extra.el index 09470457d93..ab06682cf93 100644 --- a/lisp/emacs-lisp/cl-extra.el +++ b/lisp/emacs-lisp/cl-extra.el @@ -392,7 +392,7 @@ With two arguments, return rounding and remainder of their quotient." (res (cl-floor (+ x hy) y))) (if (and (= (car (cdr res)) 0) (= (+ hy hy) y) - (/= (% (car res) 2) 0)) + (oddp (car res))) (list (1- (car res)) hy) (list (car res) (- (car (cdr res)) hy)))) (let ((q (round (/ x y)))) diff --git a/lisp/emacs-lisp/eieio.el b/lisp/emacs-lisp/eieio.el index 1fa177b08da..8665934ebfd 100644 --- a/lisp/emacs-lisp/eieio.el +++ b/lisp/emacs-lisp/eieio.el @@ -118,7 +118,7 @@ and reference them using the function `class-option'." (/= 1 (% (length options-and-doc) 2))) (error "Too many arguments to `defclass'")) ((and (symbolp (car options-and-doc)) - (/= 0 (% (length options-and-doc) 2))) + (oddp (length options-and-doc))) (error "Too many arguments to `defclass'"))) (if (stringp (car options-and-doc)) diff --git a/lisp/emacs-lisp/elint.el b/lisp/emacs-lisp/elint.el index 0f5d15be838..b63bcd44edf 100644 --- a/lisp/emacs-lisp/elint.el +++ b/lisp/emacs-lisp/elint.el @@ -798,7 +798,7 @@ CODE can be a lambda expression, a macro, or byte-compiled code." (defun elint-check-setq-form (form env) "Lint the setq FORM in ENV." - (or (= (mod (length form) 2) 1) + (or (oddp (length form)) ;; (setq foo) is valid and equivalent to (setq foo nil). (elint-warning "Missing value in setq: %s" form)) (let ((newenv env) diff --git a/lisp/emulation/cua-rect.el b/lisp/emulation/cua-rect.el index 27eed91927f..e224d4ce248 100644 --- a/lisp/emulation/cua-rect.el +++ b/lisp/emulation/cua-rect.el @@ -187,7 +187,7 @@ Activates the region if needed. Only lasts until the region is deactivated." ;; t if point is on right side of rectangle. (if (and topbot (= (cua--rectangle-left) (cua--rectangle-right))) (< (cua--rectangle-corner) 2) - (= (mod (cua--rectangle-corner) 2) 1))) + (oddp (cua--rectangle-corner)))) (defun cua--rectangle-column () (if (cua--rectangle-right-side) diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el index 7ced54170ff..3cca55be3a7 100644 --- a/lisp/progmodes/gud.el +++ b/lisp/progmodes/gud.el @@ -919,7 +919,7 @@ CONTEXT is the text before COMMAND on the line." (while (string-match "\\([^'\\]\\|\\\\'\\)*'" str pos) (setq count (1+ count) pos (match-end 0))) - (and (= (mod count 2) 1) + (and (oddp count) (setq complete-list (list (concat str "'")))))) complete-list) diff --git a/lisp/ps-print.el b/lisp/ps-print.el index c1258db2c54..d133e0bad67 100644 --- a/lisp/ps-print.el +++ b/lisp/ps-print.el @@ -6462,7 +6462,7 @@ If FACE is not a valid face name, use default face." (replace-match (format "/Lines %d def\n/PageCount %d def" total-lines total-pages) t))))) ;; Set dummy page - (and ps-spool-duplex (= (mod ps-page-order 2) 1) + (and ps-spool-duplex (oddp ps-page-order) (let ((ps-n-up-printing 0)) (ps-header-sheet) (ps-output "/PrintHeader false def\n/ColumnIndex 0 def\n" diff --git a/lisp/ses.el b/lisp/ses.el index 88e83ae160b..d23cefc53f4 100644 --- a/lisp/ses.el +++ b/lisp/ses.el @@ -4105,7 +4105,7 @@ printer otherwise." value ; Too large for field, anyway. (setq half (make-string (/ width 2) fill)) (concat half value half - (if (> (% width 2) 0) (char-to-string fill)))))) + (if (oddp width) (char-to-string fill)))))) (defun ses-center-span (value &optional fill printer) "Print VALUE, centered within the span that starts in the current column diff --git a/lisp/vc/ediff-ptch.el b/lisp/vc/ediff-ptch.el index e83e7e95c0f..42b0d6850ef 100644 --- a/lisp/vc/ediff-ptch.el +++ b/lisp/vc/ediff-ptch.el @@ -552,7 +552,7 @@ an optional argument, then use it." ((and (integerp arg) (eq 0 (mod arg 2))) (setq patch-buf (ediff-prompt-for-patch-buffer))) ;; odd prefix arg: get patch from a file - ((and (integerp arg) (eq 1 (mod arg 2))) + ((and (integerp arg) (oddp arg)) (setq patch-buf (ediff-prompt-for-patch-file))) (t (setq patch-buf (if (y-or-n-p "Is the patch already in a buffer? ") From 89bdb57f24e0bdc1a3d33d7124d93c9a1b45fa1d Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Mon, 17 Feb 2025 05:10:33 +0100 Subject: [PATCH 32/56] Prefer '(evenp A)' to '(= 0 (% A 2))' * lisp/calc/calc-comb.el (math-prime-test): * lisp/calc/calc-keypd.el (calc-keypad-press): * lisp/calc/calc-math.el (math-sqrt): (math-sqrt-raw): * lisp/calc/calc-misc.el (math-iipow): (math-iipow-show): * lisp/calc/calc-stat.el (calcFunc-vmedian): * lisp/calendar/cal-tex.el (cal-tex-cursor-filofax-2week): (cal-tex-cursor-filofax-daily): * lisp/elec-pair.el (electric-pair-post-self-insert-function): * lisp/emacs-lisp/checkdoc.el (checkdoc-in-example-string-p): * lisp/emacs-lisp/eieio.el (defclass): * lisp/emacs-lisp/ert-x.el (ert-propertized-string): * lisp/emacs-lisp/ert.el (ert--significant-plist-keys): (ert--plist-difference-explanation): * lisp/emacs-lisp/helper.el (Helper-help-scroller): * lisp/emacs-lisp/pcase.el (pcase-setq): * lisp/files-x.el (setq-connection-local): * lisp/gnus/gnus-uu.el (gnus-uu-post-encoded): * lisp/gnus/message.el (message-make-in-reply-to): * lisp/gnus/nndiary.el (nndiary-last-occurrence): (nndiary-next-occurrence): * lisp/mail/rfc2047.el (rfc2047-decode-region): * lisp/play/5x5.el (5x5-draw-grid): * lisp/play/gametree.el (gametree-compute-reduced-score): (gametree-insert-new-leaf): (gametree-break-line-here): * lisp/play/zone.el (zone-fret): * lisp/vc/ediff-ptch.el (ediff-get-patch-buffer): * lisp/yank-media.el (yank-media--utf-16-p): Prefer '(evenp A)' to '(= 0 (% A 2))' and variations thereof. --- lisp/calc/calc-comb.el | 4 ++-- lisp/calc/calc-keypd.el | 2 +- lisp/calc/calc-math.el | 4 ++-- lisp/calc/calc-misc.el | 4 ++-- lisp/calc/calc-stat.el | 2 +- lisp/calendar/cal-tex.el | 6 +++--- lisp/elec-pair.el | 2 +- lisp/emacs-lisp/checkdoc.el | 2 +- lisp/emacs-lisp/eieio.el | 2 +- lisp/emacs-lisp/ert-x.el | 2 +- lisp/emacs-lisp/ert.el | 6 +++--- lisp/emacs-lisp/helper.el | 2 +- lisp/emacs-lisp/pcase.el | 2 +- lisp/files-x.el | 2 +- lisp/gnus/gnus-uu.el | 2 +- lisp/gnus/message.el | 2 +- lisp/gnus/nndiary.el | 8 ++++---- lisp/mail/rfc2047.el | 2 +- lisp/play/5x5.el | 2 +- lisp/play/gametree.el | 6 +++--- lisp/play/zone.el | 2 +- lisp/vc/ediff-ptch.el | 2 +- lisp/yank-media.el | 2 +- 23 files changed, 35 insertions(+), 35 deletions(-) diff --git a/lisp/calc/calc-comb.el b/lisp/calc/calc-comb.el index 1ac3347b758..6e2fc08fece 100644 --- a/lisp/calc/calc-comb.el +++ b/lisp/calc/calc-comb.el @@ -826,8 +826,8 @@ '(t)))) ((not (equal n (car math-prime-test-cache))) (cond ((if (consp n) - (= (% (nth 1 n) 2) 0) - (= (% n 2) 0)) + (evenp (nth 1 n)) + (evenp n)) '(nil 2)) ((if (consp n) (= (% (nth 1 n) 5) 0) diff --git a/lisp/calc/calc-keypd.el b/lisp/calc/calc-keypd.el index 2a9c8e75214..ad2b1741181 100644 --- a/lisp/calc/calc-keypd.el +++ b/lisp/calc/calc-keypd.el @@ -411,7 +411,7 @@ (if invhyp (calc-wrapper)) ; clear Inv and Hyp flags (unwind-protect (cond ((or (null cmd) - (= (% row 2) 0)) + (evenp row)) (beep)) ((and (> (minibuffer-depth) 0)) (cond (isstring diff --git a/lisp/calc/calc-math.el b/lisp/calc/calc-math.el index 53e5df30fad..49a64008e0a 100644 --- a/lisp/calc/calc-math.el +++ b/lisp/calc/calc-math.el @@ -402,7 +402,7 @@ If this can't be done, return NIL." (math-div (math-float num-sqrt) den-sqrt)))))) (and (eq (car-safe a) 'float) (if calc-symbolic-mode - (if (= (% (nth 2 a) 2) 0) + (if (evenp (nth 2 a)) (let ((res (cl-isqrt (nth 1 a)))) (if (= (* res res) (nth 1 a)) (math-make-float res (/ (nth 2 a) 2)) @@ -468,7 +468,7 @@ If this can't be done, return NIL." (t (if (null guess) (let ((ldiff (- (math-numdigs (nth 1 a)) 6))) - (or (= (% (+ (nth 2 a) ldiff) 2) 0) (setq ldiff (1+ ldiff))) + (or (evenp (+ (nth 2 a) ldiff)) (setq ldiff (1+ ldiff))) (setq guess (math-make-float (cl-isqrt (math-scale-int (nth 1 a) (- ldiff))) (/ (+ (nth 2 a) ldiff) 2))))) diff --git a/lisp/calc/calc-misc.el b/lisp/calc/calc-misc.el index 0772b76409a..564cbfc6537 100644 --- a/lisp/calc/calc-misc.el +++ b/lisp/calc/calc-misc.el @@ -898,7 +898,7 @@ loaded and the keystroke automatically re-typed." (defun math-iipow (a n) ; [O O S] (cond ((= n 0) 1) ((= n 1) a) - ((= (% n 2) 0) (math-iipow (math-mul a a) (/ n 2))) + ((evenp n) (math-iipow (math-mul a a) (/ n 2))) (t (math-mul a (math-iipow (math-mul a a) (/ n 2)))))) (defun math-iipow-show (a n) ; [O O S] @@ -906,7 +906,7 @@ loaded and the keystroke automatically re-typed." (let ((val (cond ((= n 0) 1) ((= n 1) a) - ((= (% n 2) 0) (math-iipow-show (math-mul a a) (/ n 2))) + ((evenp n) (math-iipow-show (math-mul a a) (/ n 2))) (t (math-mul a (math-iipow-show (math-mul a a) (/ n 2))))))) (math-working "pow" val) val)) diff --git a/lisp/calc/calc-stat.el b/lisp/calc/calc-stat.el index 57f42645e34..cbf85c51ab4 100644 --- a/lisp/calc/calc-stat.el +++ b/lisp/calc/calc-stat.el @@ -390,7 +390,7 @@ (math-reject-arg (car p) 'anglep)) (setq p (cdr p))) (setq flat (sort flat 'math-lessp)) - (if (= (% len 2) 0) + (if (evenp len) (math-div (math-add (nth (1- hlen) flat) (nth hlen flat)) 2) (nth hlen flat)))))) diff --git a/lisp/calendar/cal-tex.el b/lisp/calendar/cal-tex.el index c0bb9760810..f5bdfb970cc 100644 --- a/lisp/calendar/cal-tex.el +++ b/lisp/calendar/cal-tex.el @@ -1295,7 +1295,7 @@ Optional EVENT indicates a buffer position to use instead of point." (cal-tex-b-document) (cal-tex-cmd "\\pagestyle" "empty") (dotimes (i n) - (if (zerop (mod i 2)) + (if (evenp i) (insert "\\righthead") (insert "\\lefthead")) (cal-tex-arg @@ -1318,7 +1318,7 @@ Optional EVENT indicates a buffer position to use instead of point." (calendar-extract-year d)))))) (insert "%\n") (dotimes (_jdummy 7) - (if (zerop (mod i 2)) + (if (evenp i) (insert "\\rightday") (insert "\\leftday")) (cal-tex-arg (cal-tex-LaTeXify-string (calendar-day-name date))) @@ -1388,7 +1388,7 @@ Optional EVENT indicates a buffer position to use instead of point." (cal-tex-cmd "\\pagestyle" "empty") (dotimes (i n) (dotimes (j 4) - (let ((even (zerop (% j 2)))) + (let ((even (evenp j))) (insert (if even "\\righthead" "\\lefthead")) diff --git a/lisp/elec-pair.el b/lisp/elec-pair.el index 10c14e55eae..aa2577300fd 100644 --- a/lisp/elec-pair.el +++ b/lisp/elec-pair.el @@ -558,7 +558,7 @@ The decision is taken by order of preference: ;; Backslash-escaped: no pairing, no skipping. ((save-excursion (goto-char beg) - (not (zerop (% (skip-syntax-backward "\\") 2)))) + (not (evenp (skip-syntax-backward "\\")))) (let ((current-prefix-arg (1- num))) (electric-pair-post-self-insert-function))) ;; Skip self. diff --git a/lisp/emacs-lisp/checkdoc.el b/lisp/emacs-lisp/checkdoc.el index dd3da9ae8c0..3541e3d0a57 100644 --- a/lisp/emacs-lisp/checkdoc.el +++ b/lisp/emacs-lisp/checkdoc.el @@ -2109,7 +2109,7 @@ The text checked is between START and LIMIT." (goto-char start) (while (and (< (point) p) (re-search-forward "\\\\\"" limit t)) (setq c (1+ c))) - (and (< 0 c) (= (% c 2) 0)))))) + (and (< 0 c) (evenp c)))))) (defun checkdoc-in-abbreviation-p (begin) "Return non-nil if point is at an abbreviation. diff --git a/lisp/emacs-lisp/eieio.el b/lisp/emacs-lisp/eieio.el index 8665934ebfd..0f029813f80 100644 --- a/lisp/emacs-lisp/eieio.el +++ b/lisp/emacs-lisp/eieio.el @@ -115,7 +115,7 @@ and reference them using the function `class-option'." (cl-check-type superclasses list) (cond ((and (stringp (car options-and-doc)) - (/= 1 (% (length options-and-doc) 2))) + (evenp (length options-and-doc))) (error "Too many arguments to `defclass'")) ((and (symbolp (car options-and-doc)) (oddp (length options-and-doc))) diff --git a/lisp/emacs-lisp/ert-x.el b/lisp/emacs-lisp/ert-x.el index 147787d3d38..0dacec130a0 100644 --- a/lisp/emacs-lisp/ert-x.el +++ b/lisp/emacs-lisp/ert-x.el @@ -260,7 +260,7 @@ structure with the plists in ARGS." (string (let ((begin (point))) (insert x) (set-text-properties begin (point) current-plist))) - (list (unless (zerop (mod (length x) 2)) + (list (unless (evenp (length x)) (error "Odd number of args in plist: %S" x)) (setq current-plist x)))) (buffer-string))) diff --git a/lisp/emacs-lisp/ert.el b/lisp/emacs-lisp/ert.el index 5d1b9f2acbb..e8012326eb3 100644 --- a/lisp/emacs-lisp/ert.el +++ b/lisp/emacs-lisp/ert.el @@ -576,7 +576,7 @@ Return nil if they are." (defun ert--significant-plist-keys (plist) "Return the keys of PLIST that have non-null values, in order." - (cl-assert (zerop (mod (length plist) 2)) t) + (cl-assert (evenp (length plist)) t) (cl-loop for (key value . rest) on plist by #'cddr unless (or (null value) (memq key accu)) collect key into accu finally (cl-return accu))) @@ -587,8 +587,8 @@ Return nil if they are." Returns nil if they are equivalent, i.e., have the same value for each key, where absent values are treated as nil. The order of key/value pairs in each list does not matter." - (cl-assert (zerop (mod (length a) 2)) t) - (cl-assert (zerop (mod (length b) 2)) t) + (cl-assert (evenp (length a)) t) + (cl-assert (evenp (length b)) t) ;; Normalizing the plists would be another way to do this but it ;; requires a total ordering on all lisp objects (since any object ;; is valid as a text property key). Perhaps defining such an diff --git a/lisp/emacs-lisp/helper.el b/lisp/emacs-lisp/helper.el index d8f758d2fe5..8a173219545 100644 --- a/lisp/emacs-lisp/helper.el +++ b/lisp/emacs-lisp/helper.el @@ -80,7 +80,7 @@ (recenter)) ((and (or (eq continue 'backspace) (eq continue ?\177)) - (zerop (% state 2))) + (evenp state)) (scroll-down)) (t (setq continue nil)))))))) diff --git a/lisp/emacs-lisp/pcase.el b/lisp/emacs-lisp/pcase.el index a6a4751f49a..c68b8961ee3 100644 --- a/lisp/emacs-lisp/pcase.el +++ b/lisp/emacs-lisp/pcase.el @@ -370,7 +370,7 @@ undetected, binding variables to arbitrary values, such as nil. (cond (args (let ((arg-length (length args))) - (unless (= 0 (mod arg-length 2)) + (unless (evenp arg-length) (signal 'wrong-number-of-arguments (list 'pcase-setq (+ 2 arg-length))))) (let ((result)) diff --git a/lisp/files-x.el b/lisp/files-x.el index 0e8b99c1e4f..3f57321eb53 100644 --- a/lisp/files-x.el +++ b/lisp/files-x.el @@ -914,7 +914,7 @@ earlier in the `setq-connection-local'. The return value of the \(fn [VARIABLE VALUE]...)" (declare (debug setq)) - (unless (zerop (mod (length pairs) 2)) + (unless (evenp (length pairs)) (error "PAIRS must have an even number of variable/value members")) (let ((set-expr nil) (profile-vars nil)) diff --git a/lisp/gnus/gnus-uu.el b/lisp/gnus/gnus-uu.el index 4372fd58669..bf745be0f6e 100644 --- a/lisp/gnus/gnus-uu.el +++ b/lisp/gnus/gnus-uu.el @@ -2098,7 +2098,7 @@ If no file has been included, the user will be asked for a file." (make-string minlen ?-) file-name i parts (make-string - (if (= 0 (% whole-len 2)) (1- minlen) minlen) ?-))) + (if (evenp whole-len) (1- minlen) minlen) ?-))) (goto-char (point-min)) (when (re-search-forward "^Subject: " nil t) diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el index dede5520d66..46c3550418f 100644 --- a/lisp/gnus/message.el +++ b/lisp/gnus/message.el @@ -6035,7 +6035,7 @@ In posting styles use `(\"Expires\" (make-expires-date 30))'." (while (search-forward "\"" nil t) (when (prog2 (backward-char) - (zerop (% (skip-chars-backward "\\\\") 2)) + (evenp (skip-chars-backward "\\\\")) (goto-char (match-beginning 0))) (insert "\\")) (forward-char)) diff --git a/lisp/gnus/nndiary.el b/lisp/gnus/nndiary.el index de051745f92..7bc46fa88f8 100644 --- a/lisp/gnus/nndiary.el +++ b/lisp/gnus/nndiary.el @@ -1353,9 +1353,9 @@ all. This may very well take some time.") (max (cond ((= month 2) (if (date-leap-year-p year) 29 28)) ((<= month 7) - (if (zerop (% month 2)) 30 31)) + (if (evenp month) 30 31)) (t - (if (zerop (% month 2)) 31 30)))) + (if (evenp month) 31 30)))) (doms dom-list) (dows dow-list) day days) @@ -1456,9 +1456,9 @@ all. This may very well take some time.") (max (cond ((= month 2) (if (date-leap-year-p year) 29 28)) ((<= month 7) - (if (zerop (% month 2)) 30 31)) + (if (evenp month) 30 31)) (t - (if (zerop (% month 2)) 31 30)))) + (if (evenp month) 31 30)))) (doms dom-list) (dows dow-list) day days) diff --git a/lisp/mail/rfc2047.el b/lisp/mail/rfc2047.el index 38b924851fc..13d1ac320b0 100644 --- a/lisp/mail/rfc2047.el +++ b/lisp/mail/rfc2047.el @@ -1076,7 +1076,7 @@ other than `\"' and `\\' in quoted strings." (while (search-forward "\"" end t) (when (prog2 (backward-char) - (zerop (% (skip-chars-backward "\\\\") 2)) + (evenp (skip-chars-backward "\\\\")) (goto-char (match-beginning 0))) (insert "\\")) (forward-char)) diff --git a/lisp/play/5x5.el b/lisp/play/5x5.el index 3c5a3601927..e7638ef0f59 100644 --- a/lisp/play/5x5.el +++ b/lisp/play/5x5.el @@ -312,7 +312,7 @@ Quit current game \\[5x5-quit-game]" (forward-char (+ 1 (/ (1+ 5x5-x-scale) 2))) (dotimes (x 5x5-grid-size) (when (5x5-cell solution-grid y x) - (if (= 0 (mod 5x5-x-scale 2)) + (if (evenp 5x5-x-scale) (progn (insert "()") (delete-region (point) (+ (point) 2)) diff --git a/lisp/play/gametree.el b/lisp/play/gametree.el index c0d43944e67..8ffddfc7275 100644 --- a/lisp/play/gametree.el +++ b/lisp/play/gametree.el @@ -347,7 +347,7 @@ Subnodes which have been manually scored are honored." ;; be either a leaf child, or a subheading. (let ((running gametree-default-score) (minmax - (if (= 0 (mod (gametree-current-branch-ply) 2)) + (if (evenp (gametree-current-branch-ply)) 'max 'min))) (while (and (not (eobp)) (= 0 (gametree-current-branch-depth))) ;handle leaves @@ -395,7 +395,7 @@ depth AT-DEPTH or smaller is found." (gametree-current-branch-ply))))) (goto-char (1- (point))) (insert "\n") - (insert (format (if (= 0 (mod starting-plies 2)) + (insert (format (if (evenp starting-plies) gametree-full-ply-format gametree-half-ply-format) (/ starting-plies 2)))))) @@ -450,7 +450,7 @@ only work of Black's moves are explicitly numbered, for instance gametree-full-ply-regexp "\\|" gametree-half-ply-regexp "\\)"))) (progn - (insert (format (if (= 0 (mod (gametree-looking-at-ply) 2)) + (insert (format (if (evenp (gametree-looking-at-ply)) gametree-full-ply-format gametree-half-ply-format) (/ (gametree-looking-at-ply) 2))) diff --git a/lisp/play/zone.el b/lisp/play/zone.el index b294dd6af67..39a33f1e2a0 100644 --- a/lisp/play/zone.el +++ b/lisp/play/zone.el @@ -454,7 +454,7 @@ run a specific program. The program must be a member of (dotimes (i 20) (goto-char pos) (delete-char 1) - (insert (if (= 0 (% i 2)) hmm c-string)) + (insert (if (evenp i) hmm c-string)) (zone-park/sit-for wbeg (setq wait (* wait 0.8)))) (delete-char -1) (insert c-string))) diff --git a/lisp/vc/ediff-ptch.el b/lisp/vc/ediff-ptch.el index 42b0d6850ef..1e66a016375 100644 --- a/lisp/vc/ediff-ptch.el +++ b/lisp/vc/ediff-ptch.el @@ -549,7 +549,7 @@ an optional argument, then use it." (cond ((ediff-buffer-live-p patch-buf)) ;; even prefix arg: patch in buffer - ((and (integerp arg) (eq 0 (mod arg 2))) + ((and (integerp arg) (evenp arg)) (setq patch-buf (ediff-prompt-for-patch-buffer))) ;; odd prefix arg: get patch from a file ((and (integerp arg) (oddp arg)) diff --git a/lisp/yank-media.el b/lisp/yank-media.el index 600cc0ffaf5..bb62ba272d3 100644 --- a/lisp/yank-media.el +++ b/lisp/yank-media.el @@ -172,7 +172,7 @@ non-supported selection data types." data))) (defun yank-media--utf-16-p (data) - (and (zerop (mod (length data) 2)) + (and (evenp (length data)) (let ((stats (vector 0 0))) (dotimes (i (length data)) (when (zerop (elt data i)) From 0e4d08f3dc7c76008da9cd912933a931c6e3e8d9 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Mon, 17 Feb 2025 15:17:00 +0800 Subject: [PATCH 33/56] ; More strongly discountenance Markdown-style quotes * CONTRIBUTE (Commit messages): Discourage quoting with Markdown-style pairs of backticks. * build-aux/git-hooks/prepare-commit-msg: Detect and reject commit messages with Markdown-style quotes. --- CONTRIBUTE | 10 ++++++---- build-aux/git-hooks/prepare-commit-msg | 12 ++++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/CONTRIBUTE b/CONTRIBUTE index 0ab45a99ee2..336f6f0ce00 100644 --- a/CONTRIBUTE +++ b/CONTRIBUTE @@ -276,10 +276,12 @@ formatting them: - Emacs follows the GNU coding standards for ChangeLog entries: see https://www.gnu.org/prep/standards/html_node/Change-Logs.html or run - 'info "(standards)Change Logs"'. One exception is that commits - still sometimes quote `like-this' (as the standards used to - recommend) rather than 'like-this' or ‘like this’ (as they do now), - as `...' is so widely used elsewhere in Emacs. + 'info "(standards)Change Logs"'. One exception is that commits still + sometimes quote `like-this' (as the standards used to recommend) + rather than 'like-this' or ‘like this’ (as they do now), as `...' is + so widely used elsewhere in Emacs. Please do not adopt the ugly + Markdown convention where quoting is performed with pairs of backticks + in any circumstances. That is to say, never quote `like this`. - Some commenting rules in the GNU coding standards also apply to ChangeLog entries: they must be in English, and be complete diff --git a/build-aux/git-hooks/prepare-commit-msg b/build-aux/git-hooks/prepare-commit-msg index eefecaa1556..7761f46e5e0 100755 --- a/build-aux/git-hooks/prepare-commit-msg +++ b/build-aux/git-hooks/prepare-commit-msg @@ -33,17 +33,21 @@ else awk="awk" fi -exec $awk ' +exec $awk " # Catch the case when someone ran git-commit with -s option, # which automatically adds Signed-off-by. /^Signed-off-by: / { - print "'\''Signed-off-by:'\'' in commit message" + print \"'Signed-off-by:' in commit message\" + status = 1 + } + /(^|[^\\\\])\`[^'\`]+\`/ { + print \"Markdown-style quotes in commit message\" status = 1 } END { if (status != 0) { - print "Commit aborted; please see the file 'CONTRIBUTE'" + print \"Commit aborted; please see the file 'CONTRIBUTE'\" } exit status } -' <"$COMMIT_MSG_FILE" +" <"$COMMIT_MSG_FILE" From 05a96fd39809f11a3820e2164b23ebf9df192b13 Mon Sep 17 00:00:00 2001 From: Vincenzo Pupillo Date: Fri, 14 Feb 2025 18:38:51 +0100 Subject: [PATCH 34/56] Add mhtml-ts-mode. New major-mode alternative to mhtml-mode, based on treesitter, for editing files containing html, javascript and css. * etc/NEWS: Mention the new mode and new functions. * lisp/textmodes/mhtml-ts-mode.el: New file. * lisp/progmodes/js.el (js--treesit-thing-settings): New variable. (js--treesit-font-lock-feature-list); New variable. (js--treesit-simple-imenu-settings): New variable. (js--treesit-defun-type-regexp): New variable. (js--treesit-jsdoc-comment-regexp): New variable. (js-ts-mode): Use of new variables instead of direct assignment of values. * lisp/textmodes/css-mode.el (css-mode--menu): New variable. (css-mode-map): Use new variable. (css--treesit-font-lock-feature-list): New variable. (css--treesit-simple-imenu-settings): New variable. (css--treesit-defun-type-regexp): New variable. (cs-ts-mode): Use of new variables instead of direct assignment of values. * lisp/textmodes/html-ts-mode.el (html-ts-mode--treesit-things-settings): New variable. (html-ts-mode--treesit-font-lock-feature-list): New variable. (html-ts-mode--treesit-simple-imenu-settings): New variable. (html-ts-mode--treesit-defun-type-regexp): New variable. (html-ts-mode): Use of new variables instead of direct assignment of values. * lisp/treesit.el (treesit-merge-font-lock-feature-list): New fuction. (treesit-replace-font-lock-feature-settings): New fuction. (treesit-modify-indent-rules): New function. --- etc/NEWS | 29 ++ lisp/progmodes/js.el | 72 ++-- lisp/textmodes/css-mode.el | 47 ++- lisp/textmodes/html-ts-mode.el | 54 +-- lisp/textmodes/mhtml-ts-mode.el | 594 ++++++++++++++++++++++++++++++++ lisp/treesit.el | 68 ++++ 6 files changed, 801 insertions(+), 63 deletions(-) create mode 100644 lisp/textmodes/mhtml-ts-mode.el diff --git a/etc/NEWS b/etc/NEWS index a0d0f8b9818..a0d81608103 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1217,6 +1217,12 @@ runs its body, and removes the current buffer from * New Modes and Packages in Emacs 31.1 +** New major modes based on the tree-sitter library + +*** New major mode 'mhtml-ts-mode'. +An optional major mode based on the tree-sitter library for editing html +files. This mode handles indentation, fontification, and commenting for +embedded JavaScript and CSS. * Incompatible Lisp Changes in Emacs 31.1 @@ -1370,6 +1376,29 @@ language symbol. For example, 'cpp' is translated to "C++". A new variable 'treesit-language-display-name-alist' holds the translations of language symbols where that translation is not trivial. ++++ +++++ +*** New function 'treesit-merge-font-lock-feature-list'. +This function the merge two tree-sitter font lock feature lists. +Returns a new font lock feature list with no duplicates in the same level. +It can be used to merge font lock feature lists in a multi-language major mode. + ++++ +*** New function 'treesit-replace-font-lock-feature-settings'. +Given two treesit-font-lock-settings replaces the feature in the second +font-lock-settings with the same feature in the first +font-lock-settings. In a multi-linguage major mode it is sometimes +necessary to replace features from one of the major modes, with others +that are better suited to the new multilingual context. + ++++ +*** New function 'treesit-modify-indent-rules'. +Given two treesit ident rules, it replaces, adds, or prepends the new +rules to the old ones, then returns a new treesit indent rules. +In a multi-linguage major mode it is sometimes necessary to modify rules +from one of the major modes, with others that are better suited to the +new multilingual context. + +++ *** New command 'treesit-explore'. This command replaces 'treesit-explore-mode'. It turns on diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 3168395acf1..f2acf9f40d6 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -3920,6 +3920,44 @@ See `treesit-thing-settings' for more information.") (defvar js--treesit-jsdoc-beginning-regexp (rx bos "/**") "Regular expression matching the beginning of a jsdoc block comment.") +(defvar js--treesit-thing-settings + `((javascript + (sexp ,(js--regexp-opt-symbol js--treesit-sexp-nodes)) + (list ,(js--regexp-opt-symbol js--treesit-list-nodes)) + (sentence ,(js--regexp-opt-symbol js--treesit-sentence-nodes)) + (text ,(js--regexp-opt-symbol '("comment" + "string_fragment"))))) + "Settings for `treesit-thing-settings'.") + +(defvar js--treesit-font-lock-feature-list + '(( comment document definition) + ( keyword string) + ( assignment constant escape-sequence jsx number + pattern string-interpolation) + ( bracket delimiter function operator property)) + "Settings for `treesit-font-lock-feature-list'.") + +(defvar js--treesit-simple-imenu-settings + `(("Function" "\\`function_declaration\\'" nil nil) + ("Variable" "\\`lexical_declaration\\'" + js--treesit-valid-imenu-entry nil) + ("Class" ,(rx bos (or "class_declaration" + "method_definition") + eos) + nil nil)) + "Settings for `treesit-simple-imenu'.") + +(defvar js--treesit-defun-type-regexp + (rx (or "class_declaration" + "method_definition" + "function_declaration" + "lexical_declaration")) + "Settings for `treesit-defun-type-regexp'.") + +(defvar js--treesit-jsdoc-comment-regexp + (rx (or "comment" "line_comment" "block_comment" "description")) + "Regexp for `c-ts-common--comment-regexp'.") + ;;;###autoload (define-derived-mode js-ts-mode js-base-mode "JavaScript" "Major mode for editing JavaScript. @@ -3951,29 +3989,15 @@ See `treesit-thing-settings' for more information.") ;; Indent. (setq-local treesit-simple-indent-rules js--treesit-indent-rules) ;; Navigation. - (setq-local treesit-defun-type-regexp - (rx (or "class_declaration" - "method_definition" - "function_declaration" - "lexical_declaration"))) + (setq-local treesit-defun-type-regexp js--treesit-defun-type-regexp) + (setq-local treesit-defun-name-function #'js--treesit-defun-name) - (setq-local treesit-thing-settings - `((javascript - (sexp ,(js--regexp-opt-symbol js--treesit-sexp-nodes)) - (list ,(js--regexp-opt-symbol js--treesit-list-nodes)) - (sentence ,(js--regexp-opt-symbol js--treesit-sentence-nodes)) - (text ,(js--regexp-opt-symbol '("comment" - "string_fragment")))))) + (setq-local treesit-thing-settings js--treesit-thing-settings) ;; Fontification. (setq-local treesit-font-lock-settings js--treesit-font-lock-settings) - (setq-local treesit-font-lock-feature-list - '(( comment document definition) - ( keyword string) - ( assignment constant escape-sequence jsx number - pattern string-interpolation) - ( bracket delimiter function operator property))) + (setq-local treesit-font-lock-feature-list js--treesit-font-lock-feature-list) (when (treesit-ready-p 'jsdoc t) (setq-local treesit-range-settings @@ -3983,17 +4007,11 @@ See `treesit-thing-settings' for more information.") :local t `(((comment) @capture (:match ,js--treesit-jsdoc-beginning-regexp @capture))))) - (setq c-ts-common--comment-regexp (rx (or "comment" "line_comment" "block_comment" "description")))) + (setq c-ts-common--comment-regexp js--treesit-jsdoc-comment-regexp)) ;; Imenu - (setq-local treesit-simple-imenu-settings - `(("Function" "\\`function_declaration\\'" nil nil) - ("Variable" "\\`lexical_declaration\\'" - js--treesit-valid-imenu-entry nil) - ("Class" ,(rx bos (or "class_declaration" - "method_definition") - eos) - nil nil))) + (setq-local treesit-simple-imenu-settings js--treesit-simple-imenu-settings) + (treesit-major-mode-setup) (add-to-list 'auto-mode-alist diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index 53340195386..35c61e4f66d 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -893,13 +893,7 @@ cannot be completed sensibly: `custom-ident', (modify-syntax-entry ?? "." st) st)) -(defvar-keymap css-mode-map - :doc "Keymap used in `css-mode'." - " " #'css-lookup-symbol - ;; `info-complete-symbol' is not used. - " " #'completion-at-point - "C-c C-f" #'css-cycle-color-format - :menu +(defvar css-mode--menu '("CSS" :help "CSS-specific features" ["Reformat block" fill-paragraph @@ -910,7 +904,17 @@ cannot be completed sensibly: `custom-ident', ["Describe symbol" css-lookup-symbol :help "Display documentation for a CSS symbol"] ["Complete symbol" completion-at-point - :help "Complete symbol before point"])) + :help "Complete symbol before point"]) + "Menu bar for `css-mode'") + +(defvar-keymap css-mode-map + :doc "Keymap used in `css-mode'." + " " #'css-lookup-symbol + ;; `info-complete-symbol' is not used. + " " #'completion-at-point + "C-c C-f" #'css-cycle-color-format + :menu + css-mode--menu) (eval-and-compile (defconst css--uri-re @@ -1771,6 +1775,21 @@ rgb()/rgba()." (replace-regexp-in-string "[\n ]+" " " s))) res))))))) +(defvar css--treesit-font-lock-feature-list + '((selector comment query keyword) + (property constant string) + (error variable function operator bracket)) + "Settings for `treesit-font-lock-feature-list'.") + +(defvar css--treesit-simple-imenu-settings + `(( nil ,(rx bos (or "rule_set" "media_statement") eos) + nil nil)) + "Settings for `treesit-simple-imenu'.") + +(defvar css--treesit-defun-type-regexp + "rule_set" + "Settings for `treesit-defun-type-regexp'.") + (define-derived-mode css-base-mode prog-mode "CSS" "Generic mode to edit Cascading Style Sheets (CSS). @@ -1825,16 +1844,12 @@ can also be used to fill comments. ;; Tree-sitter specific setup. (setq treesit-primary-parser (treesit-parser-create 'css)) (setq-local treesit-simple-indent-rules css--treesit-indent-rules) - (setq-local treesit-defun-type-regexp "rule_set") + (setq-local treesit-defun-type-regexp css--treesit-defun-type-regexp) (setq-local treesit-defun-name-function #'css--treesit-defun-name) (setq-local treesit-font-lock-settings css--treesit-settings) - (setq-local treesit-font-lock-feature-list - '((selector comment query keyword) - (property constant string) - (error variable function operator bracket))) - (setq-local treesit-simple-imenu-settings - `(( nil ,(rx bos (or "rule_set" "media_statement") eos) - nil nil))) + (setq-local treesit-font-lock-feature-list css--treesit-font-lock-feature-list) + (setq-local treesit-simple-imenu-settings css--treesit-simple-imenu-settings) + (treesit-major-mode-setup) (add-to-list 'auto-mode-alist '("\\.css\\'" . css-ts-mode)))) diff --git a/lisp/textmodes/html-ts-mode.el b/lisp/textmodes/html-ts-mode.el index 0f07fbedeed..26efe1be726 100644 --- a/lisp/textmodes/html-ts-mode.el +++ b/lisp/textmodes/html-ts-mode.el @@ -88,6 +88,35 @@ `((attribute_name) @font-lock-variable-name-face)) "Tree-sitter font-lock settings for `html-ts-mode'.") +(defvar html-ts-mode--treesit-things-settings + `((html + (sexp ,(regexp-opt '("element" + "text" + "attribute" + "value"))) + (list ,(rx (or + ;; Also match script_element and style_element + "element" + ;; HTML comments have the element syntax + "comment"))) + (sentence ,(rx (and bos (or "tag_name" "attribute") eos))) + (text ,(regexp-opt '("comment" "text"))))) + "Settings for `treesit-thing-settings'.") + +(defvar html-ts-mode--treesit-font-lock-feature-list + '((comment keyword definition) + (property string) + () ()) + "Settings for `treesit-font-lock-feature-list'.") + +(defvar html-ts-mode--treesit-simple-imenu-settings + '((nil "element" nil nil)) + "Settings for `treesit-simple-imenu'.") + +(defvar html-ts-mode--treesit-defun-type-regexp + "element" + "Settings for `treesit-defun-type-regexp'.") + (defun html-ts-mode--defun-name (node) "Return the defun name of NODE. Return nil if there is no name or if NODE is not a defun node." @@ -120,33 +149,18 @@ Return nil if there is no name or if NODE is not a defun node." (setq-local treesit-simple-indent-rules html-ts-mode--indent-rules) ;; Navigation. - (setq-local treesit-defun-type-regexp "element") + (setq-local treesit-defun-type-regexp html-ts-mode--treesit-defun-type-regexp) + (setq-local treesit-defun-name-function #'html-ts-mode--defun-name) - (setq-local treesit-thing-settings - `((html - (sexp ,(regexp-opt '("element" - "text" - "attribute" - "value"))) - (list ,(rx (or - ;; Also match script_element and style_element - "element" - ;; HTML comments have the element syntax - "comment"))) - (sentence ,(rx (and bos (or "tag_name" "attribute") eos))) - (text ,(regexp-opt '("comment" "text")))))) + (setq-local treesit-thing-settings html-ts-mode--treesit-things-settings) ;; Font-lock. (setq-local treesit-font-lock-settings html-ts-mode--font-lock-settings) - (setq-local treesit-font-lock-feature-list - '((comment keyword definition) - (property string) - () ())) + (setq-local treesit-font-lock-feature-list html-ts-mode--treesit-font-lock-feature-list) ;; Imenu. - (setq-local treesit-simple-imenu-settings - '((nil "element" nil nil))) + (setq-local treesit-simple-imenu-settings html-ts-mode--treesit-simple-imenu-settings) ;; Outline minor mode. (setq-local treesit-outline-predicate #'html-ts-mode--outline-predicate) diff --git a/lisp/textmodes/mhtml-ts-mode.el b/lisp/textmodes/mhtml-ts-mode.el new file mode 100644 index 00000000000..9be1a14c257 --- /dev/null +++ b/lisp/textmodes/mhtml-ts-mode.el @@ -0,0 +1,594 @@ +;;; mhtml-ts-mode.el --- Major mode for HTML using tree-sitter -*- lexical-binding: t; -*- + +;; Copyright (C) 2024 Free Software Foundation, Inc. + +;; Author: Vincenzo Pupillo +;; Maintainer: Vincenzo Pupillo +;; Created: Nov 2024 +;; Keywords: HTML languages hypermedia tree-sitter + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . + +;;; Commentary: +;; +;; This package provides `mhtml-ts-mode' which is a major mode +;; for editing HTML files with embedded JavaScript and CSS. +;; Tree Sitter is used to parse each of these languages. +;; +;; Please note that this package requires `html-ts-mode', which +;; registers itself as the major mode for editing HTML. +;; +;; This package is compatible and has been tested with the following +;; tree-sitter grammars: +;; * https://github.com/tree-sitter/tree-sitter-html +;; * https://github.com/tree-sitter/tree-sitter-javascript +;; * https://github.com/tree-sitter/tree-sitter-jsdoc +;; * https://github.com/tree-sitter/tree-sitter-css +;; +;; Features +;; +;; * Indent +;; * Flymake +;; * IMenu +;; * Navigation +;; * Which-function +;; * Tree-sitter parser installation helper + +;;; Code: + +(require 'treesit) +(require 'html-ts-mode) +(require 'css-mode) ;; for embed css into html +(require 'js) ;; for embed javascript into html + +(eval-when-compile + (require 'rx)) + +;; This tells the byte-compiler where the functions are defined. +;; Is only needed when a file needs to be able to byte-compile +;; in a Emacs not built with tree-sitter library. +(treesit-declare-unavailable-functions) + +;; In a multi-language major mode can be useful to have an "installer" to +;; simplify the installation of the grammars supported by the major-mode. +(defvar mhtml-ts-mode--language-source-alist + '((html . ("https://github.com/tree-sitter/tree-sitter-html" "v0.23.2")) + (javascript . ("https://github.com/tree-sitter/tree-sitter-javascript" "v0.23.1")) + (jsdoc . ("https://github.com/tree-sitter/tree-sitter-jsdoc" "v0.23.2")) + (css . ("https://github.com/tree-sitter/tree-sitter-css" "v0.23.1"))) + "Treesitter language parsers required by `mhtml-ts-mode'. +You can customize this variable if you want to stick to a specific +commit and/or use different parsers.") + +(defun mhtml-ts-mode-install-parsers () + "Install all the required treesitter parsers. +`mhtml-ts-mode--language-source-alist' defines which parsers to install." + (interactive) + (let ((treesit-language-source-alist mhtml-ts-mode--language-source-alist)) + (dolist (item mhtml-ts-mode--language-source-alist) + (treesit-install-language-grammar (car item))))) + +;;; Custom variables + +(defgroup mhtml-ts-mode nil + "Major mode for editing HTML files, based on `html-ts-mode'. +Works with JS and CSS and for that use `js-ts-mode' and `css-ts-mode'." + :prefix "mhtml-ts-mode-" + ;; :group 'languages + :group 'html) + +(defcustom mhtml-ts-mode-js-css-indent-offset 2 + "JavaScript and CSS indent spaces related to the + +When nil, indentation of the tag body starts just below the +tag, like: + + + +When `ignore', the tag body starts in the first column, like: + + " + :type '(choice (const nil) (const t) (const ignore)) + :safe 'symbolp + :set #'mhtml-ts-mode--tag-relative-indent-offset + :version "31.1") + +(defcustom mhtml-ts-mode-css-fontify-colors t + "Whether CSS colors should be fontified using the color as the background. +If non-nil, text representing a CSS color will be fontified +such that its background is the color itself. +Works like `css--fontify-region'." + :tag "HTML colors the CSS properties values." + :version "31.1" + :type 'boolean + :safe 'booleanp) + +(defvar mhtml-ts-mode-saved-pretty-print-command nil + "The command last used to pretty print in this buffer.") + +(defun mhtml-ts-mode-pretty-print (command) + "Prettify the current buffer. +Argument COMMAND The command to use." + (interactive + (list (read-string + "Prettify command: " + (or mhtml-ts-mode-saved-pretty-print-command + (concat mhtml-ts-mode-pretty-print-command " "))))) + (setq mhtml-ts-mode-saved-pretty-print-command command) + (save-excursion + (shell-command-on-region + (point-min) (point-max) + command (buffer-name) t + "*mhtml-ts-mode-pretty-pretty-print-errors*" t))) + +(defun mhtml-ts-mode--switch-fill-defun (&rest arguments) + "Switch between `fill-paragraph' and `prog-fill-reindent-defun'. +In an HTML region it calls `fill-paragraph' as does `html-ts-mode', +otherwise it calls `prog-fill-reindent-defun'. +Optional ARGUMENTS to to be passed to it." + (interactive) + (if (eq (treesit-language-at (point)) 'html) + (funcall-interactively #'fill-paragraph arguments) + (funcall-interactively #'prog-fill-reindent-defun arguments))) + +(defvar-keymap mhtml-ts-mode-map + :doc "Keymap for `mhtml-ts-mode' buffers." + :parent html-mode-map + ;; `mhtml-ts-mode' derive from `html-ts-mode' so the keymap is the + ;; same, we need to add some mapping from others languages. + "C-c C-f" #'css-cycle-color-format + "M-q" #'mhtml-ts-mode--switch-fill-defun) + +;; Place the CSS menu in the menu bar as well. +(easy-menu-define mhtml-ts-mode-menu mhtml-ts-mode-map + "Menu bar for `mhtml-ts-mode'." + css-mode--menu) + +;; To enable some basic treesiter functionality, you should define +;; a function that recognizes which grammar is used at-point. +;; This function should be assigned to `treesit-language-at-point-function' +(defun mhtml-ts-mode--language-at-point (point) + "Return the language at POINT assuming the point is within a HTML buffer." + (let* ((node (treesit-node-at point 'html)) + (parent (treesit-node-parent node)) + (node-query (format "(%s (%s))" + (treesit-node-type parent) + (treesit-node-type node)))) + (cond + ((equal "(script_element (raw_text))" node-query) (js--treesit-language-at-point point)) + ((equal "(style_element (raw_text))" node-query) 'css) + (t 'html)))) + +;; Custom font-lock function that's used to apply color to css color +;; The signature of the function should be conforming to signature +;; QUERY-SPEC required by `treesit-font-lock-rules'. +(defun mhtml-ts-mode--colorize-css-value (node override start end &rest _) + "Colorize CSS property value like `css--fontify-region'. +For NODE, OVERRIDE, START, and END, see `treesit-font-lock-rules'." + (if (and mhtml-ts-mode-css-fontify-colors + (string-equal "plain_value" (treesit-node-type node))) + (let ((color (css--compute-color start (treesit-node-text node t)))) + (when color + (with-silent-modifications + (add-text-properties + (treesit-node-start node) (treesit-node-end node) + (list 'face (list :background color + :foreground (readable-foreground-color + color) + :box '(:line-width -1))))))) + (treesit-fontify-with-override + (treesit-node-start node) (treesit-node-end node) + 'font-lock-variable-name-face + override start end))) + +;; Embedded languages ​​should be indented according to the language +;; that embeds them. +;; This function signature complies with `treesit-simple-indent-rules' +;; ANCHOR. +(defun mhtml-ts-mode--js-css-tag-bol (_node _parent &rest _) + "Find the first non-space characters of html tags