[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/annotate cecb77fecc 004/372: can now edit and delete annot
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/annotate cecb77fecc 004/372: can now edit and delete annotations |
Date: |
Fri, 4 Feb 2022 16:58:14 -0500 (EST) |
branch: elpa/annotate
commit cecb77fecc51b848d88a078ffc2a6f8db5eb93ed
Author: Bastian Bechtold <basti@bastibe.de>
Commit: Bastian Bechtold <basti@bastibe.de>
can now edit and delete annotations
---
annotate.el | 50 +++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 39 insertions(+), 11 deletions(-)
diff --git a/annotate.el b/annotate.el
index 44e3bcbe39..9fcca73634 100644
--- a/annotate.el
+++ b/annotate.el
@@ -23,18 +23,46 @@
:type 'number
:group 'annotate)
-(defun annotate-create-annotation ()
- "Create a new annotation for selected region."
+(defun annotate-annotate ()
+ "Create, modify, or delete annotation."
(interactive)
- (destructuring-bind (start end) (annotate-bounds)
- (let ((overlay-highlight (make-overlay start end))
- (annotation (read-from-minibuffer "Annotation: "))
- (prefix (make-string (- annotate-annotation-column
(annotate-line-length)) ? )))
- (overlay-put overlay-highlight 'face annotate-highlight-face)
- (setq annotation (propertize annotation 'face annotate-annotation-face))
- (save-excursion
- (move-end-of-line nil)
- (put-text-property (point) (1+ (point)) 'display (concat prefix
annotation "\n"))))))
+ (let ((overlay (car (overlays-at (point)))))
+ (message "%s" (overlayp overlay))
+ (cond ((and (overlayp overlay) (overlay-get overlay 'annotation))
+ (annotate-change-annotation (point)))
+ (t
+ (destructuring-bind (start end) (annotate-bounds)
+ (annotate-create-annotation start end))))))
+
+(defun annotate-create-annotation (start end)
+ "Create a new annotation for selected region."
+ (interactive "r")
+ (let ((highlight (make-overlay start end))
+ (annotation (read-from-minibuffer "Annotation: "))
+ (prefix (make-string (- annotate-annotation-column
(annotate-line-length)) ? )))
+ (overlay-put highlight 'face annotate-highlight-face)
+ (overlay-put highlight 'annotation annotation)
+ (setq annotation (propertize annotation 'face annotate-annotation-face))
+ (save-excursion
+ (move-end-of-line nil)
+ (put-text-property (point) (1+ (point)) 'display (concat prefix
annotation "\n")))))
+
+(defun annotate-change-annotation (pos)
+ "Change annotation at point. If empty, delete annotation."
+ (interactive "d")
+ (let* ((highlight (car (overlays-at pos)))
+ (annotation (read-from-minibuffer "Annotation: " (overlay-get
highlight 'annotation)))
+ (prefix (make-string (- annotate-annotation-column
(annotate-line-length)) ? )))
+ (save-excursion
+ (move-end-of-line nil)
+ (cond
+ ((string= "" annotation)
+ (delete-overlay highlight)
+ (remove-text-properties (point) (1+ (point)) '(display nil)))
+ (t
+ (overlay-put highlight 'annotation annotation)
+ (setq annotation (propertize annotation 'face
annotate-annotation-face))
+ (put-text-property (point) (1+ (point)) 'display (concat prefix
annotation "\n")))))))
(defun annotate-line-length ()
"The length of the line from beginning to end."
- [nongnu] branch elpa/annotate created (now 0cfad246ee), ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate cecb77fecc 004/372: can now edit and delete annotations,
ELPA Syncer <=
- [nongnu] elpa/annotate d7246d5220 006/372: implemented annotation saving, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate a648cd44df 010/372: make auxiliary functions non-interactive, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate f6780672bc 011/372: fix change annotation function, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate f6203f0d40 012/372: improved default column, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 526ced3131 013/372: create minor mode, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 7531343d7b 001/372: initial prototype, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 6c33ac48d0 003/372: annotate without region, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 32d82c4557 018/372: no more nil annotations, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate aa075cfe04 002/372: change annotation display from overlay to property, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 94c2a9455f 019/372: increment version number, ELPA Syncer, 2022/02/04