Skip to content

Conversation

kisaragi-hiu
Copy link

buffer-file-nameはファイルがfind-fileより開いたときもnilにさせられていることがあります。例えば、nov.elはこうして自動保存を無効にできています(https://github.com/wasamasa/nov.el/blob/ecbdecc927a3b3f7e0927d225e6e6464c244c2ae/nov.el#L720):

(define-derived-mode nov-mode special-mode "EPUB"
  ;; 中略 …
  (setq nov-file-name (buffer-file-name))
  (set-visited-file-name nil t) ; disable autosaves and save questions
  ;; …

このとき、find-file-hook--open-junk-filefile-truenameからエラーが出てしまいます。

こんなファイルやバッファーがjunk fileであることはないと思うので、エラーが出たら無視してフックも実行しないようにしました。

buffer-file-name can become nil even when opened through find-file. For
example, [nov.el] (an EPUB reader) does this to disable autosaves. Instead of
emitting the error, treat encountering an error as the file not being a junk
file, and proceed.

nov.el: https://github.com/wasamasa/nov.el
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant