diff options
author | jao <jao@gnu.org> | 2021-04-06 00:30:44 +0100 |
---|---|---|
committer | jao <jao@gnu.org> | 2021-04-06 00:30:44 +0100 |
commit | 52c3a690da3ceb54a04e5ceac593dc8ca8984516 (patch) | |
tree | 5b091bb9b48a73b6862dac27fad59140eac84891 /lib | |
parent | 7b603b967c2748a3d7fd55595f564b70809f8f9f (diff) | |
download | elibs-52c3a690da3ceb54a04e5ceac593dc8ca8984516.tar.gz elibs-52c3a690da3ceb54a04e5ceac593dc8ca8984516.tar.bz2 |
doc-view page trails
Diffstat (limited to 'lib')
-rw-r--r-- | lib/doc/jao-doc-view.el | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/lib/doc/jao-doc-view.el b/lib/doc/jao-doc-view.el index 1e5c048..762719b 100644 --- a/lib/doc/jao-doc-view.el +++ b/lib/doc/jao-doc-view.el @@ -153,15 +153,33 @@ (when-let (item (car (last args))) (let-alist item (jao-doc-view-goto-page .page)))) - -;; install -;;;###autoload -(defun jao-doc-view-install () - (add-hook 'doc-view-mode-hook #'jao-doc-view--enable-imenu) - (add-hook 'kill-buffer-hook 'jao-doc-view--save-session-1 t) - (add-hook 'kill-emacs-hook 'jao-doc-view-save-session) - (jao-doc-view-start-session-timer)) +(add-hook 'doc-view-mode-hook #'jao-doc-view--enable-imenu) + +;;; Page trailing +(defvar-local jao-doc-view--trail-back ()) +(defvar-local jao-doc-view--trail-fwd ()) + +(defun jao-doc-view--trail-push (dest-page) + (when-let (page (jao-doc-view-current-page)) + (unless (eq (car jao-doc-view--trail-back) page) + (push page jao-doc-view--trail-back)))) + +(defun jao-doc-view-back () + (interactive nil doc-view-mode) + (if-let (p (pop jao-doc-view--trail-back)) + (progn (push (jao-doc-view-current-page) jao-doc-view--trail-fwd) + (jao-doc-view-goto-page p)) + (message "No more back marks."))) + +(defun jao-doc-view-forward () + (interactive nil doc-view-mode) + (if-let (p (pop jao-doc-view--trail-fwd)) + (progn (push (jao-doc-view-current-page) jao-doc-view--trail-back) + (jao-doc-view-goto-page p)) + (message "No more forward marks."))) + +(advice-add 'doc-view-goto-page :before #'jao-doc-view--trail-push) (provide 'jao-doc-view) |