From 6d10b607d094bfd29b9ce0c4baf469e3683c3ac6 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Tue, 25 Aug 2020 16:47:10 +0200 Subject: [PATCH] Possibly mention both file and buffer names in save-some-buffers * lisp/files.el (save-some-buffers): If the file and buffer names are dissimilar, mention both their names (bug#8399). --- lisp/files.el | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/lisp/files.el b/lisp/files.el index b6abafa4bd0..f1931c7d92f 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -5566,10 +5566,28 @@ change the additional actions you can take on files." t (setq queried t) (if (buffer-file-name buffer) - (format "Save file %s? " - (buffer-file-name buffer)) - (format "Save buffer %s? " - (buffer-name buffer)))))) + (if (or + (equal (buffer-name buffer) + (file-name-nondirectory + (buffer-file-name buffer))) + (string-match + (concat "\\<" + (regexp-quote + (file-name-nondirectory + buffer-file-name)) + "<[0-9]+>\\'") + (buffer-name buffer))) + ;; The buffer name is similar to the + ;; file name. + (format "Save file %s? " + (buffer-file-name buffer)) + ;; The buffer and file names are + ;; dissimilar; display both. + (format "Save file %s (buffer %s)? " + (buffer-file-name buffer) + (buffer-name buffer))) + ;; No file name + (format "Save buffer %s? " (buffer-name buffer)))))) (lambda (buffer) (with-current-buffer buffer (save-buffer))) -- 2.39.2