commit 1278a9a907e59b22d8e20a806055c7cb92959017 (HEAD, refs/remotes/origin/master) Author: Mauro Aranda Date: Sun Sep 20 01:04:39 2020 +0200 New command: revert-buffer-with-fine-grain * doc/emacs/files.texi (Reverting): Document the new command and the new variable. * etc/NEWS: Mention the new command and the new variable. * lisp/files.el (revert-buffer-with-fine-grain): New command. Revert a buffer trying to be non-destructive, by using replace-buffer-contents. (revert-buffer-insert-file-contents-delicately): New function, alternative to revert-buffer-insert-file-contents-function--default-function. (revert-buffer-with-fine-grain-max-seconds): New variable. Passed as argument MAX-SECS of replace-buffer-contents. * test/lisp/files-tests.el (files-tests-lao files-tests-tzu): Helper variables, taken from diffutils manual, to test reverting a buffer. (files-tests-revert-buffer) (files-tests-revert-buffer-with-fine-grain): New tests (bug#18). diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi index 2fa1ecc003..51e8bd1382 100644 --- a/doc/emacs/files.texi +++ b/doc/emacs/files.texi @@ -921,6 +921,7 @@ Manual}). For customizations, see the Custom group @code{time-stamp}. @node Reverting @section Reverting a Buffer @findex revert-buffer +@findex revert-buffer-with-fine-grain @cindex drastic changes @cindex reread a file @@ -941,6 +942,19 @@ reverted changes as a single modification to the buffer's undo history aliases to bring the reverted changes back, if you happen to change your mind. +@vindex revert-buffer-with-fine-grain-max-seconds + To revert a buffer more conservatively, you can use the command +@code{revert-buffer-with-fine-grain}. This command acts like +@code{revert-buffer}, but it tries to be as non-destructive as +possible, making an effort to preserve all markers, properties and +overlays in the buffer. Since reverting this way can be very slow +when you have made a large number of changes, you can modify the +variable @code{revert-buffer-with-fine-grain-max-seconds} to +specify a maximum amount of seconds that replacing the buffer +contents this way should take. Note that it is not ensured that the +whole execution of @code{revert-buffer-with-fine-grain} won't take +longer than this. + Some kinds of buffers that are not associated with files, such as Dired buffers, can also be reverted. For them, reverting means recalculating their contents. Buffers created explicitly with diff --git a/etc/NEWS b/etc/NEWS index fb8f2845f7..e7e4910ba1 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -193,6 +193,14 @@ Completion of command names now considers obsolete aliases as candidates. Invoking a command via an obsolete alias now mentions the obsolescence fact and shows the new name of the command. ++++ +** New command 'revert-buffer-with-fine-grain'. +Revert a buffer trying to be as non-destructive as possible, +preserving markers, properties and overlays. The new variable +'revert-buffer-with-fine-grain-max-seconds' specifies the maximum +number of seconds that 'revert-buffer-with-fine-grain' should spend +trying to be non-destructive. + * Changes in Specialized Modes and Packages in Emacs 28.1 diff --git a/lisp/files.el b/lisp/files.el index 98de93c869..53a5fcb87e 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -6254,6 +6254,82 @@ an auto-save file." (insert-file-contents file-name (not auto-save-p) nil nil t)))))) +(defvar revert-buffer-with-fine-grain-max-seconds 2.0 + "Maximum time that `revert-buffer-with-fine-grain' should use. +The command tries to preserve markers, properties and overlays. +If the operation takes more than this time, a single +delete+insert is performed. Actually, this value is passed as +the MAX-SECS argument to the function `replace-buffer-contents', +so it is not ensured that the whole execution won't take longer. +See `replace-buffer-contents' for more details.") + +(defun revert-buffer-insert-file-contents-delicately (file-name _auto-save-p) + "Optional function for `revert-buffer-insert-file-contents-function'. +The function `revert-buffer-with-fine-grain' uses this function by binding +`revert-buffer-insert-file-contents-function' to it. + +As with `revert-buffer-insert-file-contents--default-function', FILE-NAME is +the name of the file and AUTO-SAVE-P is non-nil if this is an auto-save file. +Since calling `replace-buffer-contents' can take a long time, depending of +the number of changes made to the buffer, it uses the value of the variable +`revert-buffer-with-fine-grain-max-seconds' as a maximum time to try delicately +reverting the buffer. If it fails, it does a delete+insert. For more details, +see `replace-buffer-contents'." + (cond + ((not (file-exists-p file-name)) + (error (if buffer-file-number + "File %s no longer exists" + "Cannot revert nonexistent file %s") + file-name)) + ((not (file-readable-p file-name)) + (error (if buffer-file-number + "File %s no longer readable" + "Cannot revert unreadable file %s") + file-name)) + (t + (let* ((buf (current-buffer)) ; current-buffer is the buffer to revert. + (success + (save-excursion + (save-restriction + (widen) + (with-temp-buffer + (insert-file-contents file-name) + (let ((temp-buf (current-buffer))) + (set-buffer buf) + (let ((buffer-file-name nil)) + (replace-buffer-contents + temp-buf + revert-buffer-with-fine-grain-max-seconds)))))))) + ;; See comments in revert-buffer-with-fine-grain for an explanation. + (defun revert-buffer-with-fine-grain-success-p () + success)) + (set-buffer-modified-p nil)))) + +(defun revert-buffer-with-fine-grain (&optional ignore-auto noconfirm) + "Revert buffer preserving markers, overlays, etc. +This command is an alternative to `revert-buffer' because it tries to be as +non-destructive as possible, preserving markers, properties and overlays. +Binds `revert-buffer-insert-file-contents-function' to the function +`revert-buffer-insert-file-contents-delicately'. + +With a prefix argument, offer to revert from latest auto-save file. For more +details on the arguments, see `revert-buffer'." + ;; See revert-buffer for an explanation of this. + (interactive (list (not current-prefix-arg))) + ;; Simply bind revert-buffer-insert-file-contents-function to the specialized + ;; function, and call revert-buffer. + (let ((revert-buffer-insert-file-contents-function + #'revert-buffer-insert-file-contents-delicately)) + (revert-buffer ignore-auto noconfirm t) + ;; This closure is defined in revert-buffer-insert-file-contents-function. + ;; It is needed because revert-buffer--default always returns t after + ;; reverting, and it might be needed to report the success/failure of + ;; reverting delicately. + (when (fboundp 'revert-buffer-with-fine-grain-success-p) + (prog1 + (revert-buffer-with-fine-grain-success-p) + (fmakunbound 'revert-buffer-with-fine-grain-success-p))))) + (defun recover-this-file () "Recover the visited file--get contents from its last auto-save file." (interactive) diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el index b73eac2817..34777013c3 100644 --- a/test/lisp/files-tests.el +++ b/test/lisp/files-tests.el @@ -1377,5 +1377,59 @@ See ." (normal-mode) (should (eq major-mode 'mhtml-mode)))) +(defvar files-tests-lao "The Way that can be told of is not the eternal Way; +The name that can be named is not the eternal name. +The Nameless is the origin of Heaven and Earth; +The Named is the mother of all things. +Therefore let there always be non-being, + so we may see their subtlety, +And let there always be being, + so we may see their outcome. +The two are the same, +But after they are produced, + they have different names. +") + +(defvar files-tests-tzu "The Nameless is the origin of Heaven and Earth; +The named is the mother of all things. + +Therefore let there always be non-being, + so we may see their subtlety, +And let there always be being, + so we may see their outcome. +The two are the same, +But after they are produced, + they have different names. +They both may be called deep and profound. +Deeper and more profound, +The door of all subtleties! +") + +(ert-deftest files-tests-revert-buffer () + "Test that revert-buffer is succesful." + (files-tests--with-temp-file temp-file-name + (with-temp-buffer + (insert files-tests-lao) + (write-file temp-file-name) + (erase-buffer) + (insert files-tests-tzu) + (revert-buffer t t t) + (should (compare-strings files-tests-lao nil nil + (buffer-substring (point-min) (point-max)) + nil nil))))) + +(ert-deftest files-tests-revert-buffer-with-fine-grain () + "Test that revert-buffer-with-fine-grain is successful." + (files-tests--with-temp-file temp-file-name + (with-temp-buffer + (insert files-tests-lao) + (write-file temp-file-name) + (erase-buffer) + (insert files-tests-tzu) + (should (revert-buffer-with-fine-grain t t)) + (should (compare-strings files-tests-lao nil nil + (buffer-substring (point-min) (point-max)) + nil nil))))) + (provide 'files-tests) ;;; files-tests.el ends here commit 4d184fb07f543d96c0a3a40480a0d8b86c472931 Author: Nick Roberts Date: Sun Sep 20 00:27:26 2020 +0200 Make a gud error message more informative * lisp/progmodes/gud.el (gud-jdb-marker-filter): Make the error message more informative (bug#1282). diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el index 092d15983e..84c473ddb7 100644 --- a/lisp/progmodes/gud.el +++ b/lisp/progmodes/gud.el @@ -2358,17 +2358,17 @@ during jdb initialization depending on the value of (if (< n gud-jdb-lowest-stack-level) (progn (setq gud-jdb-lowest-stack-level n) t))) t) - (if (setq file-found - (gud-jdb-find-source (match-string 2 gud-marker-acc))) - (setq gud-last-frame - (cons file-found - (string-to-number - (let - ((numstr (match-string 4 gud-marker-acc))) - (if (string-match "[.,]" numstr) - (replace-match "" nil nil numstr) - numstr))))) - (message "Could not find source file."))) + (let ((class (match-string 2 gud-marker-acc))) + (if (setq file-found (gud-jdb-find-source class)) + (setq gud-last-frame + (cons file-found + (string-to-number + (let + ((numstr (match-string 4 gud-marker-acc))) + (if (string-match "[.,]" numstr) + (replace-match "" nil nil numstr) + numstr))))) + (message "Could not find source file for %s" class)))) ;; Set the accumulator to the remaining text. (setq gud-marker-acc (substring gud-marker-acc (match-end 0)))) commit a2be81780ef466f6007a8a5ec909106c5f8aebf0 Author: Peder O. Klingenberg Date: Sun Sep 20 00:16:36 2020 +0200 Extend process-lines to allow exit status handling * subr.el (process-lines-handling-status): Extension of the old process-lines, with more flexible handling of the exit status. (process-lines): Old API implemented using the new function. (process-lines-ignore-status): Another use of the new function - return the output lines regardless of the exit status (bug#1321). diff --git a/doc/lispref/processes.texi b/doc/lispref/processes.texi index 4002004cd6..e088452075 100644 --- a/doc/lispref/processes.texi +++ b/doc/lispref/processes.texi @@ -603,6 +603,11 @@ This function works by calling @code{call-process}, so program output is decoded in the same way as for @code{call-process}. @end defun +@defun process-lines-ignore-status program &rest args +This function is just like @code{process-lines}, but does not signal +an error if @var{program} exists with a non-zero exit status. +@end defun + @node Asynchronous Processes @section Creating an Asynchronous Process @cindex asynchronous subprocess diff --git a/etc/NEWS b/etc/NEWS index 67cfd5fd00..fb8f2845f7 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1371,6 +1371,12 @@ ledit.el, lmenu.el, lucid.el and old-whitespace.el. * Lisp Changes in Emacs 28.1 ++++ +*** New function 'process-lines-ignore-status'. +This is like 'process-lines', but does not signal an error if the +return status is non-zero. 'process-lines-handling-status' has also +been added, and takes a callback to handle the return status. + +++ *** New function 'replace-in-string'. This function works along the line of 'replace-regexp-in-string', but diff --git a/lisp/subr.el b/lisp/subr.el index f3c1e20660..f00e4ef867 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -2344,13 +2344,19 @@ use `start-file-process'." (if program (list :command (cons program program-args)))))) -(defun process-lines (program &rest args) +(defun process-lines-handling-status (program status-handler &rest args) "Execute PROGRAM with ARGS, returning its output as a list of lines. -Signal an error if the program returns with a non-zero exit status." +If STATUS-HANDLER is non-NIL, it must be a function with one +argument, which will be called with the exit status of the +program before the output is collected. If STATUS-HANDLER is +NIL, an error is signalled if the program returns with a non-zero +exit status." (with-temp-buffer (let ((status (apply 'call-process program nil (current-buffer) nil args))) - (unless (eq status 0) - (error "%s exited with status %s" program status)) + (if status-handler + (funcall status-handler status) + (unless (eq status 0) + (error "%s exited with status %s" program status))) (goto-char (point-min)) (let (lines) (while (not (eobp)) @@ -2361,6 +2367,18 @@ Signal an error if the program returns with a non-zero exit status." (forward-line 1)) (nreverse lines))))) +(defun process-lines (program &rest args) + "Execute PROGRAM with ARGS, returning its output as a list of lines. +Signal an error if the program returns with a non-zero exit status. +Also see `process-lines-ignore-status'." + (apply #'process-lines-handling-status program nil args)) + +(defun process-lines-ignore-status (program &rest args) + "Execute PROGRAM with ARGS, returning its output as a list of lines. +The exit status of the program is ignored. +Also see `process-lines'." + (apply #'process-lines-handling-status program #'identity args)) + (defun process-live-p (process) "Return non-nil if PROCESS is alive. A process is considered alive if its status is `run', `open', commit eda48b6fed851a14e183c38b737c5bc3992862c4 Author: Lars Ingebrigtsen Date: Sat Sep 19 21:16:35 2020 +0200 Add a new variable 'gnus-global-groups' * doc/misc/gnus.texi (HTML): Document it. * lisp/gnus/gnus-art.el (gnus-global-groups): New variable. (gnus-block-private-groups): Use it. diff --git a/doc/misc/gnus.texi b/doc/misc/gnus.texi index 2a0b51bd88..a1c8b327f2 100644 --- a/doc/misc/gnus.texi +++ b/doc/misc/gnus.texi @@ -11979,6 +11979,11 @@ anything that isn't a newsgroup. This means that no external images will be fetched as a result of reading mail, so that nobody can use web bugs (and the like) to track whether you've read email. +@vindex gnus-global-groups +If you have specific private groups that you want to have treated as +if they were public groups, you can add the name of that group to the +@code{gnus-global-groups} list. + Also @pxref{Misc Article} for @code{gnus-inhibit-images}. @item gnus-html-cache-directory diff --git a/etc/NEWS b/etc/NEWS index 458f93379a..67cfd5fd00 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -363,6 +363,14 @@ tags to be considered as well. ** Gnus ++++ +*** New variable 'gnus-global-groups'. +Gnus handles private groups differently from public (i.e., NNTP-like) +groups. Most importantly, Gnus doesn't download external images from +mail-like groups. This can be overridden by putting group names in +'gnus-global-groups': Any group present in that list will be treated +like a public group. + +++ *** New scoring types for the Date header. You can now score based on the relative age of an article with the new diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el index 13a8537997..4484b95075 100644 --- a/lisp/gnus/gnus-art.el +++ b/lisp/gnus/gnus-art.el @@ -534,6 +534,13 @@ that the symbol of the saver function, which is specified by :group 'gnus-article-saving :type 'regexp) +(defcustom gnus-global-groups nil + "Groups that should be considered like \"news\" groups. +This means that images will be automatically loaded, for instance." + :type '(repeat string) + :version "28.1" + :group 'gnus-article) + ;; Note that "Rmail format" is mbox since Emacs 23, but Babyl before. (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail "A function to save articles in your favorite format. @@ -7138,7 +7145,8 @@ If given a prefix, show the hidden text instead." "Allows images in newsgroups to be shown, blocks images in all other groups." (if (or (gnus-news-group-p group) - (gnus-member-of-valid 'global group)) + (gnus-member-of-valid 'global group) + (member group gnus-global-groups)) ;; Block nothing in news groups. nil ;; Block everything anywhere else. commit 091cb97a2a4abba2615a5035d2ce26a6ee06d245 Author: bug-gnu-emacs@gnu.org Date: Sat Sep 19 20:31:05 2020 +0200 Honor make-pointer-invisible on macOS * src/nsterm.m ([EmacsView keyDown:]): Call [NSCursor setHiddenUntilMouseMoves:] with the correct argument, depending on variable make-pointer-invisible. diff --git a/etc/NEWS b/etc/NEWS index 6d27f769e0..458f93379a 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1524,6 +1524,9 @@ To turn this on, set the variable 'w32-use-native-image-API' to a non-nil value. Please report any bugs you find while using the native image API via 'M-x report-emacs-bug'. +--- +** The variable 'make-pointer-invisible' is now honored on macOS. + ---------------------------------------------------------------------- This file is part of GNU Emacs. diff --git a/src/nsterm.m b/src/nsterm.m index 26059ab67c..f6a36c8fdc 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -6449,7 +6449,7 @@ most recently updated (I guess), which is not the correct one. */ if (nsEvArray == nil) nsEvArray = [[NSMutableArray alloc] initWithCapacity: 1]; - [NSCursor setHiddenUntilMouseMoves: YES]; + [NSCursor setHiddenUntilMouseMoves:! NILP (Vmake_pointer_invisible)]; if (hlinfo->mouse_face_hidden && FIXNUMP (Vmouse_highlight)) { commit 2e68cee6532569d26f5c20f1c1fb9d337c5d65f8 Author: Gregor Zattler Date: Sat Sep 19 19:25:24 2020 +0200 * doc/misc/eww.texi: Document the `w' key's double function * doc/misc/eww.texi (Basics): Describe what the `w' command does in eww (bug#43517). diff --git a/doc/misc/eww.texi b/doc/misc/eww.texi index 4ae2c86e3f..1bccbd7261 100644 --- a/doc/misc/eww.texi +++ b/doc/misc/eww.texi @@ -93,14 +93,20 @@ default one, which is normally called @file{*eww*}. @findex eww-quit @findex eww-reload @findex eww-copy-page-url +@findex shr-maybe-probe-and-copy-url @kindex q @kindex w @kindex g If loading the URL was successful the buffer @file{*eww*} is opened and the web page is rendered in it. You can leave EWW by pressing @kbd{q} or exit the browser by calling @kbd{eww-quit}. To reload the -web page hit @kbd{g} (@code{eww-reload}). Pressing @kbd{w} -(@code{eww-copy-page-url}) will copy the current URL to the kill ring. +web page hit @kbd{g} (@code{eww-reload}). + + Pressing @kbd{w} when point is on a link will call +@code{shr-maybe-probe-and-copy-url}, which copies this link's +@acronym{URL} to the kill ring. If point is not on a link, pressing +@kbd{w} calls @code{eww-copy-page-url}, which will copy the current +page's URL to the kill ring instead. @findex eww-open-in-new-buffer @kindex M-RET commit c9f845a53c946f28820a476de7089f486ccaf6b9 Author: Daniel Martín Date: Sat Sep 19 19:15:48 2020 +0200 Put files in mhtml-mode when they have ]*>[ \t\r\n]*<[ \t\r\n]*" comment-re "*\\)?" "[Hh][Tt][Mm][Ll]")) . mhtml-mode) - ("." (should (equal (parse-colon-path "/foo//bar/baz") '("/foo/bar/baz/")))) +(ert-deftest files-test-magic-mode-alist-doctype () + "Test that DOCTYPE and variants put files in mhtml-mode." + (with-temp-buffer + (goto-char (point-min)) + (insert "") + (normal-mode) + (should (eq major-mode 'mhtml-mode)) + (erase-buffer) + (insert "") + (normal-mode) + (should (eq major-mode 'mhtml-mode)))) + (provide 'files-tests) ;;; files-tests.el ends here commit 7222e975be8d3d128086ed49506aa5bd8fccfae5 Author: Lars Ingebrigtsen Date: Sat Sep 19 19:11:09 2020 +0200 Fix problem with spurious extra paragraphs in shr * lisp/net/shr.el (shr-ensure-paragraph): Don't regard
(empty placeholders) as occupying any space (bug#43510). diff --git a/lisp/net/shr.el b/lisp/net/shr.el index 6517596130..1f53bc4016 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el @@ -555,7 +555,7 @@ size, and full-buffer size." ;; If the element was empty, we don't have anything to put the ;; anchor on. So just insert a dummy character. (when (= start (point)) - (insert ?*) + (insert ? ) (put-text-property (1- (point)) (point) 'display "")) (put-text-property start (1+ start) 'shr-target-id id)) ;; If style is set, then this node has set the color. @@ -932,6 +932,22 @@ size, and full-buffer size." (looking-at " *$"))) ;; We're already at a new paragraph; do nothing. ) + ((and (not (bolp)) + (save-excursion + (beginning-of-line) + (looking-at " *$")) + (save-excursion + (forward-line -1) + (looking-at " *$")) + ;; Check all chars on the current line and see whether + ;; they're all placeholders. + (cl-loop for pos from (line-beginning-position) upto (1- (point)) + unless (get-text-property pos 'shr-target-id) + return nil + finally return t)) + ;; We have some invisible markers from
; + ;; do nothing. + ) ((and prefix (= prefix (- (point) (line-beginning-position)))) ;; Do nothing; we're at the start of a
  • . commit 28ba8793626f60d9af2be4a21b3c57a314ac9e79 Author: Drew Adams Date: Sat Sep 19 18:23:27 2020 +0200 Document and extend menu-bar-make-toggle some 2020-09-19 Lars Ingebrigtsen * lisp/menu-bar.el (menu-bar-showhide-fringe-menu): Adjust caller. (menu-bar-search-options-menu): Ditto. (menu-bar-options-menu): Ditto. (menu-bar-options-menu): Ditto. * lisp/progmodes/gdb-mi.el (menu): Ditto. * lisp/emacs-lisp/find-func.el (find-function-regexp): Add menu-bar-make-toggle-command. * lisp/menu-bar.el (menu-bar-make-toggle): Compatibility wrapper. 2020-09-19 Drew Adams * lisp/menu-bar.el (menu-bar-make-toggle-command): Add doc string and allow setting all keywords (bug#17954). diff --git a/lisp/emacs-lisp/find-func.el b/lisp/emacs-lisp/find-func.el index f3f3944a7f..ee94e1fbff 100644 --- a/lisp/emacs-lisp/find-func.el +++ b/lisp/emacs-lisp/find-func.el @@ -61,7 +61,7 @@ "^\\s-*(\\(def\\(ine-skeleton\\|ine-generic-mode\\|ine-derived-mode\\|\ ine\\(?:-global\\)?-minor-mode\\|ine-compilation-mode\\|un-cvs-mode\\|\ foo\\|\\(?:[^icfgv]\\|g[^r]\\)\\(\\w\\|\\s_\\)+\\*?\\)\\|easy-mmode-define-[a-z-]+\\|easy-menu-define\\|\ -menu-bar-make-toggle\\)" +menu-bar-make-toggle\\|menu-bar-make-toggle-command\\)" find-function-space-re "\\('\\|(quote \\)?%s\\(\\s-\\|$\\|[()]\\)") "The regexp used by `find-function' to search for a function definition. diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el index ef04689f4c..fa60cb3b12 100644 --- a/lisp/menu-bar.el +++ b/lisp/menu-bar.el @@ -663,31 +663,63 @@ PROPS are additional properties." :button (:toggle . (and (default-boundp ',fname) (default-value ',fname))))) -(defmacro menu-bar-make-toggle (name variable doc message help &rest body) +(defmacro menu-bar-make-toggle (command variable item-name message help + &rest body) + "Define a menu-bar toggle command. +See `menu-bar-make-toggle-command', for which this is a +compatability wrapper. BODY is passed in as SETTING-SEXP in that macro." + (declare (obsolete menu-bar-make-toggle-command "28.1")) + `(menu-bar-make-toggle-command ,command ,variable ,item-name ,message ,help + ,(and body + `(progn + ,@body)))) + +(defmacro menu-bar-make-toggle-command (command variable item-name message + help + &optional setting-sexp + &rest keywords) + "Define a menu-bar toggle command. +COMMAND (a symbol) is the toggle command to define. + +VARIABLE (a symbol) is the variable to set. + +ITEM-NAME (a string) is the menu-item name. + +MESSAGE is a format string for the toggle message, with %s for the new +status. + +HELP (a string) is the `:help' tooltip text and the doc string first +line (minus final period) for the command. + +SETTING-SEXP is a Lisp sexp that sets VARIABLE, or it is nil meaning +set it according to its `defcustom' or using `set-default'. + +KEYWORDS is a plist for `menu-item' for keywords other than `:help'." `(progn - (defun ,name (&optional interactively) + (defun ,command (&optional interactively) ,(concat "Toggle whether to " (downcase (substring help 0 1)) - (substring help 1) ". + (substring help 1) ". In an interactive call, record this option as a candidate for saving by \"Save Options\" in Custom buffers.") (interactive "p") - (if ,(if body `(progn . ,body) - `(progn + (if ,(if setting-sexp + `,setting-sexp + `(progn (custom-load-symbol ',variable) (let ((set (or (get ',variable 'custom-set) 'set-default)) (get (or (get ',variable 'custom-get) 'default-value))) (funcall set ',variable (not (funcall get ',variable)))))) - (message ,message "enabled globally") - (message ,message "disabled globally")) - ;; The function `customize-mark-as-set' must only be called when - ;; a variable is set interactively, as the purpose is to mark it as - ;; a candidate for "Save Options", and we do not want to save options - ;; the user have already set explicitly in his init file. - (if interactively (customize-mark-as-set ',variable))) - '(menu-item ,doc ,name - :help ,help - :button (:toggle . (and (default-boundp ',variable) - (default-value ',variable)))))) + (message ,message "enabled globally") + (message ,message "disabled globally")) + ;; `customize-mark-as-set' must only be called when a variable is set + ;; interactively, because the purpose is to mark the variable as a + ;; candidate for `Save Options', and we do not want to save options that + ;; the user has already set explicitly in the init file. + (when interactively (customize-mark-as-set ',variable))) + '(menu-item ,item-name ,command :help ,help + :button (:toggle . (and (default-boundp ',variable) + (default-value ',variable))) + ,@keywords))) ;; Function for setting/saving default font. @@ -959,10 +991,11 @@ The selected font will be the default on both the existing and future frames." :help "Indicate buffer boundaries in fringe")) (bindings--define-key menu [indicate-empty-lines] - (menu-bar-make-toggle toggle-indicate-empty-lines indicate-empty-lines - "Empty Line Indicators" - "Indicating of empty lines %s" - "Indicate trailing empty lines in fringe, globally")) + (menu-bar-make-toggle-command + toggle-indicate-empty-lines indicate-empty-lines + "Empty Line Indicators" + "Indicating of empty lines %s" + "Indicate trailing empty lines in fringe, globally")) (bindings--define-key menu [customize] '(menu-item "Customize Fringe" menu-bar-showhide-fringe-menu-customize @@ -1407,7 +1440,7 @@ mail status in mode line")) (bindings--define-key menu [custom-separator] menu-bar-separator) (bindings--define-key menu [case-fold-search] - (menu-bar-make-toggle + (menu-bar-make-toggle-command toggle-case-fold-search case-fold-search "Ignore Case" "Case-Insensitive Search %s" @@ -1438,7 +1471,7 @@ mail status in mode line")) (if (featurep 'system-font-setting) (bindings--define-key menu [menu-system-font] - (menu-bar-make-toggle + (menu-bar-make-toggle-command toggle-use-system-font font-use-system-font "Use System Font" "Use system font: %s" @@ -1464,13 +1497,15 @@ mail status in mode line")) menu-bar-separator) (bindings--define-key menu [debug-on-quit] - (menu-bar-make-toggle toggle-debug-on-quit debug-on-quit - "Enter Debugger on Quit/C-g" "Debug on Quit %s" - "Enter Lisp debugger when C-g is pressed")) + (menu-bar-make-toggle-command + toggle-debug-on-quit debug-on-quit + "Enter Debugger on Quit/C-g" "Debug on Quit %s" + "Enter Lisp debugger when C-g is pressed")) (bindings--define-key menu [debug-on-error] - (menu-bar-make-toggle toggle-debug-on-error debug-on-error - "Enter Debugger on Error" "Debug on Error %s" - "Enter Lisp debugger when an error is signaled")) + (menu-bar-make-toggle-command + toggle-debug-on-error debug-on-error + "Enter Debugger on Error" "Debug on Error %s" + "Enter Lisp debugger when an error is signaled")) (bindings--define-key menu [debugger-separator] menu-bar-separator) @@ -1483,31 +1518,33 @@ mail status in mode line")) menu-bar-separator) (bindings--define-key menu [save-desktop] - (menu-bar-make-toggle + (menu-bar-make-toggle-command toggle-save-desktop-globally desktop-save-mode "Save State between Sessions" "Saving desktop state %s" "Visit desktop of previous session when restarting Emacs" - (require 'desktop) - ;; Do it by name, to avoid a free-variable - ;; warning during byte compilation. - (set-default - 'desktop-save-mode (not (symbol-value 'desktop-save-mode))))) + (progn + (require 'desktop) + ;; Do it by name, to avoid a free-variable + ;; warning during byte compilation. + (set-default + 'desktop-save-mode (not (symbol-value 'desktop-save-mode)))))) (bindings--define-key menu [save-place] - (menu-bar-make-toggle + (menu-bar-make-toggle-command toggle-save-place-globally save-place-mode "Save Place in Files between Sessions" "Saving place in files %s" "Visit files of previous session when restarting Emacs" - (require 'saveplace) - ;; Do it by name, to avoid a free-variable - ;; warning during byte compilation. - (set-default - 'save-place-mode (not (symbol-value 'save-place-mode))))) + (progn + (require 'saveplace) + ;; Do it by name, to avoid a free-variable + ;; warning during byte compilation. + (set-default + 'save-place-mode (not (symbol-value 'save-place-mode)))))) (bindings--define-key menu [uniquify] - (menu-bar-make-toggle + (menu-bar-make-toggle-command toggle-uniquify-buffer-names uniquify-buffer-name-style "Use Directory Names in Buffer Names" "Directory name in buffer names (uniquify) %s" diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el index c1184211d0..e5c62f9148 100644 --- a/lisp/progmodes/gdb-mi.el +++ b/lisp/progmodes/gdb-mi.el @@ -4665,11 +4665,11 @@ SPLIT-HORIZONTAL and show BUF in the new window." (interactive) (customize-option 'gdb-switch-reasons)))) (define-key menu [gdb-switch-when-another-stopped] - (menu-bar-make-toggle gdb-toggle-switch-when-another-stopped - gdb-switch-when-another-stopped - "Automatically switch to stopped thread" - "GDB thread switching %s" - "Switch to stopped thread")) + (menu-bar-make-toggle-command + gdb-toggle-switch-when-another-stopped + gdb-switch-when-another-stopped + "Automatically switch to stopped thread" + "GDB thread switching %s" "Switch to stopped thread")) (define-key gud-menu-map [mi] `(menu-item "GDB-MI" ,menu :visible (eq gud-minor-mode 'gdbmi)))) commit b6594d76068937958a7fab08a09115d84df7e81d Author: Lennart Borgman Date: Sat Sep 19 17:43:42 2020 +0200 Allow reveal mode to not automatically re-hide revealed text * lisp/reveal.el (reveal-hide-revealed): New command (bug#7101). (reveal-auto-hide): New defcustom. (reveal-post-command): Use it. diff --git a/etc/NEWS b/etc/NEWS index 26aa030391..6d27f769e0 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1015,6 +1015,12 @@ window after starting). This variable defaults to nil. ** Miscellaneous +--- +*** New user option 'reveal-auto-hide'. +If non-nil (the default), revealed text is automatically hidden when +point leaves the text. If nil, the text is not hidden again. Instead +`M-x reveal-hide-revealed' can be used to hide all the revealed text. + +++ *** New user options to control the look of line/column numbers in the mode line. 'mode-line-position-line-format' is the line number format (when diff --git a/lisp/reveal.el b/lisp/reveal.el index 92b80071f7..f9e3864634 100644 --- a/lisp/reveal.el +++ b/lisp/reveal.el @@ -60,6 +60,13 @@ :type 'boolean :group 'reveal) +(defcustom reveal-auto-hide t + "Automatically hide revealed text when leaving it. +If nil, the `reveal-hide-revealed' command can be useful to hide +revealed text manually." + :type 'boolean + :version "28.1") + (defvar reveal-open-spots nil "List of spots in the buffer which are open. Each element has the form (WINDOW . OVERLAY).") @@ -97,7 +104,8 @@ Each element has the form (WINDOW . OVERLAY).") (cdr x)))) reveal-open-spots)))) (setq old-ols (reveal-open-new-overlays old-ols)) - (reveal-close-old-overlays old-ols))))) + (when reveal-auto-hide + (reveal-close-old-overlays old-ols)))))) (defun reveal-open-new-overlays (old-ols) (let ((repeat t)) @@ -196,6 +204,14 @@ Each element has the form (WINDOW . OVERLAY).") (delq (rassoc ol reveal-open-spots) reveal-open-spots))))))) +(defun reveal-hide-revealed () + "Hide all revealed text. +If there is revealed text under point, this command does not hide +that text." + (interactive) + (let ((reveal-auto-hide t)) + (reveal-post-command))) + (defvar reveal-mode-map (let ((map (make-sparse-keymap))) ;; Override the default move-beginning-of-line and move-end-of-line @@ -209,7 +225,9 @@ Each element has the form (WINDOW . OVERLAY).") "Toggle uncloaking of invisible text near point (Reveal mode). Reveal mode is a buffer-local minor mode. When enabled, it -reveals invisible text around point." +reveals invisible text around point. + +Also see the `reveal-auto-hide' variable." :group 'reveal :lighter (global-reveal-mode nil " Reveal") :keymap reveal-mode-map commit 144bbfc6625c4e5c8a247d05f7a1dc45c2b62553 Author: Lars Ingebrigtsen Date: Sat Sep 19 17:21:02 2020 +0200 Allow customizing hooks defined via define-minor-mode * lisp/emacs-lisp/easy-mmode.el (define-minor-mode): Allow using Customize on the hooks (bug#10773). diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el index e3eb9294ed..fdc1233540 100644 --- a/lisp/emacs-lisp/easy-mmode.el +++ b/lisp/emacs-lisp/easy-mmode.el @@ -335,6 +335,9 @@ or call the function `%s'.")))) No problems result if this variable is not bound. `add-hook' automatically binds it. (This is true for all hook variables.)" modefun))) + ;; Allow using using `M-x customize-variable' on the hook. + (put ',hook 'custom-type 'hook) + (put ',hook 'standard-value (list nil)) ;; Define the minor-mode keymap. ,(unless (symbolp keymap) ;nil is also a symbol. commit 50b446a6b32166b15939d7285e35f70f1994b276 Author: Alex Bochannek Date: Sat Sep 19 16:49:38 2020 +0200 Fix gnus-summary-catchup-from-here edge case * lisp/gnus/gnus-sum.el (gnus-summary-catchup-from-here): Make the command work in the final line in the buffer, too (bug#43496). diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el index 2f0ea0c58f..8e27a94e5b 100644 --- a/lisp/gnus/gnus-sum.el +++ b/lisp/gnus/gnus-sum.el @@ -11537,7 +11537,7 @@ If ALL is non-nil, also mark ticked and dormant articles as read." (gnus-save-hidden-threads (let ((beg (point))) ;; We check that there are unread articles. - (when (or all (gnus-summary-find-next)) + (when (or all (gnus-summary-last-article-p) (gnus-summary-find-next)) (gnus-summary-catchup all t beg nil t))))) (gnus-summary-position-point)) commit e79d1e151f19b9679fa9ffa32d12d917e322136a Author: Lars Ingebrigtsen Date: Sat Sep 19 16:46:26 2020 +0200 Document Gnus body matching quirks * doc/misc/gnus.texi (Summary Score Commands): Document body match quirks (bug#43502). diff --git a/doc/misc/gnus.texi b/doc/misc/gnus.texi index 76aaca1699..2a0b51bd88 100644 --- a/doc/misc/gnus.texi +++ b/doc/misc/gnus.texi @@ -19907,7 +19907,7 @@ Substring matching. Fuzzy matching (@pxref{Fuzzy Matching}). @item r -Regexp matching +Regexp matching. @end table @item date @@ -19935,6 +19935,21 @@ Equal to number. @item > Greater than number. @end table + +@item body-strings + +These match types are available on the @samp{head} and @code{body} +``header types''. + +@table @kbd + +@item z +Substring matching. + +@item p +Regexp matching. +@end table + @end table @item @@ -19970,7 +19985,8 @@ To make things a bit more complicated, there are shortcuts. If you use a capital letter on either the second or third keys, Gnus will use defaults for the remaining one or two keystrokes. The defaults are ``substring'' and ``temporary''. So @kbd{I A} is the same as @kbd{I a s -t}, and @kbd{I a R} is the same as @kbd{I a r t}. +t}, and @kbd{I a R} is the same as @kbd{I a r t}. (These shortcuts +are not available for the body matches.) These functions take both the numerical prefix and the symbolic prefix (@pxref{Symbolic Prefixes}). A numerical prefix says how much to lower commit b8f447867f20ebfc2bb80dd44ecfac9b7b2ea628 Author: Lars Ingebrigtsen Date: Sat Sep 19 16:05:55 2020 +0200 Display the language in the Flyspell mode line * lisp/textmodes/flyspell.el (flyspell-mode): Display the language in the mode line (bug#14957). diff --git a/etc/NEWS b/etc/NEWS index 54bad068f8..26aa030391 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1139,6 +1139,10 @@ easily bind this menu to 'down-mouse-3' (usually the right mouse button) instead of 'mouse-2' (the default) by customizing the new user option 'flyspell-use-mouse-3-for-menu'. +--- +*** The current dictionary is now displayed in the minor mode lighter. +Clicking the dictionary name changes the current dictionary. + ** Time --- diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el index 51ed3a2f78..e862e354b5 100644 --- a/lisp/textmodes/flyspell.el +++ b/lisp/textmodes/flyspell.el @@ -529,7 +529,21 @@ in your init file. \\[flyspell-region] checks all words inside a region. \\[flyspell-buffer] checks the whole buffer." - :lighter flyspell-mode-line-string + :lighter (flyspell-mode-line-string + ;; If `flyspell-mode-line-string' is nil, then nothing of + ;; the following is displayed in the mode line. + ((:propertize flyspell-mode-line-string) + (:propertize + (:eval + (concat "/" (substring (or ispell-local-dictionary + ispell-dictionary + "--") + 0 2))) + face bold + help-echo "mouse-1: Change dictionary" + local-map (keymap + (mode-line keymap + (mouse-1 . ispell-change-dictionary)))))) :keymap flyspell-mode-map :group 'flyspell (if flyspell-mode