[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/annotate b180248ddc 113/372: - fixed bug with multiline an
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/annotate b180248ddc 113/372: - fixed bug with multiline annotation |
Date: |
Fri, 4 Feb 2022 16:58:23 -0500 (EST) |
branch: elpa/annotate
commit b180248ddc613b7f49b74e72d39c422be94842dd
Author: cage <cage-invalid@invalid>
Commit: cage <cage-invalid@invalid>
- fixed bug with multiline annotation
when the user annotated some text placed before (but on the same
line) an already annotated multiline region the latter annotation
was displayed twice, This patch mitigate this issue.
---
annotate.el | 118 +++++++++++++++++++++++++++++++++++-------------------------
1 file changed, 69 insertions(+), 49 deletions(-)
diff --git a/annotate.el b/annotate.el
index 3d5ea60ae1..1c7cf94af7 100644
--- a/annotate.el
+++ b/annotate.el
@@ -254,13 +254,16 @@ modified (for example a newline is inserted)."
"Create, modify, or delete annotation."
(interactive)
(let ((overlay (car (overlays-at (point)))))
- (cond ((and (overlayp overlay) (overlay-get overlay 'annotation))
- (annotate-change-annotation (point)))
- (t
- (cl-destructuring-bind (start end) (annotate-bounds)
- (annotate-create-annotation start end)))))
- (font-lock-fontify-block 1)
- (set-buffer-modified-p t))
+ (cond
+ ((and (overlayp overlay)
+ (overlay-get overlay 'annotation))
+ (annotate-change-annotation (point))
+ (font-lock-fontify-buffer nil))
+ (t
+ (cl-destructuring-bind (start end) (annotate-bounds)
+ (annotate-create-annotation start end)
+ (font-lock-fontify-block 1))))
+ (set-buffer-modified-p t)))
(defun annotate-next-annotation ()
"Move point to the next annotation."
@@ -710,48 +713,65 @@ to 'maximum-width'."
"Searches the line before point for annotations, and returns a
`facespec` with the annotation in its `display` property."
(save-excursion
- (goto-char (1- (point))) ; we start at the start of the next line
- ;; find overlays in the preceding line
- (let ((prefix (annotate-make-prefix)) ; white spaces before
first annotation
- (bol (progn (beginning-of-line) (point)))
- (eol (progn (end-of-line) (point)))
- (text "")
- (overlays nil)
- (annotation-counter 1))
- ;; include previous line if point is at bol:
- (when (eq nil (overlays-in bol eol))
- (setq bol (1- bol)))
- (setq overlays
- (sort (cl-remove-if-not 'annotationp (overlays-in bol eol))
- (lambda (x y)
- (< (overlay-end x) (overlay-end y)))))
- ;; put each annotation on its own line
- (dolist (ov overlays)
- (cl-incf annotation-counter)
- (let ((face (if (= (cl-rem annotation-counter 2) 0)
- 'annotate-annotation
- 'annotate-annotation-secondary))
- (face-highlight (if (= (cl-rem annotation-counter 2) 0)
- 'annotate-highlight
- 'annotate-highlight-secondary)))
- (overlay-put ov 'face face-highlight)
- (dolist (l (save-match-data
- (split-string (annotate-lineate (overlay-get ov
'annotation)
- (- eol bol))
- "\n")))
- (setq text
- (concat text
- prefix
- (propertize l 'face face)
- "\n"))
- ;; white space before for all but the first annotation line
- (setq prefix (make-string annotate-annotation-column ? )))))
- ;; build facespec with the annotation text as display property
- (if (string= text "")
- ;; annotation has been removed: remove display prop
- (list 'face 'default 'display nil)
- ;; annotation has been changed/added: change/add display prop
- (list 'face 'default 'display text)))))
+ (let ((newline-position (point)))
+ (goto-char (1- (point))) ; we start at the start of the previous line
+ ;; find overlays in the preceding line
+ (let ((prefix (annotate-make-prefix)) ; white spaces before
first annotation
+ (bol (progn (beginning-of-line) (point)))
+ (eol (progn (end-of-line) (point)))
+ (text "")
+ (overlays nil)
+ (annotation-counter 1))
+ ;; include previous line if point is at bol:
+ (when (eq nil (overlays-in bol eol))
+ (setq bol (1- bol)))
+ (setq overlays
+ (sort (cl-remove-if (lambda (a) (or (not (annotationp a))
+ ;; if an annotated
+ ;; text contains a
+ ;; newline (is a
+ ;; multiline one) do
+ ;; not add
+ ;; annotation for it
+ ;; here (i.e. remove
+ ;; from that list),
+ ;; this annotation
+ ;; will be shown on
+ ;; the next newline
+ ;; instead
+ (<= (overlay-start a)
+ newline-position
+ (overlay-end a))))
+ (overlays-in bol eol))
+ (lambda (x y)
+ (< (overlay-end x) (overlay-end y)))))
+ ;; put each annotation on its own line
+ (dolist (ov overlays)
+ (cl-incf annotation-counter)
+ (let ((face (if (= (cl-rem annotation-counter 2) 0)
+ 'annotate-annotation
+ 'annotate-annotation-secondary))
+ (face-highlight (if (= (cl-rem annotation-counter 2) 0)
+ 'annotate-highlight
+ 'annotate-highlight-secondary)))
+ (overlay-put ov 'face face-highlight)
+ (dolist (l (save-match-data
+ (split-string (annotate-lineate (overlay-get ov
'annotation)
+ (- eol bol))
+ "\n")))
+ (setq text
+ (concat text
+ prefix
+ (propertize l 'face face)
+ "\n"))
+ ;; white space before for all but the first annotation line
+ (setq prefix (make-string annotate-annotation-column ? )))))
+ ;; build facespec with the annotation text as display property
+ (if (string= text "")
+ ;; annotation has been removed: remove display prop
+ (list 'face 'default 'display nil)
+ ;; annotation has been changed/added: change/add display prop
+ (list 'face 'default 'display text))))))
(defun annotate--remove-annotation-property (begin end)
"Cleans up annotation properties associated with a region."
- [nongnu] elpa/annotate e1cafc819b 101/372: - removed newlines in snippet text;, (continued)
- [nongnu] elpa/annotate e1cafc819b 101/372: - removed newlines in snippet text;, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 74699a2a70 102/372: - making loading multiple time this mode with no effect on the buffer, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate d60feb9cab 106/372: Merge pull request #45 from cage2/master, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate c5ecb3649b 127/372: - removed useless quotation mark., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate db489ad5c0 111/372: - changed secondary color., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 4f9c5f6d67 125/372: - added a warning when searching for a annotated text fails., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 01373a4420 104/372: - preventing loss of undo list, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 3108c44c53 123/372: - moving some args checks from 'annotate-create-annotation' to, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 1c64e46ad0 109/372: - changed variable name, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate d46d5afd34 122/372: - made two arguments of annotate-create-annotation non optional;, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate b180248ddc 113/372: - fixed bug with multiline annotation,
ELPA Syncer <=
- [nongnu] elpa/annotate 14ef3fb140 126/372: - fixed docstring., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate bae16321fc 117/372: - using a customizable variable for region where to look for annotated, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 7ff18171a6 112/372: - fixed typos., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 7ebddc73a0 144/372: - enabled filtering of annotation database when a summary window is shown., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 50ba1d719c 143/372: - used a better regex when checking if a file is in info format., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 50bc634f6b 140/372: - placed the cursor in the right place (on the annotated text) when an, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 1f9899071f 138/372: - made recongnizable code that refers to info file annotation. (3/3), ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 4629a0ad34 148/372: Merge pull request #51 from cage2/filter-summary-window-results, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 4372e9ea20 147/372: - changed escaping mechanism;, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 6948bfe686 146/372: - minor fix in comments., ELPA Syncer, 2022/02/04