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

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

[elpa] externals/org-remark c38f46e806 42/67: refactor(highlight-add): r


From: ELPA Syncer
Subject: [elpa] externals/org-remark c38f46e806 42/67: refactor(highlight-add): remove spurflous/obsolete elements
Date: Sat, 22 Jul 2023 06:59:03 -0400 (EDT)

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

    refactor(highlight-add): remove spurflous/obsolete elements
    
    Test for eww, epub, and default (txt) all have worked. Functionally, it
    appears as good as refactoring goes.
---
 org-remark-nov.el | 32 +++++---------------------------
 org-remark.el     | 55 ++++++++++++++++++++++++++-----------------------------
 2 files changed, 31 insertions(+), 56 deletions(-)

diff --git a/org-remark-nov.el b/org-remark-nov.el
index 8792a74124..c7540cf3b5 100644
--- a/org-remark-nov.el
+++ b/org-remark-nov.el
@@ -24,22 +24,20 @@
       (progn
         (add-hook 'org-remark-source-find-file-name-functions
                   #'org-remark-get-epub-source)
-        (add-hook 'org-remark-highlight-link-to-source-functions 
#'org-remark-nov-link)
         (add-hook 'org-remark-highlight-link-to-source-functions
                   #'org-remark-nov-link)
         ;; When users turn the page (document in nov-mode's terminology)
-        ;; `nov-mode' will erase the current buffer and render the new document
-        ;; content in the same buffer.  This means the highlights currently
-        ;; displayed get removed; the ones for the new document need to be
-        ;; loaded document after `nov-mode' renders the new document.
+        ;; `nov-mode' will erase the current buffer and render the new
+        ;; document content in the same buffer. This means the
+        ;; highlights currently displayed get removed; the ones for the
+        ;; new document need to be loaded document after `nov-mode'
+        ;; renders the new document.
         (add-hook 'nov-post-html-render-hook #'org-remark-highlights-load))
     ;; Disable
     (remove-hook 'org-remark-source-find-file-name-functions
                  #'org-remark-get-epub-source)
     (remove-hook 'org-remark-highlight-link-to-source-functions
                  #'org-remark-nov-link)
-    (remove-hook 'org-remark-highlight-link-to-source-functions
-              #'org-remark-nov-link)
     (remove-hook 'nov-post-html-render-hook #'org-remark-highlights-load)))
 
 (cl-defmethod org-remark-notes-get-file-name-for-mode (&context (major-mode 
nov-mode))
@@ -82,11 +80,6 @@
     (let ((temp-filename (cdr (aref nov-documents nov-documents-index))))
       (file-name-base temp-filename))))
 
-;; (defun org-remark-get-epub-filename ()
-;;   "Return the path of the epub source from which the present session is 
initiated."
-;;   (when (eq major-mode 'nov-mode)
-;;     nov-file-name))
-
 (defun org-remark-nov-link (_filname _point)
   "Return \"nov:\" link with current point in `nov-mode' buffer.
 
@@ -97,9 +90,6 @@ buffer."
   (when (eq major-mode 'nov-mode)
     (org-store-link nil)))
 
-(defun test/org-remark-nov-highlight-headlines (_level source-buf notes-buf)
-  (org-remark-nov-highlight-new-headline-maybe source-buf notes-buf))
-
 (cl-defmethod org-remark-highlight-get-constructors (&context (major-mode 
nov-mode))
   "Dev needs to define a mode-specific headline constructors.
 `(level source-filename-fn title-fn prop-to-find)`'"
@@ -114,18 +104,6 @@ buffer."
          (headline-constructors (list headline-1 headline-2)))
     headline-constructors))
 
-(defun org-remark-nov-highlight-new-headline-maybe (source-buf notes-buf)
-  (let* ((headline-1 (list 1
-                           (lambda () nov-file-name)
-                           (lambda () (cdr (assoc 'title nov-metadata)))
-                           "org-remark-nov-file"))
-         (headline-2 (list 2
-                           #'org-remark-get-epub-source
-                           #'org-remark-nov-get-epub-document-title
-                           org-remark-prop-source-file))
-         (headline-constructs (list headline-1 headline-2)))
-    (org-remark-highlight-new-headline-maybe headline-constructs source-buf 
notes-buf)))
-
 ;; navigate from notes to document
 (defun test/find-nov-file-buffer ()
   (interactive)
diff --git a/org-remark.el b/org-remark.el
index 28c856fa26..3b87319f93 100644
--- a/org-remark.el
+++ b/org-remark.el
@@ -893,33 +893,29 @@ buffer for automatic sync."
        ;;      text file:   1. source file; 2. highlight
        ;; Note the lowest level is always the highlight (common). And
        ;; the top level is the "source" -- the file or URL, etc.
-       (setq point
-             (cl-loop for (level filename-fn title-fn prop-to-find) in 
headline-constructors
-                      ;; This variable "point" is set in order to be returned 
at
-                      ;; the end of the loop.
-                      with point = nil
-                      do (let (filename title)
-                           (with-current-buffer source-buf
-                             (setq filename (funcall filename-fn))
-                             (setq title (funcall title-fn)))
-                           (with-current-buffer notes-buf
-                             (setq point
-                                   (or (org-find-property
-                                        prop-to-find filename)
-                                       (org-remark-new-headline
-                                        level title (list prop-to-find 
filename))))))
-                      finally return point))
-       ;; FIXME For now, the highlight gets in the wrong structure in
-       ;; notes and disappears from the source if the point moves after
-       ;; the loop. I suspect
-       ;; `org-remark-highlight-add-or-update-highlight-headline' needs
-       ;; the point to be a certain place withint the notes strucuture.
-       ;; This should be fixed when we refactor this function.
-       (goto-char point)
-       ;; Highlight Headline is common to all major-mode extensions
-       (setq notes-props
-             (org-remark-highlight-add-or-update-highlight-headline
-              overlay source-buf notes-buf))))
+       (cl-loop for (level filename-fn title-fn prop-to-find) in 
headline-constructors
+                ;; This variable "point" is set in order to be returned at
+                ;; the end of the loop.
+                with point = nil
+                do (let (filename title)
+                     (with-current-buffer source-buf
+                       (setq filename (funcall filename-fn))
+                       (setq title (funcall title-fn)))
+                     (with-current-buffer notes-buf
+                       (setq point
+                             (or (org-find-property
+                                  prop-to-find filename)
+                                 (org-remark-new-headline
+                                  level title (list prop-to-find filename))))))
+                ;; Add the hightlight/note nodes after the headline loop.
+                finally (progn
+                          ;; need to move to the point at the end
+                          ;; of loop
+                          (goto-char point)
+                          ;; Highlight Headline is common to all major-mode 
extensions
+                          (setq notes-props
+                                
(org-remark-highlight-add-or-update-highlight-headline
+                                 overlay source-buf notes-buf))))))
     ;;; Set up notes buffer for sync for the source buffer
     (with-current-buffer source-buf
       (unless org-remark-source-setup-done
@@ -927,8 +923,9 @@ buffer for automatic sync."
     ;;; Return notes-props
     notes-props))
 
-(defun org-remark-new-headline (level title props)
-  ""
+(defun org-remark-new-headline (level title props &rest args)
+  "
+Return the point of beginning of current heading."
   ;; If file-headline does not exist, create one at the bottom
   (org-narrow-to-subtree)
   (goto-char (point-max))



reply via email to

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