[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/annotate 24de0e4607 190/372: - renamed and fixed function
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/annotate 24de0e4607 190/372: - renamed and fixed function to search for annotations relative to a |
Date: |
Fri, 4 Feb 2022 16:58:58 -0500 (EST) |
branch: elpa/annotate
commit 24de0e46070f4e33c5c148ed79a7aa1f35527cfb
Author: cage <cage-invalid@invalid>
Commit: cage <cage-invalid@invalid>
- renamed and fixed function to search for annotations relative to a
position.
---
annotate.el | 101 ++++++++++++++++++++++++++++++------------------------------
1 file changed, 50 insertions(+), 51 deletions(-)
diff --git a/annotate.el b/annotate.el
index 10b1bbd3ab..3ecd88ed5e 100644
--- a/annotate.el
+++ b/annotate.el
@@ -1410,56 +1410,55 @@ The searched interval can be customized setting the
variable:
(concat " \n" (make-string annotate-annotation-column ? ))
(make-string prefix-length ? )))))
-(defun annotate-previous-annotation-change (point)
- "Return the previous annotation before point or nil if no annotation
+(defun annotate-annotations-at (pos)
+ (cl-remove-if-not #'annotationp
+ (overlays-at pos)))
+
+(defun annotate-previous-annotation-ends (pos)
+ "Return the previous annotation that ends before pos or nil if no annotation
+was found.
+NOTE this assumes that annotations never overlaps"
+ (cl-labels ((previous-annotation-ends (start)
+ (let ((all-annotations (annotate-annotations-at start)))
+ (if all-annotations
+ (cl-first all-annotations)
+ (if (> (1- start)
+ (point-min))
+ (previous-annotation-ends (1- start))
+ nil)))))
+ (let ((all-annotations (annotate-annotations-at pos)))
+ (if all-annotations
+ (annotate-previous-annotation-ends (1- (overlay-start (cl-first
all-annotations))))
+ (previous-annotation-ends pos)))))
+
+(defun annotate-next-annotation-starts (pos)
+ "Return the previous annotation that ends before pos or nil if no annotation
+was found.
+NOTE this assumes that annotations never overlaps"
+ (cl-labels ((next-annotation-starts (start)
+ (let ((all-annotations (annotate-annotations-at start)))
+ (if all-annotations
+ (cl-first all-annotations)
+ (if (> (1+ start)
+ (point-max))
+ (previous-annotation-ends (1+ start))
+ nil)))))
+ (let ((all-annotations (annotate-annotations-at pos)))
+ (if all-annotations
+ (annotate-previous-annotation-starts (overlay-ends (cl-first
all-annotations)))
+ (previous-annotation-ends pos)))))
+
+(defun annotate-next-annotation-starts (point)
+ "Return the previous annotation that starts after point or nil if no
annotation
was found"
- (let* ((overlay-pos (previous-overlay-change point))
- (all-overlays (overlays-at (1- overlay-pos)))
- (sorted-overlays (sort all-overlays
- (lambda (a b)
- (> (overlay-end a)
- (overlay-end b)))))
- ;; TODO checks if is correct that could contains 0 or 1 annotation
- (annotations (cl-remove-if-not #'annotationp
- all-overlays))
- (overlay-most-right-end (and sorted-overlays
- (overlay-end (cl-first
sorted-overlays))))
- (first-overlay (and sorted-overlays
- (cl-first sorted-overlays))))
- (cond
- (annotations
- (cl-first annotations))
- ((= (point-min)
- overlay-pos)
- nil)
- (first-overlay
- (annotate-previous-annotation-change (1- (overlay-start
first-overlay)))))))
-
-(defun annotate-next-annotation-change (point)
- "Return the next annotation after point or nil if no annotation
-was found"
- (let* ((overlay-pos (next-overlay-change point))
- (all-overlays (overlays-at overlay-pos))
- ;; TODO checks if is correct that could contains 0 or 1 annotation
- (sorted-overlays (sort all-overlays
- (lambda (a b)
- (< (overlay-start a)
- (overlay-start b)))))
- (annotations (cl-remove-if-not #'annotationp
- all-overlays))
- (overlay-most-left-end (and sorted-overlays
- (overlay-end (cl-first sorted-overlays))))
-
- (first-overlay (and sorted-overlays
- (cl-first sorted-overlays))))
- (cond
- (annotations
- (cl-first annotations))
- ((= (point-max)
- overlay-pos)
- nil)
- (first-overlay
- (annotate-previous-annotation-change (overlay-end first-overlay))))))
+ ;; NOTE this assumes that annotations never overlaps
+ (let ((all-annotations (annotate-annotations-at point)))
+ (if all-annotations
+ (annotate-next-annotation-starts (overlay-end (cl-first
all-annotations)))
+ (let* ((overlay-pos (next-overlay-change point))
+ (all-annotations-at-pos (annotate-annotations-at overlay-pos))
+ (annotation (cl-first all-annotations-at-pos)))
+ annotation))))
(defun annotate-symbol-strictly-at-point ()
"Return non nil if a symbol is at char immediately following
@@ -1484,7 +1483,7 @@ was found"
((use-region-p)
(region-beginning))
((annotate-symbol-strictly-at-point)
- (let* ((annotation-before
(annotate-previous-annotation-change (point)))
+ (let* ((annotation-before (annotate-previous-annotation-ends
(point)))
(boundaries (bounds-of-thing-at-point 'symbol))
(symbol-start (car boundaries))
(annotation-end (if annotation-before
@@ -1503,7 +1502,7 @@ was found"
(1- (region-end))
(region-end)))
((annotate-symbol-strictly-at-point)
- (let* ((annotation-after (annotate-next-annotation-change
(point)))
+ (let* ((annotation-after (annotate-next-annotation-starts
(point)))
(boundaries (bounds-of-thing-at-point 'symbol))
(symbol-end (cdr boundaries))
(annotation-start (if annotation-after
- [nongnu] elpa/annotate 6239d033ce 355/372: - updated README.org mentioning 'annotate-y-or-n-prompt-function'., (continued)
- [nongnu] elpa/annotate 6239d033ce 355/372: - updated README.org mentioning 'annotate-y-or-n-prompt-function'., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 04a5710cf6 334/372: - prevented saving a file whith an empty database;, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 2e7c18b12a 337/372: - fixed callback for "[replace]" button in summary window, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 6b73ccf009 352/372: - fixed function's name., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 4c3ba3a5da 331/372: - prevented calling 'annotate--remove-annotation-property' on a narrowed buffer, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 3b0bc40a4f 347/372: - improved docstrings;, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 46aa377cfc 370/372: - upgraded version number;, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 0cfad246ee 372/372: Merge pull request #120 from cage2/add-merge-db, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 401a9b4990 309/372: - removed useless argument for 'font-lock-flush'., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate ed0c9bc64b 184/372: - prevented annotation of text marked with a region that overlap with, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 24de0e4607 190/372: - renamed and fixed function to search for annotations relative to a,
ELPA Syncer <=
- [nongnu] elpa/annotate e6fb2b31df 188/372: - fixed position to start for overlay checks in, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate a81a7d9386 209/372: - updated versions;, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 30ee7a0b87 198/372: - fixed 'annotate-previous-annotation-ends' and 'annotate-next-annotation-ends', ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 1143087515 213/372: - updated documentation., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate b8fd76f712 216/372: Merge pull request #60 from cage2/rethink-multiline-annotations, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate a37ec08035 249/372: - added signalling of error to 'annotate-switch-db';, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 34f0df8d5b 251/372: - updated documentation., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate bc89867f65 289/372: Merge pull request #92 from cage2/expand-db-path, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate be998ca006 263/372: Merge pull request #81 from cage2/popup-annotation, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 804c7b9421 257/372: - Removed internal link because of issue #79., ELPA Syncer, 2022/02/04