Skip to content

Instantly share code, notes, and snippets.

@soulawaker
Last active September 18, 2019 16:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save soulawaker/538689eef010da3ace731dc6f680a691 to your computer and use it in GitHub Desktop.
Save soulawaker/538689eef010da3ace731dc6f680a691 to your computer and use it in GitHub Desktop.
Make the persp-mode save|restore nov.el EPUB buffer. Tested in my spacemacs.
(with-eval-after-load "persp-mode"
(with-eval-after-load "nov"
(add-hook 'persp-save-buffer-functions
'(lambda (b)
(when (eq 'nov-mode (buffer-local-value 'major-mode b))
`(def-nov-buffer ,(buffer-name b)
,(buffer-local-value 'nov-file-name b)
,(buffer-local-value 'major-mode b)))))
(add-hook 'persp-load-buffer-functions
'(lambda (savelist)
(when (eq (car savelist) 'def-nov-buffer)
(with-current-buffer (get-buffer-create (cadr savelist))
(setq buffer-file-name (expand-file-name (caddr savelist)))
(require 'nov)
(nov-mode)))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment