]> git.eshelyaron.com Git - emacs.git/commitdiff
Possibly mention both file and buffer names in save-some-buffers
authorLars Ingebrigtsen <larsi@gnus.org>
Tue, 25 Aug 2020 14:47:10 +0000 (16:47 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Tue, 25 Aug 2020 14:47:10 +0000 (16:47 +0200)
* lisp/files.el (save-some-buffers): If the file and buffer names
are dissimilar, mention both their names (bug#8399).

lisp/files.el

index b6abafa4bd0de9105e25273983a3fae03bd167b7..f1931c7d92fd8510c88c59ffc495ed1d601eefe6 100644 (file)
@@ -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)))