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

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

[elpa] externals/org-remark 41b0997c3f 151/173: fix: remove/delete remov


From: ELPA Syncer
Subject: [elpa] externals/org-remark 41b0997c3f 151/173: fix: remove/delete remove only one highlihgt at a time
Date: Fri, 28 Jan 2022 16:58:10 -0500 (EST)

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

    fix: remove/delete remove only one highlihgt at a time
    
    It was removing all higlights at point. The program issue was it removed 
only
    one from the marginal notes, causing inconsistency.
    
    It should be only one at a time, especially when delete is used.
---
 NEWS          |  5 ++++-
 org-remark.el | 27 +++++++++++++++++----------
 2 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/NEWS b/NEWS
index c3aa1201a0..c285823547 100644
--- a/NEWS
+++ b/NEWS
@@ -26,8 +26,11 @@
 
 * Changes
 
+  - chg: `remove' (and delete) only removes one highlight at a time instead of
+         remove all at point
+
   - chg: Save marginal notes on `mark' instead of wainting for `save'
-  
+
   - chg: define org-remark-mark explicitly for autoload cookie
 
   - chg: `org-remark-visit' and `org-remark-open'. Visit will stay in the
diff --git a/org-remark.el b/org-remark.el
index d706491d16..d1a154c580 100644
--- a/org-remark.el
+++ b/org-remark.el
@@ -28,7 +28,7 @@
 ;;; Commentary:
 
 ;; This package lets you highlight and annotate any text file with using Org
-;; mode.  Refer to README.org and docstring for detail.
+;; mode.
 
 ;;; Code:
 
@@ -499,18 +499,25 @@ If you have done so by error, you could still `undo' it 
in the
 marginal notes buffer, but not in the current buffer as adding
 and removing overlays are not part of the undo tree."
   (interactive "d\nP")
-  ;; TODO There may be multiple overlays
   (when-let* ((id (get-char-property point 'org-remark-id)))
     ;; Remove the highlight overlay and id
-    (dolist (ov (overlays-at (point)))
-      ;; Remove the element in the variable org-remark-highlights
-      (when (overlay-get ov 'org-remark-id)
-        (delete ov org-remark-highlights)
-        (delete-overlay ov)))
+    ;; Where there is more than one, remove only one
+    ;; It should be last-in-first-out
+    (let ((deleted)
+          ;; reverse the order so that pop returns the last one
+          ;; for last-in-first-out
+          (ovs (reverse (overlays-at (point)))))
+      (while (not deleted)
+        (let ((ov (pop ovs)))
+          ;; Remove the element in the variable org-remark-highlights
+          (when (overlay-get ov 'org-remark-id)
+            (delete ov org-remark-highlights)
+            (delete-overlay ov)
+            ;; Update the notes file accordingly
+            (org-remark-single-highlight-remove id delete)
+            (setq deleted t)))))
     (org-remark-housekeep)
     (org-remark-highlights-sort)
-    ;; Update the notes file accordingly
-    (org-remark-single-highlight-remove id delete)
     t))
 
 
@@ -786,6 +793,7 @@ Each highlight is a list in the following structure:
   (when-let ((notes-buf (find-file-noselect org-remark-notes-file-path))
              (source-path (org-remark-source-path (buffer-file-name))))
     ;; TODO check if there is any relevant notes for the current file
+    ;; This can be used for adding icon to the highlight
     (let ((highlights))
       (with-current-buffer notes-buf
         (when (featurep 'org-remark-convert-legacy)
@@ -898,7 +906,6 @@ the show/hide state."
   (when-let ((highlights org-remark-highlights))
     (dolist (highlight highlights)
       (overlay-put highlight 'org-remark-hidden nil)
-      ;; TODO it does not work with new pens
       (overlay-put highlight 'face (overlay-get highlight 'org-remark-face)))
     t))
 



reply via email to

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