Subject: bug#43192: lisp/files.el; 6d10b607d0 introduced bug that breaks C-x C-c

From: Lars Ingebrigtsen <[email-masked]>
Date: Fri, 04 Sep 2020 04:58:54 +0200

Tom Gillespie <[email-masked]> writes:

> #+begin_src diff
> +                                   (string-match
> +                                    (concat "\\<"
> +                                            (regexp-quote
> +                                             (file-name-nondirectory
> +                                              buffer-file-name))
> +                                            "<[0-9]+>\\'")
> +                                    (buffer-name buffer)))
> #+end_src
>
> This is the second statement in a call to `or'. buffer-file-name is
> not guaranteed to be non-nil because buffers like *scratch* and
> *Messages* exist. In many workflows for emacsclient opening to scratch
> and closing again from scratch are common.

I think it's just a typo -- the code should be:

diff --git a/lisp/files.el b/lisp/files.el
index 3403e257a1..5f5902d0cb 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -5574,7 +5574,7 @@ save-some-buffers
                                     (concat "\\<"
                                             (regexp-quote
                                              (file-name-nondirectory
-                                              buffer-file-name))
+                                              (buffer-file-name buffer)))
                                             "<[^>]*>\\'")
                                     (buffer-name buffer)))
                                   ;; The buffer name is similar to the

I've now applied this to Emacs 28, and that fixes the test case in this
bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no