Ensure #'magic:find-file-noselect creates unique buffers
authorSteve Youngs <steve@sxemacs.org>
Tue, 17 Mar 2020 04:08:18 +0000 (14:08 +1000)
committerSteve Youngs <steve@sxemacs.org>
Tue, 17 Mar 2020 04:08:18 +0000 (14:08 +1000)
Having `magic:find-file-magic-alist-enable' features turned on, the
following scenario could eventuate...

  C-x C-f /path/one/to/a/file/called/Wanda

  C-x C-f /path/two/to/another/file/called/Wanda

would result in the *same* buffer being used for *both* files.
Imagine the fun, especially when both paths are writable for you.

This change fixes that.

* lisp/ffi/ffi-magic.el (magic:find-file-noselect): Use
#'create-file-buffer, not #'get-buffer-create. Gah! What was I
thinking?!

Signed-off-by: Steve Youngs <steve@sxemacs.org>
lisp/ffi/ffi-magic.el

index 955ab4d..bb6ab16 100644 (file)
@@ -590,7 +590,7 @@ set by something else prior.  For example, if the user had called
 (defun magic:find-file-noselect (file)
   (let* ((codesys (intern (magic:file file :mime-encoding)))
         (coding-system-for-read codesys)
-        (buf (get-buffer-create (file-name-nondirectory file)))
+        (buf (create-file-buffer file))
         (coding nil))
     (with-current-buffer buf
       (insert-file-contents file t)