wasamasa / nov.el

Major mode for reading EPUBs in Emacs
GNU General Public License v3.0
654 stars 34 forks source link

Add the opened ebook into Recent Files. #40

Closed qinbill closed 5 years ago

qinbill commented 5 years ago

I use spacemacs. it would be helpful if the Nov mode can automatically add the opened files into the recent files, ie recentf.

wasamasa commented 5 years ago

Interesting, the reason the files don't end up there is because by default recentf-mode hooks into file functions that assume a recent file is associated with a filename. This isn't the case here because the association with the filename is cut to avoid warnings about modified files or saving the file to destroy your EPUB.

I've recently added support for third-party packages to figure out the original filename by checking nov-file-name. With this it's possible to add the opened file to recentf-list:

(defun my-nov-add-to-recentf ()
  (when nov-file-name
    (recentf-add-file nov-file-name)))

(add-hook 'nov-mode-hook 'my-nov-add-to-recentf)

Does this work as expected for you?

qinbill commented 5 years ago

Thanks. It worked.