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

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

[elpa] externals/org-remark 8004555a9b 16/37: fix: highlights housekeep


From: ELPA Syncer
Subject: [elpa] externals/org-remark 8004555a9b 16/37: fix: highlights housekeep to delete notes when you want to keep
Date: Sat, 14 Jan 2023 10:58:01 -0500 (EST)

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

    fix: highlights housekeep to delete notes when you want to keep
    
    In working toward supporting nov.el, it was found out that marginal
    notes were removed when they should be kept intact.  It was found that
    '-highlights-housekeep' function was the cause.  This was because nov.el
    buffer becomes writable when we turn the
    page:(e.g. 'nov-next-document'), erase the buffer, and then render the
    new page.  Housekeeping should be done to the highlights overlays from
    the now-the-previous page (as they will have start/end both 1); however,
    the related notes must not be removed.
    
    This can be prevented by adding additional condition that the major mode
    is derived from special mode (nov-mode is).
---
 org-remark.el | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/org-remark.el b/org-remark.el
index 2606804385..a64093ed88 100644
--- a/org-remark.el
+++ b/org-remark.el
@@ -6,7 +6,7 @@
 ;; URL: https://github.com/nobiot/org-remark
 ;; Version: 1.0.5
 ;; Created: 22 December 2020
-;; Last modified: 08 January 2023
+;; Last modified: 09 January 2023
 ;; Package-Requires: ((emacs "27.1") (org "9.4"))
 ;; Keywords: org-mode, annotation, note-taking, marginal-notes, wp,
 
@@ -872,7 +872,7 @@ buffer for automatic sync."
       (org-remark-notes-setup notes-buf source-buf))
     (with-current-buffer notes-buf
       (when (featurep 'org-remark-convert-legacy) 
(org-remark-convert-legacy-data))
-      ;;`org-with-wide-buffer is a macro that should work for non-Org file'
+      ;;`org-with-wide-buffer' is a macro that should work for non-Org file
       (org-with-wide-buffer
        (let ((file-headline
               (or (org-find-property
@@ -1319,7 +1319,17 @@ Case 2. The overlay points to no buffer
     ;; annotation when it is.
     (when (and (overlay-buffer ov)
                (= (overlay-start ov) (overlay-end ov)))
-      (when (not buffer-read-only)
+      (when (and (not buffer-read-only)
+                 (not (derived-mode-p 'special-mode)))
+                ;; buffer-size 0 happens for package like nov.el It
+                ;; erases the buffer (size 0) and renders a new page in
+                ;; the same buffer.  In this case, buffer is writable.
+        ;; Removing the notes here is meant to be automatically remove
+        ;; notes when you delete a region that contains a higlight
+        ;; overlay.
+
+        ;; TODO Relying on the current major mode being derived from
+        ;; special-mode is not the best.
         (org-remark-notes-remove (overlay-get ov 'org-remark-id)))
       (delete-overlay ov))
     (unless (overlay-buffer ov)



reply via email to

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