From 68d9a048cdd05d19fe79f87a2ec32dde14fd282b Mon Sep 17 00:00:00 2001 From: jao Date: Thu, 1 Sep 2022 04:07:54 +0100 Subject: doc session: allowing a buffer to register more than one file --- lib/doc/jao-doc-session.el | 8 +++++--- lib/doc/jao-org-links.el | 10 ++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/doc/jao-doc-session.el b/lib/doc/jao-doc-session.el index 3eee781..669b191 100644 --- a/lib/doc/jao-doc-session.el +++ b/lib/doc/jao-doc-session.el @@ -48,8 +48,8 @@ (let ((docs '()) (cb (and skip-current (current-buffer)))) (dolist (b (buffer-list)) - (when-let (fn (and (not (eq cb b)) (jao-doc-session-is-doc b))) - (add-to-list 'docs fn))) + (when-let (fs (and (not (eq cb b)) (jao-doc-session-is-doc b))) + (dolist (f fs) (add-to-list 'docs f)))) (when (or force (> (length docs) 0)) (jao-doc-session--save-to-file jao-doc-session-file docs)))) @@ -60,7 +60,9 @@ t)) (defun jao-doc-session-mark (&optional path) - (setq jao-doc-session--is-doc (or path (buffer-file-name))) + (unless (listp jao-doc-session--is-doc) + (setq jao-doc-session--is-doc (ensure-list jao-doc-session--is-doc))) + (cl-pushnew (or path (buffer-file-name)) jao-doc-session--is-doc) (jao-doc-session--save-session)) (defun jao-doc-session--save-1 () diff --git a/lib/doc/jao-org-links.el b/lib/doc/jao-org-links.el index d6bb8dc..dd8f2bb 100644 --- a/lib/doc/jao-org-links.el +++ b/lib/doc/jao-org-links.el @@ -2,17 +2,19 @@ (require 'jao-org-notes) (require 'jao-doc-view) +(require 'jao-doc-session) (require 'jao-pdf) (defvar jao-org--sink-dir "./") -(defvar jao-org-open-pdf-fun #'jao-org--pdf-open) +(defvar jao-org-open-pdf-fun #'jao-org--default-open) -(defun jao-org--pdf-open (path page &optional height) +(defun jao-org--default-open (path page &optional height) (org-open-file path 1) (jao-doc-view-goto-page page height)) (defun jao-org--pdf-open (path page &optional height) - (funcall (or jao-org-open-pdf-fun #'jao-org--pdf-open) path page height)) + (when (file-exists-p path) (jao-doc-session-mark path)) + (funcall (or jao-org-open-pdf-fun #'jao-org--default-open) path page height)) (defun jao-org-links--open-pdf (link) "Open LINK in pdf-view-mode." @@ -119,7 +121,7 @@ (defun jao-org-goto-pdf () (interactive) (if-let (f (jao-org-org-to-pdf-file)) - (funcall jao-org-open-pdf-fun f 1) + (jao-org--pdf-open f nil) (user-error "No PDF file associated with this buffer"))) (with-eval-after-load "org" -- cgit v1.2.3