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

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

[nongnu] elpa/annotate da5f3dcfe8 2/6: - prevented using the same color


From: ELPA Syncer
Subject: [nongnu] elpa/annotate da5f3dcfe8 2/6: - prevented using the same color on adjacent annotations;
Date: Sat, 30 Sep 2023 12:59:45 -0400 (EDT)

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

    - prevented using the same color on adjacent annotations;
    
      To     reproduce     the     issue    (assuming     the     variable
      'annotate-highlight-faces' is bound to a list of two elements):
    
      1. annotate the first line of a buffer (C-a)
      2. annotate the second line of the same buffer (C-a)
      3. delete the annotation on the second line (C-d)
      4. annotate again the second line (C-a)
    
      the annotations in both lines got the same colors.
---
 annotate.el | 35 ++++++++++++++++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)

diff --git a/annotate.el b/annotate.el
index 22ac54286b..e28bc2b932 100644
--- a/annotate.el
+++ b/annotate.el
@@ -433,6 +433,22 @@ annotated text?
 See: `ANNOTATE-ANNOTATION-POSITION-POLICY'."
   (overlay-get annotation 'force-newline-policy))
 
+(defun annotate-annotation-set-face (annotation face)
+  "Set property face to `FACE' for `ANNOTATION'."
+  (overlay-put annotation 'face face))
+
+(defun annotate-annotation-face (annotation)
+  "Get property face from `ANNOTATION'."
+  (overlay-get annotation 'face))
+
+(defun annotate-annotation-set-annotation-face (annotation face)
+  "Set property annotation-face to `FACE' for `ANNOTATION'."
+  (overlay-put annotation 'annotation-face face))
+
+(defun annotate-annotation-property-annotation-face (annotation)
+  "Get property annotation-face from `ANNOTATION'."
+  (overlay-get annotation 'annotation-face))
+
 (defun annotate-chain-last-ring (chain)
   "Get the last ring of `CHAIN'."
   (car (last chain)))
@@ -2095,7 +2111,24 @@ interval and, if found, the buffer is annotated right 
there.
 
 The searched interval can be customized setting the variable:
 'annotate-search-region-lines-delta'."
-  (cl-labels ((create-annotation (start end annotation-text)
+  (cl-labels ((face-index-annotation-shifting-point (position 
shifting-direction-function)
+                (when-let* ((annotation       (funcall 
shifting-direction-function
+                                                       position))
+                            (annotation-face  (annotate-annotation-face 
annotation)))
+                  (cl-position-if (lambda (a) (cl-equalp annotation-face a))
+                                  annotate-highlight-faces)))
+              (face-index-annotation-before-point (position)
+                (face-index-annotation-shifting-point position
+                                                      
#'annotate-previous-annotation-ends))
+              (face-index-annotation-after-point (position)
+                (face-index-annotation-shifting-point position
+                                                      
#'annotate-next-annotation-starts))
+              (create-annotation (start end annotation-text)
+                (when (null color-index)
+                  (when-let ((used-face-index (or 
(face-index-annotation-before-point (point))
+                                                  
(face-index-annotation-after-point (point)))))
+                    (setf annotate-colors-index-counter
+                          used-face-index)))
                (cl-incf annotate-colors-index-counter)
                (save-excursion
                  (let ((all-overlays ()))



reply via email to

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