emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/org-remark ba8e3433e0 18/67: feat: test/find-nov-file-b


From: ELPA Syncer
Subject: [elpa] externals/org-remark ba8e3433e0 18/67: feat: test/find-nov-file-buffer
Date: Sat, 22 Jul 2023 06:59:00 -0400 (EDT)

branch: externals/org-remark
commit ba8e3433e0921e5572d6215ca92cd6bcda154ff5
Author: Noboru Ota <me@nobiot.com>
Commit: Noboru Ota <me@nobiot.com>

    feat: test/find-nov-file-buffer
---
 adjust-highlights.el | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/adjust-highlights.el b/adjust-highlights.el
index 1cad144627..1bb48c2b3f 100644
--- a/adjust-highlights.el
+++ b/adjust-highlights.el
@@ -23,3 +23,28 @@
        ;; separately.
        (when (re-search-forward text paragraph-end :noerror)
          (move-overlay highlight (match-beginning 0) (match-end 0)))))))
+
+;; navigate from notes to document
+(defun test/find-nov-file-buffer ()
+  (when-let* ((pos (point))
+              (base-buf (or (buffer-base-buffer) (current-buffer)))
+              (link (with-current-buffer base-buf
+                      (org-entry-get pos "org-remark-link")))
+              (path (with-temp-buffer
+                      (insert link) (beginning-of-buffer)
+                      (org-element-property :path (org-element-context))))
+              (file (if (string-match "^\\(.*\\)::\\([0-9]+\\):\\([0-9]+\\)$" 
path) ;; nov only
+                        (match-string 1 path)                                  
     ;; nov only
+                      (error "Invalid nov.el link")))                          
     ;; nov only
+              (index (string-to-number (match-string 2 path)))                 
     ;; nov only
+              (point (string-to-number (match-string 3 path)))                 
     ;; nov only
+              (source-buffers (with-current-buffer base-buf
+                                org-remark-notes-source-buffers))
+              (epub-buffer (seq-find
+                            (lambda (buf) (and (buffer-live-p buf)
+                                               (with-current-buffer buf
+                                                 (string= file 
nov-file-name))))    ;; nov only
+                            source-buffers)))
+    (pop-to-buffer epub-buffer)
+    ;; If FILE is nil, the current buffer is used.
+    (nov--find-file nil index point)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]