From 286934e3ed238a2ee8c6137568742e917bc44d97 Mon Sep 17 00:00:00 2001 From: jao Date: Mon, 18 Apr 2022 00:01:24 +0100 Subject: epub files in doc session --- init.org | 3 ++- lib/doc/jao-doc-view.el | 17 +++++++++-------- lib/eos/jao-afio.el | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/init.org b/init.org index e6805d8..553bdf0 100644 --- a/init.org +++ b/init.org @@ -1823,7 +1823,8 @@ (use-package nov :ensure t :after doc-view - :init (setq nov-variable-pitch nil) + :init (setq nov-variable-pitch t + nov-text-width 80) :config (add-to-list 'auto-mode-alist '("\\.epub\\'" . nov-mode))) #+end_src diff --git a/lib/doc/jao-doc-view.el b/lib/doc/jao-doc-view.el index 4e210f3..ea55565 100644 --- a/lib/doc/jao-doc-view.el +++ b/lib/doc/jao-doc-view.el @@ -1,6 +1,6 @@ ;; jao-doc-view.el -- Remembering visited documents -*- lexical-binding: t; -*- -;; Copyright (c) 2013, 2015, 2017, 2018, 2019, 2021 Jose Antonio Ortega Ruiz +;; Copyright (c) 2013, 2015, 2017, 2018, 2019, 2021, 2022 Jose Antonio Ortega Ruiz ;; This file is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -30,12 +30,12 @@ (require 'doc-view) (defvar jao-doc-view-session-file "~/.emacs.d/cache/doc-view-session.eld") -(defvar-local jao-doc-view--is-pdf nil) +(defvar-local jao-doc-view--is-doc nil) -(defun jao-doc-view-session-mark (path) (setq-local jao-doc-view--is-pdf path)) -(defun jao-doc-view--is-pdf () - (or jao-doc-view--is-pdf - (when (derived-mode-p 'doc-view-mode 'pdf-view-mode) +(defun jao-doc-view-session-mark (path) (setq-local jao-doc-view--is-doc path)) +(defun jao-doc-view--is-doc () + (or jao-doc-view--is-doc + (when (derived-mode-p 'doc-view-mode 'pdf-view-mode 'nov-mode) (buffer-file-name)))) (defun jao-doc-view--read-file (file) @@ -61,13 +61,13 @@ (cb (when skip-current (current-buffer)))) (dolist (b (buffer-list)) (with-current-buffer b - (when-let (fn (and (not (eq cb b)) (jao-doc-view--is-pdf))) + (when-let (fn (and (not (eq cb b)) (jao-doc-view--is-doc))) (add-to-list 'docs fn)))) (when (> (length docs) 0) (jao-doc-view--save-to-file jao-doc-view-session-file docs)))) (defun jao-doc-view--save-session-1 () - (when (jao-doc-view--is-pdf) (jao-doc-view-save-session t))) + (when (jao-doc-view--is-doc) (jao-doc-view-save-session t))) (defvar jao-doc-view-inhibit-session-save nil) @@ -82,6 +82,7 @@ (add-hook 'kill-buffer-hook #'jao-doc-view--save-session-1) (add-hook 'doc-view-mode-hook #'jao-doc-view--save-session) (add-hook 'pdf-view-mode-hook #'jao-doc-view--save-session) +(add-hook 'nov-mode-hook #'jao-doc-view--save-session) ;;; PDF info diff --git a/lib/eos/jao-afio.el b/lib/eos/jao-afio.el index 470981d..28e6f67 100644 --- a/lib/eos/jao-afio.el +++ b/lib/eos/jao-afio.el @@ -86,7 +86,7 @@ (delete-other-windows) (split-window-right) (let ((docs (cl-remove-if-not (lambda (b) - (with-current-buffer b (jao-doc-view--is-pdf))) + (with-current-buffer b (jao-doc-view--is-doc))) (buffer-list)))) (if (car docs) (progn (switch-to-buffer (car docs)) -- cgit v1.2.3