From e287da5a8154d83a97107b64915ccc17e3a086b8 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Sun, 2 Feb 2020 10:17:20 -0600 Subject: * lisp/emacs-lisp/map.el: Add keyword-only pattern abbreviation * lisp/emacs-lisp/map.el: Update version to 2.1. ((pcase-defmacro map)): Update docstring. (map--make-pcase-bindings): Match keyword pattern. * test/lisp/emacs-lisp/map-tests.el (test-map-plist-pcase): Add test. --- lisp/emacs-lisp/map.el | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/map.el b/lisp/emacs-lisp/map.el index 67f5b3cf24e..9c23344baca 100644 --- a/lisp/emacs-lisp/map.el +++ b/lisp/emacs-lisp/map.el @@ -4,7 +4,7 @@ ;; Author: Nicolas Petton ;; Keywords: convenience, map, hash-table, alist, array -;; Version: 2.0 +;; Version: 2.1 ;; Package-Requires: ((emacs "25")) ;; Package: map @@ -56,8 +56,10 @@ evaluated and searched for in the map. The match fails if for any KEY found in the map, the corresponding PAT doesn't match the value associated to the KEY. -Each element can also be a SYMBOL, which is an abbreviation of a (KEY -PAT) tuple of the form (\\='SYMBOL SYMBOL). +Each element can also be a SYMBOL, which is an abbreviation of +a (KEY PAT) tuple of the form (\\='SYMBOL SYMBOL). When SYMBOL +is a keyword, it is an abbreviation of the form (:SYMBOL SYMBOL), +useful for binding plist values. Keys in ARGS not found in the map are ignored, and the match doesn't fail." @@ -486,9 +488,12 @@ Example: (defun map--make-pcase-bindings (args) "Return a list of pcase bindings from ARGS to the elements of a map." (seq-map (lambda (elt) - (if (consp elt) - `(app (pcase--flip map-elt ,(car elt)) ,(cadr elt)) - `(app (pcase--flip map-elt ',elt) ,elt))) + (cond ((consp elt) + `(app (pcase--flip map-elt ,(car elt)) ,(cadr elt))) + ((keywordp elt) + (let ((var (intern (substring (symbol-name elt) 1)))) + `(app (pcase--flip map-elt ,elt) ,var))) + (t `(app (pcase--flip map-elt ',elt) ,elt)))) args)) (defun map--make-pcase-patterns (args) -- cgit v1.2.3 From aea12d4903136c057bb14d3fd7683bf7a4e1eff6 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Wed, 5 Feb 2020 13:12:01 +0100 Subject: Add new filter commands to Package Menu (Bug#38424) * lisp/emacs-lisp/package.el (package-menu-filter-by-version) (package-menu-filter-by-status, package-menu-filter-by-archive): New filter commands. (package-menu--filter-by): New helper function. (package-menu-filter-by-keyword, package-menu-filter-by-name): Use the above helper function. (package-menu-mode-menu): (package-menu-mode-map): Update menu to include new filter commands. * doc/emacs/package.texi (Package Menu): Document the new commands and re-arrange the sort order of commands to be closer to the one in describe-major-mode. * etc/NEWS: Announce the new commands. * lisp/emacs-lisp/package.el (package-menu--display): New function extracted from.... (package-menu--generate): ...here. * test/lisp/emacs-lisp/package-tests.el (with-package-menu-test): New macro. (package-test-update-listing, package-test-list-filter-by-name) (package-test-list-filter-clear): Use above macro. (package-test-list-filter-by-archive) (package-test-list-filter-by-keyword) (package-test-list-filter-by-status) (package-test-list-filter-by-version-=) (package-test-list-filter-by-version-<) (package-test-list-filter-by-version->): New tests. (package-test-filter-by-version): New helper function. --- doc/emacs/package.texi | 63 ++++++---- etc/NEWS | 14 +++ lisp/emacs-lisp/package.el | 219 +++++++++++++++++++++++++++------- test/lisp/emacs-lisp/package-tests.el | 117 +++++++++++++----- 4 files changed, 319 insertions(+), 94 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/doc/emacs/package.texi b/doc/emacs/package.texi index 1cac7f9b4b6..360fc980e4a 100644 --- a/doc/emacs/package.texi +++ b/doc/emacs/package.texi @@ -151,27 +151,6 @@ Refresh the package list (@code{revert-buffer}). This fetches the list of available packages from the package archive again, and redisplays the package list. -@item / k -@kindex / k @r{(Package Menu)} -@findex package-menu-filter-by-keyword -Filter the package list by keyword -(@code{package-menu-filter-by-keyword}). This prompts for a keyword -(e.g., @samp{games}), then shows only the packages that relate to that -keyword. - -@item / n -@kindex / n @r{(Package Menu)} -@findex package-menu-filter-by-name -Filter the package list by name (@code{package-menu-filter-by-name}). -This prompts for a string, then shows only the packages whose names -match a regexp with that value. - -@item / / -@kindex / / @r{(Package Menu)} -@findex package-menu-clear-filter -Clear filter currently applied to the package list -(@code{package-menu-clear-filter}). - @item H @kindex H @r{(Package Menu)} @findex package-menu-hide-package @@ -183,6 +162,48 @@ Permanently hide packages that match a regexp @findex package-menu-toggle-hiding Toggle visibility of old versions of packages and also of versions from lower-priority archives (@code{package-menu-toggle-hiding}). + +@item / a +@kindex / a @r{(Package Menu)} +@findex package-menu-filter-by-archive +Filter package list by archive (@code{package-menu-filter-by-archive}). +This prompts for a package archive (e.g., @samp{gnu}), then shows only +packages from that archive. + +@item / k +@kindex / k @r{(Package Menu)} +@findex package-menu-filter-by-keyword +Filter package list by keyword (@code{package-menu-filter-by-keyword}). +This prompts for a keyword (e.g., @samp{games}), then shows only +packages with that keyword. + +@item / n +@kindex / n @r{(Package Menu)} +@findex package-menu-filter-by-name +Filter package list by name (@code{package-menu-filter-by-name}). +This prompts for a regular expression, then shows only packages +with names matching that regexp. + +@item / s +@kindex / s @r{(Package Menu)} +@findex package-menu-filter-by-status +Filter package list by status (@code{package-menu-filter-by-status}). +This prompts for one or more statuses (e.g., @samp{available}), then +shows only packages with matching status. + +@item / v +@kindex / v @r{(Package Menu)} +@findex package-menu-filter-by-version +Filter package list by version (@code{package-menu-filter-by-version}). +This prompts first for one of the qualifiers @samp{<}, @samp{>} or +@samp{=}, and then a package version, and shows packages that has a +lower, equal or higher version than the one specified. + +@item / / +@kindex / / @r{(Package Menu)} +@findex package-menu-filter-clear +Clear filter currently applied to the package list +(@code{package-menu-filter-clear}). @end table @noindent diff --git a/etc/NEWS b/etc/NEWS index 093b54bdd46..6ab6a8aab3b 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -120,6 +120,20 @@ like cell phones, tablets or cameras. *** Pcase 'map' pattern added keyword symbols abbreviation. A pattern like '(map :sym)' binds the map's value for ':sym' to 'sym', equivalent to '(map (:sym sym))'. +** Package + ++++ +*** New functions to filter the package list. +The filter command key bindings are as follows: + +key binding +--- ------- +/ a package-menu-filter-by-archive +/ k package-menu-filter-by-keyword +/ n package-menu-filter-by-name +/ s package-menu-filter-by-status +/ v package-menu-filter-by-version +/ / package-menu-filter-clear * New Modes and Packages in Emacs 28.1 diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index a9508c1bdc5..f14ef7919ea 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -2679,15 +2679,18 @@ either a full name or nil, and EMAIL is a valid email address." (define-key map "i" 'package-menu-mark-install) (define-key map "U" 'package-menu-mark-upgrades) (define-key map "r" 'revert-buffer) - (define-key map (kbd "/ k") 'package-menu-filter-by-keyword) - (define-key map (kbd "/ n") 'package-menu-filter-by-name) - (define-key map (kbd "/ /") 'package-menu-clear-filter) (define-key map "~" 'package-menu-mark-obsolete-for-deletion) (define-key map "x" 'package-menu-execute) (define-key map "h" 'package-menu-quick-help) (define-key map "H" #'package-menu-hide-package) (define-key map "?" 'package-menu-describe-package) (define-key map "(" #'package-menu-toggle-hiding) + (define-key map (kbd "/ /") 'package-menu-clear-filter) + (define-key map (kbd "/ a") 'package-menu-filter-by-archive) + (define-key map (kbd "/ k") 'package-menu-filter-by-keyword) + (define-key map (kbd "/ n") 'package-menu-filter-by-name) + (define-key map (kbd "/ s") 'package-menu-filter-by-status) + (define-key map (kbd "/ v") 'package-menu-filter-by-version) map) "Local keymap for `package-menu-mode' buffers.") @@ -2714,8 +2717,11 @@ either a full name or nil, and EMAIL is a valid email address." "--" ("Filter Packages" + ["Filter by Archive" package-menu-filter-by-archive :help "Filter packages by archive"] ["Filter by Keyword" package-menu-filter-by-keyword :help "Filter packages by keyword"] ["Filter by Name" package-menu-filter-by-name :help "Filter packages by name"] + ["Filter by Status" package-menu-filter-by-status :help "Filter packages by status"] + ["Filter by Version" package-menu-filter-by-version :help "Filter packages by version"] ["Clear Filter" package-menu-clear-filter :help "Clear package list filter"]) ["Hide by Regexp" package-menu-hide-package :help "Permanently hide all packages matching a regexp"] @@ -3021,22 +3027,31 @@ When none are given, the package matches." found) t)) -(defun package-menu--generate (remember-pos packages &optional keywords) - "Populate the Package Menu. +(defun package-menu--display (remember-pos suffix) + "Display the Package Menu. If REMEMBER-POS is non-nil, keep point on the same entry. + +If SUFFIX is non-nil, append that to \"Package\" for the first +column in the header line." + (setf (car (aref tabulated-list-format 0)) + (if suffix + (concat "Package[" suffix "]") + "Package")) + (tabulated-list-init-header) + (tabulated-list-print remember-pos)) + +(defun package-menu--generate (remember-pos &optional packages keywords) + "Populate and display the Package Menu. PACKAGES should be t, which means to display all known packages, or a list of package names (symbols) to display. With KEYWORDS given, only packages with those keywords are shown." (package-menu--refresh packages keywords) - (setf (car (aref tabulated-list-format 0)) - (if keywords - (let ((filters (mapconcat #'identity keywords ","))) - (concat "Package[" filters "]")) - "Package")) - (tabulated-list-init-header) - (tabulated-list-print remember-pos)) + (package-menu--display remember-pos + (when keywords + (let ((filters (mapconcat #'identity keywords ","))) + (concat "Package[" filters "]"))))) (defun package-menu--print-info (pkg) "Return a package entry suitable for `tabulated-list-entries'. @@ -3673,45 +3688,160 @@ shown." (select-window win) (switch-to-buffer buf)))) +(defun package-menu--filter-by (predicate suffix) + "Filter \"*Packages*\" buffer by PREDICATE and add SUFFIX to header. +PREDICATE is a function which will be called with one argument, a +`package-desc' object, and returns t if that object should be +listed in the Package Menu. + +SUFFIX is passed on to `package-menu--display' and is added to +the header line of the first column." + ;; Update `tabulated-list-entries' so that it contains all + ;; packages before searching. + (package-menu--refresh t nil) + (let (found-entries) + (dolist (entry tabulated-list-entries) + (when (funcall predicate (car entry)) + (push entry found-entries))) + (if found-entries + (progn + (setq tabulated-list-entries found-entries) + (package-menu--display t suffix)) + (user-error "No packages found")))) + +(defun package-menu-filter-by-archive (archive) + "Filter the \"*Packages*\" buffer by ARCHIVE. +Display only packages from package archive ARCHIVE. + +When called interactively, prompt for ARCHIVE, which can be a +comma-separated string. If ARCHIVE is empty, show all packages. + +When called from Lisp, ARCHIVE can be a string or a list of +strings. If ARCHIVE is nil or the empty string, show all +packages." + (interactive (list (completing-read-multiple + "Filter by archive (comma separated): " + (mapcar #'car package-archives)))) + (package--ensure-package-menu-mode) + (let ((re (if (listp archive) + (regexp-opt archive) + archive))) + (package-menu--filter-by (lambda (pkg-desc) + (let ((pkg-archive (package-desc-archive pkg-desc))) + (and pkg-archive + (string-match-p re pkg-archive)))) + (concat "archive:" (if (listp archive) + (string-join archive ",") + archive))))) + (defun package-menu-filter-by-keyword (keyword) "Filter the \"*Packages*\" buffer by KEYWORD. -Show only those items that relate to the specified KEYWORD. - -KEYWORD can be a string or a list of strings. If it is a list, a -package will be displayed if it matches any of the keywords. -Interactively, it is a list of strings separated by commas. - -KEYWORD can also be used to filter by status or archive name by -using keywords like \"arc:gnu\" and \"status:available\". -Statuses available include \"incompat\", \"available\", -\"built-in\" and \"installed\"." - (interactive - (list (completing-read-multiple - "Keywords (comma separated): " (package-all-keywords)))) +Display only packages with specified KEYWORD. + +When called interactively, prompt for KEYWORD, which can be a +comma-separated string. If KEYWORD is empty, show all packages. + +When called from Lisp, KEYWORD can be a string or a list of +strings. If KEYWORD is nil or the empty string, show all +packages." + (interactive (list (completing-read-multiple + "Keywords (comma separated): " + (package-all-keywords)))) + (when (stringp keyword) + (setq keyword (list keyword))) (package--ensure-package-menu-mode) - (package-show-package-list t (if (stringp keyword) - (list keyword) - keyword))) + (if (not keyword) + (package-menu--generate t t) + (package-menu--filter-by (lambda (pkg-desc) + (package--has-keyword-p pkg-desc keyword)) + (concat "keyword:" (string-join keyword ","))))) (defun package-menu-filter-by-name (name) - "Filter the \"*Packages*\" buffer by NAME. -Show only those items whose name matches the regular expression -NAME. If NAME is nil or the empty string, show all packages." - (interactive (list (read-from-minibuffer "Filter by name (regexp): "))) + "Filter the \"*Packages*\" buffer by NAME regexp. +Display only packages with name that matches regexp NAME. + +When called interactively, prompt for NAME. + +If NAME is nil or the empty string, show all packages." + (interactive (list (read-regexp "Filter by name (regexp)"))) (package--ensure-package-menu-mode) (if (or (not name) (string-empty-p name)) - (package-show-package-list t nil) - ;; Update `tabulated-list-entries' so that it contains all - ;; packages before searching. - (package-menu--refresh t nil) - (let (matched) - (dolist (entry tabulated-list-entries) - (let* ((pkg-name (package-desc-name (car entry)))) - (when (string-match name (symbol-name pkg-name)) - (push pkg-name matched)))) - (if matched - (package-show-package-list matched nil) - (user-error "No packages found"))))) + (package-menu--generate t t) + (package-menu--filter-by (lambda (pkg-desc) + (string-match-p name (symbol-name + (package-desc-name pkg-desc)))) + (format "name:%s" name)))) + +(defun package-menu-filter-by-status (status) + "Filter the \"*Packages*\" buffer by STATUS. +Display only packages with specified STATUS. + +When called interactively, prompt for STATUS, which can be a +comma-separated string. If STATUS is empty, show all packages. + +When called from Lisp, STATUS can be a string or a list of +strings. If STATUS is nil or the empty string, show all +packages." + (interactive (list (completing-read "Filter by status: " + '("avail-obso" + "available" + "built-in" + "dependency" + "disabled" + "external" + "held" + "incompat" + "installed" + "new" + "unsigned")))) + (package--ensure-package-menu-mode) + (if (or (not status) (string-empty-p status)) + (package-menu--generate t t) + (package-menu--filter-by (lambda (pkg-desc) + (string-match-p status (package-desc-status pkg-desc))) + (format "status:%s" status)))) + +(defun package-menu-filter-by-version (version predicate) + "Filter the \"*Packages*\" buffer by VERSION and PREDICATE. +Display only packages with a matching version. + +When called interactively, prompt for one of the qualifiers `<', +`>' or `=', and a package version. Show only packages that has a +lower (`<'), equal (`=') or higher (`>') version than the +specified one. + +When called from Lisp, VERSION should be a version string and +PREDICATE should be the symbol `=', `<' or `>'. + +If VERSION is nil or the empty string, show all packages." + (interactive (let ((choice (intern + (char-to-string + (read-char-choice + "Filter by version? [Type =, <, > or q] " + '(?< ?> ?= ?q)))))) + (if (eq choice 'q) + '(quit nil) + (list (read-from-minibuffer + (concat "Filter by version (" + (pcase choice + ('= "= equal to") + ('< "< less than") + ('> "> greater than")) + "): ")) + choice)))) + (unless (equal predicate 'quit) + (if (or (not version) (string-empty-p version)) + (package-menu--generate t t) + (package-menu--filter-by + (let ((fun (pcase predicate + ('= 'version-list-=) + ('< 'version-list-<) + ('> '(lambda (a b) (not (version-list-<= a b)))) + (_ (error "Unknown predicate: %s" predicate)))) + (ver (version-to-list version))) + (lambda (pkg-desc) + (funcall fun (package-desc-version pkg-desc) ver))) + (format "versions:%s%s" predicate version))))) (defun package-menu-clear-filter () "Clear any filter currently applied to the \"*Packages*\" buffer." @@ -3760,6 +3890,7 @@ The return value is a string (or nil in case we can't find it)." (or (lm-header "package-version") (lm-header "version"))))))))) + ;;;; Quickstart: precompute activation actions for faster start up. ;; Activating packages via `package-initialize' is costly: for N installed diff --git a/test/lisp/emacs-lisp/package-tests.el b/test/lisp/emacs-lisp/package-tests.el index 7d354d6ecde..adf917aef46 100644 --- a/test/lisp/emacs-lisp/package-tests.el +++ b/test/lisp/emacs-lisp/package-tests.el @@ -349,43 +349,102 @@ Must called from within a `tar-mode' buffer." (goto-char (point-min)) (should (re-search-forward re nil t))))))) + +;;; Package Menu tests + +(defmacro with-package-menu-test (&rest body) + "Set up Package Menu (\"*Packages*\") buffer for testing." + (declare (indent 0) (debug (([&rest form]) body))) + `(with-package-test () + (let ((buf (package-list-packages))) + (unwind-protect + (progn ,@body) + (kill-buffer buf))))) + (ert-deftest package-test-update-listing () "Ensure installed package status is updated." - (with-package-test () - (let ((buf (package-list-packages))) - (search-forward-regexp "^ +simple-single") - (package-menu-mark-install) - (package-menu-execute) - (run-hooks 'post-command-hook) - (should (package-installed-p 'simple-single)) - (switch-to-buffer "*Packages*") - (goto-char (point-min)) - (should (re-search-forward "^\\s-+simple-single\\s-+1.3\\s-+installed" nil t)) - (goto-char (point-min)) - (should-not (re-search-forward "^\\s-+simple-single\\s-+1.3\\s-+\\(available\\|new\\)" nil t)) - (kill-buffer buf)))) + (with-package-menu-test + (search-forward-regexp "^ +simple-single") + (package-menu-mark-install) + (package-menu-execute) + (run-hooks 'post-command-hook) + (should (package-installed-p 'simple-single)) + (switch-to-buffer "*Packages*") + (goto-char (point-min)) + (should (re-search-forward "^\\s-+simple-single\\s-+1.3\\s-+installed" nil t)) + (goto-char (point-min)) + (should-not (re-search-forward "^\\s-+simple-single\\s-+1.3\\s-+\\(available\\|new\\)" nil t)))) + +(ert-deftest package-test-list-filter-by-archive () + "Ensure package list is filtered correctly by archive version." + (with-package-menu-test + ;; TODO: Add another package archive to test filtering, because + ;; the testing environment currently only has one. + (package-menu-filter-by-archive "gnu") + (goto-char (point-min)) + (should (looking-at "^\\s-+multi-file")) + (should (= (count-lines (point-min) (point-max)) 4)) + (should-error (package-menu-filter-by-archive "non-existent archive")))) + +(ert-deftest package-test-list-filter-by-keyword () + "Ensure package list is filtered correctly by package keyword." + (with-package-menu-test + (package-menu-filter-by-keyword "frobnicate") + (goto-char (point-min)) + (should (re-search-forward "^\\s-+simple-single" nil t)) + (should (= (count-lines (point-min) (point-max)) 1)) + (should-error (package-menu-filter-by-keyword "non-existent-keyword")))) (ert-deftest package-test-list-filter-by-name () "Ensure package list is filtered correctly by package name." - (with-package-test () - (let ((buf (package-list-packages))) - (package-menu-filter-by-name "tetris") - (goto-char (point-min)) - (should (re-search-forward "^\\s-+tetris" nil t)) - (should (= (count-lines (point-min) (point-max)) 1)) - (kill-buffer buf)))) + (with-package-menu-test () + (package-menu-filter-by-name "tetris") + (goto-char (point-min)) + (should (re-search-forward "^\\s-+tetris" nil t)) + (should (= (count-lines (point-min) (point-max)) 1)))) + +(ert-deftest package-test-list-filter-by-status () + "Ensure package list is filtered correctly by package status." + (with-package-menu-test + (package-menu-filter-by-status "available") + (goto-char (point-min)) + (should (re-search-forward "^\\s-+multi-file" nil t)) + (should (= (count-lines (point-min) (point-max)) 4)) + ;; No installed packages in default environment. + (should-error (package-menu-filter-by-status "installed")))) + +(ert-deftest package-test-list-filter-by-version () + (with-package-menu-test + (should-error (package-menu-filter-by-version "1.1" 'unknown-symbol))) ) + +(defun package-test-filter-by-version (version predicate name) + (with-package-menu-test + (package-menu-filter-by-version version predicate) + (goto-char (point-min)) + ;; We just check that the given package is included in the + ;; listing. One could be more ambitious. + (should (re-search-forward name)))) + +(ert-deftest package-test-list-filter-by-version-= () + "Ensure package list is filtered correctly by package version (=)." + (package-test-filter-by-version "1.1" '= "^\\s-+simple-two-depend")) + +(ert-deftest package-test-list-filter-by-version-< () + "Ensure package list is filtered correctly by package version (<)." + (package-test-filter-by-version "1.2" '< "^\\s-+simple-two-depend")) + +(ert-deftest package-test-list-filter-by-version-> () + "Ensure package list is filtered correctly by package version (>)." + (package-test-filter-by-version "1.0" '> "^\\s-+simple-two-depend")) (ert-deftest package-test-list-clear-filter () "Ensure package list filter is cleared correctly." - (with-package-test () - (let ((buf (package-list-packages))) - (let ((num-packages (count-lines (point-min) (point-max)))) - (should (> num-packages 1)) - (package-menu-filter-by-name "tetris") - (should (= (count-lines (point-min) (point-max)) 1)) - (package-menu-clear-filter) - (should (= (count-lines (point-min) (point-max)) num-packages))) - (kill-buffer buf)))) + (with-package-menu-test + (let ((num-packages (count-lines (point-min) (point-max)))) + (package-menu-filter-by-name "tetris") + (should (= (count-lines (point-min) (point-max)) 1)) + (package-menu-clear-filter) + (should (= (count-lines (point-min) (point-max)) num-packages))))) (ert-deftest package-test-update-archives () "Test updating package archives." -- cgit v1.2.3 From feb681dc36cf8d086d326197a6db912f98b97773 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Wed, 5 Feb 2020 13:28:31 +0100 Subject: Silence byte-compiler warning * lisp/emacs-lisp/bytecomp.el (byte-compile-insert-header): Silence byte-compiler warning about "Unused lexical variable". --- lisp/emacs-lisp/bytecomp.el | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index d35ce663507..fce5e4aed6d 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -2187,8 +2187,7 @@ With argument ARG, insert value in current buffer after the form." (defun byte-compile-insert-header (_filename outbuffer) "Insert a header at the start of OUTBUFFER. Call from the source buffer." - (let ((dynamic-docstrings byte-compile-dynamic-docstrings) - (dynamic byte-compile-dynamic) + (let ((dynamic byte-compile-dynamic) (optimize byte-optimize)) (with-current-buffer outbuffer (goto-char (point-min)) -- cgit v1.2.3 From ebff24c0b8fa54854fe8445f2eba1d99fb76ecf2 Mon Sep 17 00:00:00 2001 From: Tino Calancha Date: Wed, 5 Feb 2020 19:05:23 +0100 Subject: Eval macro arg just once * lisp/emacs-lisp/cl-macs.el (cl--push-clause-loop-body): Use `macroexp-let2' (Bug#39428). --- lisp/emacs-lisp/cl-macs.el | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el index 9d0fd15bc3d..4c2f58907de 100644 --- a/lisp/emacs-lisp/cl-macs.el +++ b/lisp/emacs-lisp/cl-macs.el @@ -1037,9 +1037,10 @@ For more details, see Info node `(cl)Loop Facility'. (defmacro cl--push-clause-loop-body (clause) "Apply CLAUSE to both `cl--loop-conditions' and `cl--loop-body'." - `(progn - (push ,clause cl--loop-conditions) - (push ,clause cl--loop-body))) + (macroexp-let2 nil sym clause + `(progn + (push ,sym cl--loop-conditions) + (push ,sym cl--loop-body)))) ;; Below is a complete spec for cl-loop, in several parts that correspond ;; to the syntax given in CLtL2. The specs do more than specify where -- cgit v1.2.3 From b2e27d8617ad727c578763445d240962828a872c Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Thu, 6 Feb 2020 13:30:33 +0100 Subject: Revert "Signal user-error on duplicate package refresh" That commit caused errors when the connection was dropped in the middle of a package refresh. To avoid any further issues this close to the pretest, we simply remove this feature. (Bug#39187) Don't merge to master, where we will instead try to fix the bug. --- lisp/emacs-lisp/package.el | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index afe42c7d723..130b105bb5d 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -3175,15 +3175,12 @@ Return (PKG-DESC [NAME VERSION STATUS DOC])." (defun package-menu--refresh-contents (&optional _arg _noconfirm) "In Package Menu, download the Emacs Lisp package archive. Fetch the contents of each archive specified in -`package-archives', and then refresh the package menu. Signal a -user-error if there is already a refresh running asynchronously. +`package-archives', and then refresh the package menu. `package-menu-mode' sets `revert-buffer-function' to this function. The args ARG and NOCONFIRM, passed from `revert-buffer', are ignored." (package--ensure-package-menu-mode) - (when (and package-menu-async package--downloads-in-progress) - (user-error "Package refresh is already in progress, please wait...")) (setq package-menu--old-archive-contents package-archive-contents) (setq package-menu--new-package-list nil) (package-refresh-contents package-menu-async)) -- cgit v1.2.3 From 56b8768b32e9679d3f4f6e2070e9af8f9fc14ff1 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 8 Feb 2020 11:38:52 +0200 Subject: More accurate documentation of 'package-menu-hide-package' * doc/emacs/package.texi (Package Menu): Improve the description of the 'H' command. * lisp/emacs-lisp/package.el (package-menu-mode-menu): More accurate wording of the help-echo string. (package-menu-hide-package): Make the doc string more accurate. (Bug#39436) --- doc/emacs/package.texi | 7 +++++-- lisp/emacs-lisp/package.el | 7 ++++--- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/doc/emacs/package.texi b/doc/emacs/package.texi index 1cac7f9b4b6..6bf4fc7e10c 100644 --- a/doc/emacs/package.texi +++ b/doc/emacs/package.texi @@ -175,8 +175,11 @@ Clear filter currently applied to the package list @item H @kindex H @r{(Package Menu)} @findex package-menu-hide-package -Permanently hide packages that match a regexp -(@code{package-menu-hide-package}). +Hide packages whose names match a regexp +(@code{package-menu-hide-package}). This prompts for a regexp, and +then hides the packages with matching names. The default value of the +regexp will hide only the package whose name is at point, so just +pressing @key{RET} to the prompt will hide the current package. @item ( @kindex ( @r{(Package Menu)} diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index 130b105bb5d..64d2001646f 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -2734,7 +2734,7 @@ either a full name or nil, and EMAIL is a valid email address." ["Filter by Name" package-menu-filter-by-name :help "Filter packages by name"] ["Clear Filter" package-menu-clear-filter :help "Clear package list filter"]) - ["Hide by Regexp" package-menu-hide-package :help "Permanently hide all packages matching a regexp"] + ["Hide by Regexp" package-menu-hide-package :help "Hide all packages matching a regexp"] ["Display Older Versions" package-menu-toggle-hiding :style toggle :selected (not package-menu--hide-packages) :help "Display package even if a newer version is already installed"] @@ -3187,8 +3187,9 @@ function. The args ARG and NOCONFIRM, passed from (define-obsolete-function-alias 'package-menu-refresh 'revert-buffer "27.1") (defun package-menu-hide-package () - "Hide a package under point in Package Menu. -If optional arg BUTTON is non-nil, describe its associated package." + "Hide in Package Menu packages that match a regexp. +Prompts for the regexp to match against package names. +The default regexp will hide only the package whose name is at point." (interactive) (package--ensure-package-menu-mode) (declare (interactive-only "change `package-hidden-regexps' instead.")) -- cgit v1.2.3 From 530067463bffc982f02dcc4f2805d389704575b4 Mon Sep 17 00:00:00 2001 From: Alan Mackenzie Date: Sun, 9 Feb 2020 14:33:14 +0000 Subject: Correct "different than" to "different from" where appropriate (doc/emacs/screen.texi) (doc/lispintro/emacs-lisp-intro.texi) (doc/misc/calc.texi) (doc/misc/gnus.texi) (doc/misc/sc.texi) (lisp/align.el) (lisp/allout-widgets.el) (lisp/allout.el) (lisp/emacs-lisp/gv.el) (lisp/font-lock.el) (lisp/gnus/mm-util.el) (lisp/mail/feedmail.el) (lisp/mail/sendmail.el) (lisp/mail/supercite.el) (lisp/org/org-attach.el) (lisp/progmodes/cc-langs.el) (lisp/progmodes/idlw-shell.el) (lisp/ps-print.el) (lisp/simple.el) (src/cmds.c) (src/editfns.c) (src/frame.h) (src/regex-emacs.c) (src/xfaces.c): Replace "different than" by "different from". --- doc/emacs/screen.texi | 2 +- doc/lispintro/emacs-lisp-intro.texi | 2 +- doc/misc/calc.texi | 4 ++-- doc/misc/gnus.texi | 2 +- doc/misc/sc.texi | 4 ++-- lisp/align.el | 2 +- lisp/allout-widgets.el | 2 +- lisp/allout.el | 2 +- lisp/emacs-lisp/gv.el | 2 +- lisp/font-lock.el | 4 ++-- lisp/gnus/mm-util.el | 2 +- lisp/mail/feedmail.el | 2 +- lisp/mail/sendmail.el | 2 +- lisp/mail/supercite.el | 2 +- lisp/org/org-attach.el | 2 +- lisp/progmodes/cc-langs.el | 2 +- lisp/progmodes/idlw-shell.el | 2 +- lisp/ps-print.el | 6 +++--- lisp/simple.el | 2 +- src/cmds.c | 4 ++-- src/editfns.c | 4 ++-- src/frame.h | 2 +- src/regex-emacs.c | 2 +- src/xfaces.c | 10 +++++----- 24 files changed, 35 insertions(+), 35 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/doc/emacs/screen.texi b/doc/emacs/screen.texi index 773bb939441..5c5a5da5511 100644 --- a/doc/emacs/screen.texi +++ b/doc/emacs/screen.texi @@ -167,7 +167,7 @@ what is going on in the current buffer. When there is only one window, the mode line appears right above the echo area; it is the next-to-last line in the frame. On a graphical display, the mode line is drawn with a 3D box appearance. Emacs also usually draws the mode -line of the selected window with a different color than that of +line of the selected window with a different color from that of unselected windows, in order to make it stand out. The text displayed in the mode line has the following format: diff --git a/doc/lispintro/emacs-lisp-intro.texi b/doc/lispintro/emacs-lisp-intro.texi index 87152f49d6f..9e23f055f53 100644 --- a/doc/lispintro/emacs-lisp-intro.texi +++ b/doc/lispintro/emacs-lisp-intro.texi @@ -12919,7 +12919,7 @@ familiar part of this function. @unnumberedsubsec The @code{let*} expression The next line of the @code{forward-paragraph} function begins a -@code{let*} expression. This is a different than @code{let}. The +@code{let*} expression. This is different from @code{let}. The symbol is @code{let*} not @code{let}. @findex let* diff --git a/doc/misc/calc.texi b/doc/misc/calc.texi index a89a92d694e..f9196f808e7 100644 --- a/doc/misc/calc.texi +++ b/doc/misc/calc.texi @@ -27155,7 +27155,7 @@ anywhere in the formula. It is possible for a rule set to get into an infinite loop. The most obvious case, replacing a formula with itself, is not a problem because a rule is not considered to ``succeed'' unless the righthand -side actually comes out to something different than the original +side actually comes out to something different from the original formula or sub-formula that was matched. But if you accidentally had both @samp{ln(a b) := ln(a) + ln(b)} and the reverse @samp{ln(a) + ln(b) := ln(a b)} in your rule set, Calc would @@ -28075,7 +28075,7 @@ for angstroms. The unit @code{pt} stands for pints; the name @code{point} stands for a typographical point, defined by @samp{72 point = 1 in}. This is -slightly different than the point defined by the American Typefounder's +slightly different from the point defined by the American Typefounder's Association in 1886, but the point used by Calc has become standard largely due to its use by the PostScript page description language. There is also @code{texpt}, which stands for a printer's point as diff --git a/doc/misc/gnus.texi b/doc/misc/gnus.texi index 83641feeb56..fbdf09420a9 100644 --- a/doc/misc/gnus.texi +++ b/doc/misc/gnus.texi @@ -27664,7 +27664,7 @@ added. A plethora of new commands and modes have been added. @xref{Gnus Unplugged}, for the full story. @item -The @code{nndraft} back end has returned, but works differently than +The @code{nndraft} back end has returned, but works differently from before. All Message buffers are now also articles in the @code{nndraft} group, which is created automatically. diff --git a/doc/misc/sc.texi b/doc/misc/sc.texi index abde85c790b..ccf5b9efb05 100644 --- a/doc/misc/sc.texi +++ b/doc/misc/sc.texi @@ -1033,7 +1033,7 @@ that will be used to composed a non-nested citation string. Supercite scans the various mail headers present in the original article and uses a number of heuristics to extract strings which it puts into the @dfn{attribution association list} or @dfn{attribution alist}. This is -analogous, but different than, the info alist previously mentioned. Each +analogous, but different from, the info alist previously mentioned. Each element in the attribution alist is a key-value pair containing such information as the author's first name, middle names, and last name, the author's initials, and the author's email terminus. @@ -1330,7 +1330,7 @@ co-worker that uses an uncommon citation style (say one that employs a possible for Supercite to recognize this and @emph{coerce} the citation to your preferred style, for consistency. In theory, it is possible for Supercite to recognize such things as uuencoded messages or C code and -cite or fill those differently than normal text. None of this is +cite or fill those differently from normal text. None of this is currently part of Supercite, but contributions are welcome! @node Using Regi diff --git a/lisp/align.el b/lisp/align.el index 2c5492f0b16..c1a2b691312 100644 --- a/lisp/align.el +++ b/lisp/align.el @@ -259,7 +259,7 @@ The possible settings for `align-region-separate' are: `group' Each contiguous set of lines where a specific alignment occurs is considered a section for that alignment rule. Note that each rule may have any entirely different set - of section divisions than another. + of section divisions from another. int alpha = 1; /* one */ double beta = 2.0; diff --git a/lisp/allout-widgets.el b/lisp/allout-widgets.el index fecaf2052ea..fbdddca7d76 100644 --- a/lisp/allout-widgets.el +++ b/lisp/allout-widgets.el @@ -1847,7 +1847,7 @@ Optional HAS-SUCCESSOR is true if the item is followed by a sibling. We also hide the header-prefix string. Guides are established according to the item-widget's :guide-column-flags, -when different than :was-guide-column-flags. Changing that property and +when different from :was-guide-column-flags. Changing that property and reapplying this method will rectify the glyphs." (when (not (widget-get item-widget :is-container)) diff --git a/lisp/allout.el b/lisp/allout.el index 56f74870657..174f1e3dc21 100644 --- a/lisp/allout.el +++ b/lisp/allout.el @@ -5948,7 +5948,7 @@ See `allout-toggle-current-subtree-encryption' for more details." (setq buffer-file-coding-system (allout-select-safe-coding-system subtree-beg subtree-end)) ;; if the coding system for the text being encrypted is different - ;; than that prevailing, then there a real risk that the coding + ;; from that prevailing, then there a real risk that the coding ;; system can't be noticed by emacs when the file is visited. to ;; mitigate that, offer to preserve the coding system using a file ;; local variable. diff --git a/lisp/emacs-lisp/gv.el b/lisp/emacs-lisp/gv.el index 92241a7d566..b43e53b9d27 100644 --- a/lisp/emacs-lisp/gv.el +++ b/lisp/emacs-lisp/gv.el @@ -24,7 +24,7 @@ ;;; Commentary: ;; This is a re-implementation of the setf machinery using a different -;; underlying approach than the one used earlier in CL, which was based on +;; underlying approach from the one used earlier in CL, which was based on ;; define-setf-expander. ;; `define-setf-expander' makes every "place-expander" return a 5-tuple ;; (VARS VALUES STORES GETTER SETTER) diff --git a/lisp/font-lock.el b/lisp/font-lock.el index 77b8e427249..506c888ff64 100644 --- a/lisp/font-lock.el +++ b/lisp/font-lock.el @@ -1004,14 +1004,14 @@ The value of this variable is used when Font Lock mode is turned on." ;; font-lock.el uses its own function for buffer fontification. This function ;; makes fontification be on a message-by-message basis and so visiting an ;; RMAIL file is much faster. A clever implementation of the function might -;; fontify the headers differently than the message body. (It should, and +;; fontify the headers differently from the message body. (It should, and ;; correspondingly for Mail mode, but I can't be bothered to do the work. Can ;; you?) This hints at a more interesting use... ;; ;; Languages that contain text normally contained in different major modes ;; could define their own fontification functions that treat text differently ;; depending on its context. For example, Perl mode could arrange that here -;; docs are fontified differently than Perl code. Or Yacc mode could fontify +;; docs are fontified differently from Perl code. Or Yacc mode could fontify ;; rules one way and C code another. Neat! ;; ;; A further reason to use the fontification indirection feature is when the diff --git a/lisp/gnus/mm-util.el b/lisp/gnus/mm-util.el index e863051e56a..7629d5cb151 100644 --- a/lisp/gnus/mm-util.el +++ b/lisp/gnus/mm-util.el @@ -53,7 +53,7 @@ ;; positions! ,@(unless (mm-coding-system-p 'iso-8859-15) '((iso-8859-15 . iso-8859-1))) - ;; BIG-5HKSCS is similar to, but different than, BIG-5. + ;; BIG-5HKSCS is similar to, but different from, BIG-5. ,@(unless (mm-coding-system-p 'big5-hkscs) '((big5-hkscs . big5))) ;; A Microsoft misunderstanding. diff --git a/lisp/mail/feedmail.el b/lisp/mail/feedmail.el index 08db4262f17..b9920023d82 100644 --- a/lisp/mail/feedmail.el +++ b/lisp/mail/feedmail.el @@ -1552,7 +1552,7 @@ in a buffer, try /bin/rmail instead of /bin/mail. If /bin/rmail exists, this can be accomplished by keeping the default nil setting of `mail-interactive'. You might also like to consult local mail experts for any other interesting command line possibilities. Some versions -of UNIX have an rmail program which behaves differently than +of UNIX have an rmail program which behaves differently from /bin/rmail and complains if feedmail gives it a message on stdin. If you don't know about such things and if there is no local expert to consult, stick with /bin/mail or use one of the other buffer eating diff --git a/lisp/mail/sendmail.el b/lisp/mail/sendmail.el index 91d097d678a..14adb5a195d 100644 --- a/lisp/mail/sendmail.el +++ b/lisp/mail/sendmail.el @@ -1222,7 +1222,7 @@ external program defined by `sendmail-program'." (delete-region (line-beginning-position) (line-beginning-position 2)))) ;; Apparently this causes a duplicate Sender. - ;; ;; If the From is different than current user, insert Sender. + ;; ;; If the From is different from current user, insert Sender. ;; (goto-char (point-min)) ;; (and (re-search-forward "^From:" delimline t) ;; (progn diff --git a/lisp/mail/supercite.el b/lisp/mail/supercite.el index b8595343fcd..986d0cf4074 100644 --- a/lisp/mail/supercite.el +++ b/lisp/mail/supercite.el @@ -1311,7 +1311,7 @@ use it instead of `sc-citation-root-regexp'." ;; filling (defun sc-fill-if-different (&optional prefix) "Fill the region bounded by `sc-fill-begin' and point. -Only fill if optional PREFIX is different than `sc-fill-line-prefix'. +Only fill if optional PREFIX is different from `sc-fill-line-prefix'. If `sc-auto-fill-region-p' is nil, do not fill region. If PREFIX is not supplied, initialize fill variables. This is useful for a regi `begin' frame-entry." diff --git a/lisp/org/org-attach.el b/lisp/org/org-attach.el index 6148657bec4..1ed305c9ff3 100644 --- a/lisp/org/org-attach.el +++ b/lisp/org/org-attach.el @@ -429,7 +429,7 @@ attachment-folder. Change of attachment-folder due to unset might be if an ID property is set on the node, or if a separate inherited -DIR-property exists (that is different than the unset one)." +DIR-property exists (that is different from the unset one)." (interactive) (let ((old (org-attach-dir)) (new diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el index 715af32d7ea..8d0ade70f36 100644 --- a/lisp/progmodes/cc-langs.el +++ b/lisp/progmodes/cc-langs.el @@ -86,7 +86,7 @@ ;; compiled runtime constants ready for use by (the byte compiled) CC ;; Mode, and the source definitions in this file don't have to be ;; loaded then. However, if a byte compiled package is loaded that -;; has been compiled with a different version of CC Mode than the one +;; has been compiled with a different version of CC Mode from the one ;; currently loaded, then the compiled-in values will be discarded and ;; new ones will be built when the mode is initialized. That will ;; automatically trig a load of the file(s) containing the source diff --git a/lisp/progmodes/idlw-shell.el b/lisp/progmodes/idlw-shell.el index e21bbaefd95..dba70cb2821 100644 --- a/lisp/progmodes/idlw-shell.el +++ b/lisp/progmodes/idlw-shell.el @@ -3502,7 +3502,7 @@ Returns nil if frame not found." (defun idlwave-shell-new-bp (bp) "Find the new breakpoint in IDL's list and update with DATA. -The actual line number for a breakpoint in IDL may be different than +The actual line number for a breakpoint in IDL may be different from the line number used with the IDL breakpoint command. Looks for a new breakpoint index number in the list. This is considered the new breakpoint if the file name of frame matches." diff --git a/lisp/ps-print.el b/lisp/ps-print.el index 5f6e1cfd99e..ace30017814 100644 --- a/lisp/ps-print.el +++ b/lisp/ps-print.el @@ -3046,7 +3046,7 @@ See also `ps-use-face-background'." (defcustom ps-fg-list nil "Specify foreground color list. -This list is used to chose a text foreground color which is different than the +This list is used to chose a text foreground color which is different from the background color. It'll be used the first foreground color in `ps-fg-list' which is different from the background color. @@ -6028,8 +6028,8 @@ to the equivalent Latin-1 characters.") ;; Specify a foreground color only if: ;; one's specified, - ;; it's different than the background (if `ps-fg-validate-p' is non-nil) - ;; and it's different than the current. + ;; it's different from the background (if `ps-fg-validate-p' is non-nil) + ;; and it's different from the current. (let ((fg (or fg-color ps-default-foreground))) (if ps-fg-validate-p (let ((bg (or bg-color ps-default-background)) diff --git a/lisp/simple.el b/lisp/simple.el index 00a706848bd..0d8072bf5f0 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -2733,7 +2733,7 @@ Return what remains of the list." ;; said it would do. (unless (and (= start start-mark) (= (+ delta end) end-mark)) - (error "Changes to be undone by function different than announced")) + (error "Changes to be undone by function different from announced")) (set-marker start-mark nil) (set-marker end-mark nil)) (apply fun-args)) diff --git a/src/cmds.c b/src/cmds.c index 462cb661d54..5d7a45e65f6 100644 --- a/src/cmds.c +++ b/src/cmds.c @@ -159,7 +159,7 @@ With argument N not nil or 1, move forward N - 1 lines first. If point reaches the beginning or end of buffer, it stops there. This function constrains point to the current field unless this moves -point to a different line than the original, unconstrained result. +point to a different line from the original, unconstrained result. If N is nil or 1, and a front-sticky field starts at point, the point does not move. To ignore field boundaries bind `inhibit-field-text-motion' to t, or use the `forward-line' function @@ -184,7 +184,7 @@ If point reaches the beginning or end of buffer, it stops there. To ignore intangibility, bind `inhibit-point-motion-hooks' to t. This function constrains point to the current field unless this moves -point to a different line than the original, unconstrained result. If +point to a different line from the original, unconstrained result. If N is nil or 1, and a rear-sticky field ends at point, the point does not move. To ignore field boundaries bind `inhibit-field-text-motion' to t. */) diff --git a/src/editfns.c b/src/editfns.c index 3f1b3aa4b75..05ad3925813 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -717,7 +717,7 @@ position of the first character in logical order, i.e. the smallest character position on the line. This function constrains the returned position to the current field -unless that position would be on a different line than the original, +unless that position would be on a different line from the original, unconstrained result. If N is nil or 1, and a front-sticky field starts at point, the scan stops as soon as it starts. To ignore field boundaries, bind `inhibit-field-text-motion' to t. @@ -750,7 +750,7 @@ position of the last character in logical order, i.e. the largest character position on the line. This function constrains the returned position to the current field -unless that would be on a different line than the original, +unless that would be on a different line from the original, unconstrained result. If N is nil or 1, and a rear-sticky field ends at point, the scan stops as soon as it starts. To ignore field boundaries bind `inhibit-field-text-motion' to t. diff --git a/src/frame.h b/src/frame.h index 6ab690c0ff5..a54b8623e50 100644 --- a/src/frame.h +++ b/src/frame.h @@ -107,7 +107,7 @@ struct frame to redirect keystrokes to a surrogate minibuffer frame when needed. - Note that a value of nil is different than having the field point + Note that a value of nil is different from having the field point to the frame itself. Whenever the Fselect_frame function is used to shift from one frame to the other, any redirections to the original frame are shifted to the newly selected frame; if diff --git a/src/regex-emacs.c b/src/regex-emacs.c index 552216cd87b..694431c95e2 100644 --- a/src/regex-emacs.c +++ b/src/regex-emacs.c @@ -3932,7 +3932,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, allocate space for that if we're not allocating space for anything else (see below). Also, we never need info about register 0 for any of the other register vectors, and it seems rather a kludge to - treat 'best_regend' differently than the rest. So we keep track of + treat 'best_regend' differently from the rest. So we keep track of the end of the best match so far in a separate variable. We initialize this to NULL so that when we backtrack the first time and need to test it, it's not garbage. */ diff --git a/src/xfaces.c b/src/xfaces.c index 3689b9ee7d3..91a7a8533e8 100644 --- a/src/xfaces.c +++ b/src/xfaces.c @@ -4940,7 +4940,7 @@ DEFUN ("face-attributes-as-vector", Fface_attributes_as_vector, that a face containing all the attributes in ATTRS, when merged with the default face for display, can be represented in a way that's - (1) different in appearance than the default face, and + (1) different in appearance from the default face, and (2) `close in spirit' to what the attributes specify, if not exact. */ static bool @@ -5043,7 +5043,7 @@ gui_supports_face_attributes_p (struct frame *f, that a face containing all the attributes in ATTRS, when merged with the default face for display, can be represented in a way that's - (1) different in appearance than the default face, and + (1) different in appearance from the default face, and (2) `close in spirit' to what the attributes specify, if not exact. Point (2) implies that a `:weight black' attribute will be satisfied @@ -5160,7 +5160,7 @@ tty_supports_face_attributes_p (struct frame *f, > TTY_SAME_COLOR_THRESHOLD) return false; /* displayed color is too different */ else - /* Make sure the color is really different than the default. */ + /* Make sure the color is really different from the default. */ { Emacs_Color def_fg_color; if (tty_lookup_color (f, def_fg, &def_fg_color, 0) @@ -5184,7 +5184,7 @@ tty_supports_face_attributes_p (struct frame *f, > TTY_SAME_COLOR_THRESHOLD) return false; /* displayed color is too different */ else - /* Make sure the color is really different than the default. */ + /* Make sure the color is really different from the default. */ { Emacs_Color def_bg_color; if (tty_lookup_color (f, def_bg, &def_bg_color, 0) @@ -5226,7 +5226,7 @@ The definition of `supported' is somewhat heuristic, but basically means that a face containing all the attributes in ATTRIBUTES, when merged with the default face for display, can be represented in a way that's - (1) different in appearance than the default face, and + (1) different in appearance from the default face, and (2) `close in spirit' to what the attributes specify, if not exact. Point (2) implies that a `:weight black' attribute will be satisfied by -- cgit v1.2.3 From 5a21aaff468ec3f0337117707cda4254cbef8de7 Mon Sep 17 00:00:00 2001 From: Mattias EngdegÄrd Date: Tue, 11 Feb 2020 13:23:10 +0100 Subject: rx: Use longest match for all-string 'or' forms (bug#37659) Revert to the Emacs 26 semantics that always gave the longest match for rx 'or' forms with only string arguments. This guarantee was never well documented, but it is useful and people likely have come to rely on it. For example, prior to this change, (rx (or ">" ">=")) matched ">" even if the text contained ">=". * lisp/emacs-lisp/rx.el (rx--translate-or): Don't tell regexp-opt to preserve the matching order. * doc/lispref/searching.texi (Rx Constructs): Document the longest-match guarantee for all-string 'or' forms. * test/lisp/emacs-lisp/rx-tests.el (rx-or): Update test. --- doc/lispref/searching.texi | 5 ++++- lisp/emacs-lisp/rx.el | 2 +- test/lisp/emacs-lisp/rx-tests.el | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/doc/lispref/searching.texi b/doc/lispref/searching.texi index 3d7ea932863..5f4509a8b43 100644 --- a/doc/lispref/searching.texi +++ b/doc/lispref/searching.texi @@ -1080,7 +1080,10 @@ Corresponding string regexp: @samp{@var{A}@var{B}@dots{}} @cindex @code{or} in rx @itemx @code{(| @var{rx}@dots{})} @cindex @code{|} in rx -Match exactly one of the @var{rx}s, trying from left to right. +Match exactly one of the @var{rx}s. +If all arguments are string literals, the longest possible match +will always be used. Otherwise, either the longest match or the +first (in left-to-right order) will be used. Without arguments, the expression will not match anything at all.@* Corresponding string regexp: @samp{@var{A}\|@var{B}\|@dots{}}. diff --git a/lisp/emacs-lisp/rx.el b/lisp/emacs-lisp/rx.el index 03af053c91e..b4cab5715da 100644 --- a/lisp/emacs-lisp/rx.el +++ b/lisp/emacs-lisp/rx.el @@ -290,7 +290,7 @@ Return (REGEXP . PRECEDENCE)." ((null (cdr body)) ; Single item. (rx--translate (car body))) ((rx--every #'stringp body) ; All strings. - (cons (list (regexp-opt body nil t)) + (cons (list (regexp-opt body nil)) t)) ((rx--every #'rx--charset-p body) ; All charsets. (rx--translate-union nil body)) diff --git a/test/lisp/emacs-lisp/rx-tests.el b/test/lisp/emacs-lisp/rx-tests.el index e19e626527b..a6c172adfe7 100644 --- a/test/lisp/emacs-lisp/rx-tests.el +++ b/test/lisp/emacs-lisp/rx-tests.el @@ -43,7 +43,7 @@ (should (equal (rx (or "ab" (| "c" nonl) "de")) "ab\\|c\\|.\\|de")) (should (equal (rx (or "ab" "abc" "a")) - "\\(?:ab\\|abc\\|a\\)")) + "\\(?:a\\(?:bc?\\)?\\)")) (should (equal (rx (| nonl "a") (| "b" blank)) "\\(?:.\\|a\\)\\(?:b\\|[[:blank:]]\\)")) (should (equal (rx (|)) -- cgit v1.2.3