summaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2021-04-06 00:30:25 +0100
committerjao <jao@gnu.org>2021-04-06 00:30:25 +0100
commit7b603b967c2748a3d7fd55595f564b70809f8f9f (patch)
treeb664cf767f629ec8bf0b2946cf10952263b110cb /lib
parent8f1f006e644bcabdada369cbcb0b5f5b6c01cbe3 (diff)
downloadelibs-7b603b967c2748a3d7fd55595f564b70809f8f9f.tar.gz
elibs-7b603b967c2748a3d7fd55595f564b70809f8f9f.tar.bz2
jao-doc-view: sessions don't need a timer either
Diffstat (limited to 'lib')
-rw-r--r--lib/doc/jao-doc-view.el29
1 files changed, 10 insertions, 19 deletions
diff --git a/lib/doc/jao-doc-view.el b/lib/doc/jao-doc-view.el
index af87c9e..1e5c048 100644
--- a/lib/doc/jao-doc-view.el
+++ b/lib/doc/jao-doc-view.el
@@ -29,7 +29,7 @@
(require 'doc-view)
-(defvar jao-doc-view-session-file "~/.emacs.d/doc-view-session")
+(defvar jao-doc-view-session-file "~/.emacs.d/cache/doc-view-session.eld")
(defun jao-doc-view--read-file (file)
(let ((buff (find-file-noselect file)))
@@ -54,36 +54,27 @@
(cb (when skip-current (current-buffer))))
(dolist (b (buffer-list))
(with-current-buffer b
- (when (and (equalp major-mode 'pdf-view-mode)
+ (when (and (derived-mode-p 'doc-view-mode 'pdf-view-mode)
(not (equalp cb b)))
(add-to-list 'docs (buffer-file-name)))))
(when (> (length docs) 0)
- (jao-doc-view--save-to-file jao-doc-view-session-file docs))))
+ (jao-doc-view--save-to-file jao-doc-view-session-file docs))
+ (message "%s docs saved" (length docs))))
(defun jao-doc-view--save-session-1 ()
(when (derived-mode-p 'pdf-view-mode 'doc-view-mode)
(jao-doc-view-save-session t)))
-(defvar jao-doc-session-timer nil)
-(defvar jao-doc-session-timer-seconds 60)
-
-(defun jao-doc-view-stop-session-timer ()
- (interactive)
- (when jao-doc-session-timer
- (cancel-timer jao-doc-session-timer)
- (setq jao-doc-session-timer nil)))
-
(defun jao-doc-view--save-session ()
(let ((inhibit-message t)
(message-log-max nil))
- (jao-doc-view-save-session)))
+ (jao-doc-view-save-session)
+ t))
-(defun jao-doc-view-start-session-timer ()
- (interactive)
- (setq jao-doc-session-timer
- (run-with-idle-timer jao-doc-session-timer-seconds
- t
- 'jao-doc-view--save-session)))
+(add-hook 'kill-emacs-query-functions #'jao-doc-view--save-session)
+(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)
;;; PDF info