From: Sean Whitton Date: Thu, 3 Oct 2024 10:36:45 +0000 (+0800) Subject: New M-~ entry in save-some-buffers-action-alist X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=24e9b1b68c5bb665b11b57de70de006cc70c236e;p=emacs.git New M-~ entry in save-some-buffers-action-alist * lisp/files.el (save-some-buffers-action-alist): New M-~ entry. (save-some-buffers): * doc/emacs/files.texi (Save Commands): * etc/NEWS: Document the new M-~ binding during C-x s. (cherry picked from commit cc2ad5c2d1508236e79658936e7c7f532ddba586) --- diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi index 460214d7208..2bce0749790 100644 --- a/doc/emacs/files.texi +++ b/doc/emacs/files.texi @@ -479,6 +479,9 @@ Terminate @code{save-some-buffers} without any more saving. @item . Save this buffer, then exit @code{save-some-buffers} without even asking about other buffers. +@item M-~ +Don't save this buffer, and also mark it as unmodified. +This is like the @code{not-modified} command (@pxref{Save Commands}). @item C-r View the buffer that you are currently being asked about. When you exit View mode, you get back to @code{save-some-buffers}, which asks the diff --git a/etc/NEWS b/etc/NEWS index ea1aefe00c1..151469dc094 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -139,6 +139,11 @@ You can now insert or wrap text with multiple sets of parentheses and other matching delimiters at once with Electric Pair mode, by providing a prefix argument when inserting one of the delimiters. ++++ +** You can now use M-~ during C-x s ('save-some-buffers'). +Typing M-~ while saving some buffers means not to save the buffer and +also to mark it as unmodified. This is an alternative way to mark a +buffer as unmodified which doesn't require switching to that buffer. * Changes in Specialized Modes and Packages in Emacs 31.1 diff --git a/lisp/files.el b/lisp/files.el index be4e637df22..a72cbeec195 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -6195,7 +6195,13 @@ Before and after saving the buffer, this function runs (defvar save-some-buffers--switch-window-callback nil) (defvar save-some-buffers-action-alist - `((?\C-r + `((?\M-~ ,(lambda (buf) + (with-current-buffer buf + (set-buffer-modified-p nil)) + ;; Return t not to ask about BUF again. + t) + ,(purecopy "skip this buffer and mark it unmodified")) + (?\C-r ,(lambda (buf) (view-buffer buf (lambda (_) (exit-recursive-edit))) (recursive-edit) @@ -6296,7 +6302,8 @@ in variables (rather than in buffers).") (defun save-some-buffers (&optional arg pred) "Save some modified file-visiting buffers. Asks user about each one. -You can answer \\`y' or \\`SPC' to save, \\`n' or \\`DEL' not to save, \\`C-r' +You can answer \\`y' or \\`SPC' to save, \\`n' or \\`DEL' not to save, +\\`M-~' not to save and also mark the buffer as unmodified, \\`C-r' to look at the buffer in question with `view-buffer' before deciding, \\`d' to view the differences using `diff-buffer-with-file', \\`!' to save the buffer and all remaining