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

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

[nongnu] elpa/annotate de990d8adf 348/372: - added command to delete an


From: ELPA Syncer
Subject: [nongnu] elpa/annotate de990d8adf 348/372: - added command to delete an annotation under point;
Date: Fri, 4 Feb 2022 16:59:21 -0500 (EST)

branch: elpa/annotate
commit de990d8adfe50aa4ffc5da11c9a59c54906bf88e
Author: cage <cage@localhost>
Commit: cage <cage@invalid>

    - added command to delete an annotation under point;
    
    - refactored some code in a function.
---
 annotate.el | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/annotate.el b/annotate.el
index c47cda10ab..6fd50769b7 100644
--- a/annotate.el
+++ b/annotate.el
@@ -73,6 +73,8 @@ See https://github.com/bastibe/annotate.el/ for 
documentation."
 
 (define-key annotate-mode-map (kbd "C-c C-a") 'annotate-annotate)
 
+(define-key annotate-mode-map (kbd "C-c C-d") 'annotate-delete-annotation)
+
 (define-key annotate-mode-map (kbd "C-c C-s") 
'annotate-show-annotation-summary)
 
 (define-key annotate-mode-map (kbd "C-c ]") 'annotate-goto-next-annotation)
@@ -2074,15 +2076,22 @@ from a chain where `annotation' belong."
        (t
         (move-overlay last-annotation last-annotation-starting-pos 
new-ending-pos))))))
 
+(defun annotate--delete-annotation-prevent-modification (annotation)
+  (annotate-ensure-annotation (annotation)
+    (annotate-with-restore-modified-bit
+     (annotate--delete-annotation-chain annotation))))
+
+(cl-defun annotate-delete-annotation (&optional (point (point)))
+  (interactive)
+  (when-let ((annotation (annotate-annotation-at point)))
+    (annotate--delete-annotation-prevent-modification annotation)))
+
 (defun annotate-change-annotation (pos)
   "Change annotation at point. If empty, delete annotation."
   (let* ((highlight       (annotate-annotation-at pos))
          (annotation-text (read-from-minibuffer annotate-annotation-prompt
                                                 (overlay-get highlight 
'annotation))))
-    (cl-labels ((delete (annotation)
-                  (annotate-with-restore-modified-bit
-                    (annotate--delete-annotation-chain annotation)))
-                (change (annotation)
+    (cl-labels ((change (annotation)
                   (let ((chain (annotate-find-chain annotation)))
                     (dolist (single-element chain)
                       (annotate-overlay-maybe-set-help-echo single-element 
annotation-text)
@@ -2093,7 +2102,7 @@ from a chain where `annotation' belong."
          ((null annotation-text))
          ;; annotation was erased:
          ((string= "" annotation-text)
-          (delete highlight))
+          (annotate--delete-annotation-prevent-modification highlight))
          ;; annotation was changed:
          (t
           (change highlight)))))))



reply via email to

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