editorconfig / editorconfig-emacs

EditorConfig plugin for Emacs
https://editorconfig.org
GNU General Public License v3.0
748 stars 107 forks source link

Using a `insert-file-contents` with a temporary file causes `editorconfig--advice-insert-file-contents` to fail #353

Closed abougouffa closed 4 months ago

abougouffa commented 4 months ago

Hello,

Here is a minimal example illustrating the problem:

(with-temp-file "/tmp/file.1"
  (insert-file-contents "/tmp/file.1"))

And here is the trace after C-c C-e:

Debugger entered--Lisp error: (file-missing "Opening input file" "No such file or directory" "/tmp/file.1")
  #<subr insert-file-contents>("/tmp/file.1")
  editorconfig--advice-insert-file-contents(#<subr insert-file-contents> "/tmp/file.1")
  apply(editorconfig--advice-insert-file-contents #<subr insert-file-contents> "/tmp/file.1")
  insert-file-contents("/tmp/file.1")
  (save-current-buffer (set-buffer temp-buffer) (insert-file-contents "/tmp/file.1"))
  (prog1 (save-current-buffer (set-buffer temp-buffer) (insert-file-contents "/tmp/file.1")) (save-current-buffer (set-buffer temp-buffer) (write-region nil nil temp-file nil 0)))
  (unwind-protect (prog1 (save-current-buffer (set-buffer temp-buffer) (insert-file-contents "/tmp/file.1")) (save-current-buffer (set-buffer temp-buffer) (write-region nil nil temp-file nil 0))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer)))
  (let ((temp-file "/tmp/file.1") (temp-buffer (generate-new-buffer " *temp file*" t))) (unwind-protect (prog1 (save-current-buffer (set-buffer temp-buffer) (insert-file-contents "/tmp/file.1")) (save-current-buffer (set-buffer temp-buffer) (write-region nil nil temp-file nil 0))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))))
  elisp-eval-region-or-buffer()
  funcall-interactively(elisp-eval-region-or-buffer)
  command-execute(elisp-eval-region-or-buffer)