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

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

[nongnu] elpa/annotate e7ca823566 201/372: Merge branch 'master' into or


From: ELPA Syncer
Subject: [nongnu] elpa/annotate e7ca823566 201/372: Merge branch 'master' into org-mode-fix
Date: Fri, 4 Feb 2022 16:58:59 -0500 (EST)

branch: elpa/annotate
commit e7ca82356693aa4d5aa89be078ef2ba00f9c3ed1
Merge: f4cc83ec84 30ee7a0b87
Author: cage <cage-invalid@invalid>
Commit: cage <cage-invalid@invalid>

    Merge branch 'master' into org-mode-fix
---
 Changelog   | 20 +++++++++----
 NEWS.org    | 10 ++++++-
 README.org  |  3 ++
 annotate.el | 97 ++++++++++++++++++++++++++++---------------------------------
 4 files changed, 72 insertions(+), 58 deletions(-)

diff --git a/Changelog b/Changelog
index ea6cf0d576..3387054310 100644
--- a/Changelog
+++ b/Changelog
@@ -20,8 +20,18 @@
 
         * annotate.el (annotate--font-lock-matcher):
         - fixed error for regexp search
-         Sometimes some modes/package puts overlay on the last character of a
-         buffer (notably SLIME when the parenthesis of a form are not
-          balanced). This will make 're-search-forward' in the aforementioned
-          function fails and font lock becomes a mess (e.g. text color
-          disappears).
+       Sometimes some modes/package puts overlay on the last character of a
+       buffer (notably SLIME when the parenthesis of a form are not
+        balanced). This will make 're-search-forward' in the aforementioned
+        function fails and font lock becomes a mess (e.g. text color
+        disappears).
+
+2020-02-10 Bastian Bechtold, cage
+       * annotate.el (annotate--font-lock-matcher annotate-bounds 
nnotate-symbol-strictly-at-point annotate-next-annotation-change 
annotate-previous-annotation-change annotate-clear-annotations 
annotate-annotate)
+       - prevented fails of fontification of annotated regions
+       As we walk across the overlays we can get past the limit;
+       - mark buffer as modified even if the only action the user performed
+       was clearing annotation (and at least an annotation was present in
+       the file)
+       - prevented annotation of text marked with a region that overlap with
+       an existing annotation.
diff --git a/NEWS.org b/NEWS.org
index 7eae103732..3989548d16 100644
--- a/NEWS.org
+++ b/NEWS.org
@@ -86,7 +86,15 @@
   - fixed bug that prevented correct fontifications for major modes
     that puts overlays on the buffer's text (e.g. SLIME).
 
-- 2020-01-25 V0.5.2 Bastian Bechtold, cage ::
+- 2020-02-10 V0.5.2 Bastian Bechtold, cage ::
+
+  - fixed bugs that makes some annotations overlaps;
+  - fixed some bugs in fontifications of multiline annotation;
+  - when the only user interactions, before saving, with a visited file was
+    the call of 'annotate-clear-annotations' the annotations
+    will shows again at reload, this should be fixed now.
+
+- 2020-02-18 V0.5.3 Bastian Bechtold, cage ::
   - fixed bug that prevented annotation of buffer when org-mode was used;
   - when an user delete an annotation for a file using a button from
     summary window force refresh of a buffer that is visiting said
diff --git a/README.org b/README.org
index 4439f50aa1..1345d344d8 100644
--- a/README.org
+++ b/README.org
@@ -114,6 +114,9 @@ as comments into the current buffer, like this:
    incompatibility with the way source blocks are highlighted and the
    way annotations are displayed.
 
+   Annotating a region that contains newline(s) can results in various
+   issues.
+
    Deleting the first  character of an annotated text  will remove the
    annotation (this turned out to be useful, though).
 
diff --git a/annotate.el b/annotate.el
index 1d4e9c311e..fe7219df43 100644
--- a/annotate.el
+++ b/annotate.el
@@ -1454,56 +1454,49 @@ 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
-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))))))
+(defun annotate-annotation-at (pos)
+  "Returns the annotations (overlay where (annotationp overlay) -> t)
+at positions pos or nil if no annotations exists at pos.
+
+NOTE this assumes that annotations never overlaps so the list of
+all annotations can contains only one element maximum."
+  (let ((all (cl-remove-if-not #'annotationp
+                               (overlays-at pos))))
+    (cl-first all)))
+
+(defun annotate-previous-annotation-ends (pos)
+  "Returns 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 ((annotation (annotate-annotation-at start)))
+                  (while (and (>= (1- start)
+                                  (point-min))
+                              (null annotation))
+                    (setf start (1- start))
+                    (setf annotation (annotate-annotation-at (1- start))))
+                  annotation)))
+    (let ((annotation (annotate-annotation-at pos)))
+      (if annotation
+          (previous-annotation-ends (1- (overlay-start annotation)))
+        (previous-annotation-ends pos)))))
+
+(defun annotate-next-annotation-starts (pos)
+  "Returns 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-ends (start)
+                (let ((annotation (annotate-annotation-at start)))
+                  (while (and (<= (1+ start)
+                                  (point-max))
+                              (null annotation))
+                    (setf start (1+ start))
+                    (setf annotation (annotate-annotation-at (1+ start))))
+                  annotation)))
+    (let ((annotation (annotate-annotation-at pos)))
+      (if annotation
+          (next-annotation-ends (overlay-end annotation))
+        (next-annotation-ends pos)))))
 
 (defun annotate-symbol-strictly-at-point ()
  "Return non nil if a symbol is at char immediately following
@@ -1528,7 +1521,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
@@ -1547,7 +1540,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



reply via email to

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