Fix file-name-non-special implementation of get-file-buffer

* lisp/files.el (file-name-non-special): Fix `get-file-buffer'.
(Bug#80718)

* test/lisp/files-tests.el
(files-tests-file-name-non-special--temp-file-prefixes): Extend list.
(w32-downcase-file-names): Declare.
(files-tests-file-name-non-special-get-file-buffer): Adapt test.
This commit is contained in:
Michael Albinus 2026-05-12 08:48:43 +02:00
parent 6d347d9834
commit c68f3237be
2 changed files with 13 additions and 3 deletions

View file

@ -8742,6 +8742,9 @@ arguments as the running Emacs)."
(file-in-directory-p 0 1)
(make-symbolic-link 0 1)
(add-name-to-file 0 1)
;; `get-file-buffer' shall simply run the
;; original function.
(get-file-buffer)
;; These file-notify-* operations take a
;; descriptor.
(file-notify-rm-watch)

View file

@ -401,7 +401,8 @@ be $HOME."
(append '("foo" "$foo" "~foo")
;; No amount of quoting will allow creation of a file name
;; with an embedded '*' on MS-Windows and MS-DOS.
(if (not (memq system-type '(windows-nt ms-dos))) '("foo*bar")))
(if (not (memq system-type '(windows-nt ms-dos)))
'("foo*bar" "foo?bar")))
"Prefixes to be tested for `file-name-non-special' tests.")
(ert-deftest files-tests-file-name-non-special--subprocess ()
@ -696,6 +697,8 @@ unquoted file names."
(tmpdir nospecial-dir t)
(should-error (directory-files-and-attributes nospecial-dir))))
(defvar w32-downcase-file-names)
(ert-deftest files-tests-directory-files-recursively-w32 ()
"Test MS-Windows specific features of `directory-files-recursively'."
(skip-unless (eq system-type 'windows-nt))
@ -1054,12 +1057,16 @@ unquoted file names."
(ert-deftest files-tests-file-name-non-special-get-file-buffer ()
;; Make sure these buffers don't exist.
(files-tests--with-temp-non-special (tmpfile nospecial)
(find-file-noselect nospecial)
(let ((fbuf (get-file-buffer nospecial)))
(if fbuf (kill-buffer fbuf))
(should (get-file-buffer nospecial))
(kill-buffer fbuf)
(should-not (get-file-buffer nospecial))))
(files-tests--with-temp-non-special-and-file-name-handler (tmpfile nospecial)
(find-file-noselect nospecial)
(let ((fbuf (get-file-buffer nospecial)))
(if fbuf (kill-buffer fbuf))
(should (get-file-buffer nospecial))
(kill-buffer fbuf)
(should-not (get-file-buffer nospecial)))))
(ert-deftest files-tests-file-name-non-special-insert-directory ()