[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/annotate 6c33ac48d0 003/372: annotate without region
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/annotate 6c33ac48d0 003/372: annotate without region |
Date: |
Fri, 4 Feb 2022 16:58:14 -0500 (EST) |
branch: elpa/annotate
commit 6c33ac48d006057826692ffdf45ca351c5b497d8
Author: Bastian Bechtold <basti@bastibe.de>
Commit: Bastian Bechtold <basti@bastibe.de>
annotate without region
the annotation region is chosen to be
- the region, if available
- the thing-at-point (symbol), if possible
- the current character
---
annotate.el | 32 ++++++++++++++++++++++----------
1 file changed, 22 insertions(+), 10 deletions(-)
diff --git a/annotate.el b/annotate.el
index 2270512319..44e3bcbe39 100644
--- a/annotate.el
+++ b/annotate.el
@@ -23,17 +23,18 @@
:type 'number
:group 'annotate)
-(defun annotate-create-annotation (start end &optional arg)
+(defun annotate-create-annotation ()
"Create a new annotation for selected region."
- (interactive "r")
- (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")))))
+ (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"))))))
(defun annotate-line-length ()
"The length of the line from beginning to end."
@@ -42,3 +43,14 @@
(let ((eol (point)))
(move-beginning-of-line nil)
(- eol (point)))))
+
+(defun annotate-bounds ()
+ "The bounds of the region or whatever is at point."
+ (list (cond
+ ((region-active-p) (region-beginning))
+ ((thing-at-point 'symbol) (car (bounds-of-thing-at-point 'symbol)))
+ (t (point)))
+ (cond
+ ((region-active-p) (region-end))
+ ((thing-at-point 'symbol) (cdr (bounds-of-thing-at-point 'symbol)))
+ (t (1+ (point))))))
- [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, 2022/02/04
- [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 <=
- [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
- [nongnu] elpa/annotate 530b4aa78a 022/372: increment version number, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate f2bcc95e8b 024/372: add melpa links, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate a6f7279a4c 016/372: fixed typos and version error, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 0bd3bdce01 017/372: improved README, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate ffac176c22 021/372: fix upside-down annotation construction, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 936f081575 005/372: doesn't create empty annotations any more, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate fc2c0395d7 007/372: add missing require, ELPA Syncer, 2022/02/04