[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/annotate 54d112e8d3 174/372: [bugfix] mitigated bug that p
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/annotate 54d112e8d3 174/372: [bugfix] mitigated bug that prevented rendering of annotation when |
Date: |
Fri, 4 Feb 2022 16:58:56 -0500 (EST) |
branch: elpa/annotate
commit 54d112e8d37bd4f62ee34db96265c16f2006e0e1
Author: cage <cage-invalid@invalid>
Commit: cage <cage-invalid@invalid>
[bugfix] mitigated bug that prevented rendering of annotation when
ORG major mode is used.
---
annotate.el | 117 +++++++++++++++++++++++++++++++++++++++++-------------------
1 file changed, 80 insertions(+), 37 deletions(-)
diff --git a/annotate.el b/annotate.el
index 535110bcd6..dd0e7efb60 100644
--- a/annotate.el
+++ b/annotate.el
@@ -89,15 +89,21 @@ See https://github.com/bastibe/annotate.el/ for
documentation."
:group 'annotate)
(defface annotate-annotation
- '((t (:background "coral" :foreground "black")))
+ '((t (:background "coral" :foreground "black" :inherit default)))
"Face for annotations."
:group 'annotate)
(defface annotate-annotation-secondary
- '((t (:background "khaki" :foreground "black")))
+ '((t (:background "khaki" :foreground "black" :inherit default)))
"Face for secondary annotations."
:group 'annotate)
+(defface annotate-prefix
+ '((t (:inherit default)))
+ "Face for character used to pad annotation (fill space between
+text lines and annotation text)."
+ :group 'annotate)
+
(defcustom annotate-annotation-column 85
"Where annotations appear."
:type 'number
@@ -279,6 +285,12 @@ position (so that it is unchanged after this function is
called)."
(= (overlay-start annotation)
(overlay-end annotation)))
+(defun annotate-annotation-force-newline-policy (annotation)
+ (overlay-put annotation 'force-newline-policy t))
+
+(defun annotate-annotation-newline-policy-forced-p (annotation)
+ (overlay-get annotation 'force-newline-policy))
+
(defun annotate-before-change-fn (a b)
"This function is added to 'before-change-functions' hook and
it is called any time the buffer content is changed (so, for
@@ -833,7 +845,8 @@ to 'maximum-width'."
(:new-line
t)
(:by-length
- annotation-long-p)
+ (or
(annotate-annotation-newline-policy-forced-p ov)
+ annotation-long-p))
(otherwise
nil)))
(multiline-annotation (if position-new-line-p
@@ -856,7 +869,7 @@ to 'maximum-width'."
(dolist (l multiline-annotation)
(setq annotation-text
(concat annotation-text
- prefix-first
+ (propertize prefix-first 'face 'annotate-prefix)
(propertize l 'face face)
annotation-stopper))
;; white space before for all but the first annotation line
@@ -1308,36 +1321,65 @@ 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)
- (let ((highlight (make-overlay start
end)))
- (overlay-put highlight 'face
'annotate-highlight)
- (overlay-put highlight 'annotation
annotation-text)))
- (beginning-of-nth-line (start line-count)
- (save-excursion
- (goto-char start)
- (forward-line line-count)
- (beginning-of-line)
- (point)))
- (go-backward (start)
- (beginning-of-nth-line
- start
- (- annotate-search-region-lines-delta)))
- (go-forward (start)
- (beginning-of-nth-line start
-
annotate-search-region-lines-delta))
- (guess-match-and-add (start end annotated-text max)
- (cl-block surrounding
- (while (< start max)
- (let ((to-match (ignore-errors
-
(buffer-substring-no-properties start
-
end))))
- (if (and to-match
- (string= to-match
annotated-text))
- (cl-return-from surrounding
start))
- (progn
- (setf start (1+ start)
- end (1+ end)))))
- nil)))
+ (let ((new-annotation nil))
+ (cl-labels ((create-annotation (start end annotation-text)
+ (let ((highlight (make-overlay start
end)))
+ (overlay-put highlight 'face
'annotate-highlight)
+ (overlay-put highlight 'annotation
annotation-text)
+ (setf new-annotation highlight)))
+ (beginning-of-nth-line (start line-count)
+ (save-excursion
+ (goto-char start)
+ (forward-line line-count)
+ (beginning-of-line)
+ (point)))
+ (go-backward (start)
+ (beginning-of-nth-line
+ start
+ (-
annotate-search-region-lines-delta)))
+ (go-forward (start)
+ (beginning-of-nth-line start
+
annotate-search-region-lines-delta))
+ (guess-match-and-add (start end annotated-text max)
+ (cl-block surrounding
+ (while (< start max)
+ (let ((to-match (ignore-errors
+
(buffer-substring-no-properties start
+
end))))
+ (if (and to-match
+ (string= to-match
annotated-text))
+ (cl-return-from surrounding
start))
+ (progn
+ (setf start (1+ start)
+ end (1+ end)))))
+ nil))
+ (maybe-force-newline-policy (annotation)
+ ;; force newline policy if height of any the face of
the
+ ;; overlay is different from height of default face
+ (save-excursion
+ (goto-char (overlay-start annotation))
+ (let* ((bol
(annotate-beginning-of-line-pos))
+ (eol (annotate-end-of-line-pos))
+ (changed-face-pos (min bol (overlay-start
annotation)))
+ (limit (max eol (overlay-end
annotation)))
+ (all-faces (list (get-text-property
changed-face-pos 'face)))
+ (default-face-height (face-attribute 'default
:height))
+ (all-faces-height ())
+ (force-newline-p nil))
+ (while (< changed-face-pos limit)
+ (setf changed-face-pos
+ (next-single-property-change changed-face-pos
'face (current-buffer) limit))
+ (push (get-text-property changed-face-pos 'face)
+ all-faces))
+ (setf all-faces-height
+ (mapcar (lambda (face)
+ (face-attribute face :height nil
'default))
+ (cl-remove-if #'null all-faces)))
+ (setf force-newline-p
+ (cl-find-if (lambda (a) (/= a
default-face-height))
+ all-faces-height))
+ (when force-newline-p
+ (annotate-annotation-force-newline-policy
annotation))))))
(if (not (annotate-string-empty-p annotated-text))
(let ((text-to-match (ignore-errors
(buffer-substring-no-properties start end))))
@@ -1356,18 +1398,19 @@ The searched interval can be customized setting the
variable:
(create-annotation new-match
(+ new-match length-match)
annotation-text)))
- (lwarn '(annotate-mode)
+ (lwarn '(annotate-mode) ; if matches annotated text failed
:warning
annotate-warn-file-searching-annotation-failed-control-string
(annotate-actual-file-name)
annotation-text
text-to-match)))
- (create-annotation start end annotation-text))
+ (create-annotation start end annotation-text)) ; create new annotation
(when (use-region-p)
(deactivate-mark))
(save-excursion
(goto-char end)
- (font-lock-fontify-block 1))))
+ (font-lock-fontify-block 1))
+ (maybe-force-newline-policy new-annotation))))
(defun annotate-change-annotation (pos)
"Change annotation at point. If empty, delete annotation."
- [nongnu] elpa/annotate 50bc634f6b 140/372: - placed the cursor in the right place (on the annotated text) when an, (continued)
- [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
- [nongnu] elpa/annotate b116d3125a 149/372: - added the chance to delete annotation and modify the annotated text, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 3e76557cf7 154/372: Merge pull request #53 from cage2/summary-win-delete-replace-annotation, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 9cc55145de 150/372: - shown, when editing annotation in summary window and asking user to, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate a370187f0b 151/372: - initial working on placing an annotation on its own line if too long., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 2292d5c6c8 160/372: - changed variable name from: 'text' to a more meaningful 'annotated text'., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 54d112e8d3 174/372: [bugfix] mitigated bug that prevented rendering of annotation when,
ELPA Syncer <=
- [nongnu] elpa/annotate 91412e5d65 175/372: - removed multiple, consecutive, spaces in comments., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate ed6a7dd7cc 180/372: - prevented fails of fontification of annotated regions, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate e4a7750e8c 183/372: - prevented overlapping of annotations when a symbol is already, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate eaffc1eba1 185/372: - mark buffer as modified even if the only action the user performed, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 7cf7f46be0 191/372: - removed duplicated function., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 9c2bf1bd36 192/372: - used the correct functions when recurse., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 78fc74289f 194/372: - use iteration instead of recursion in, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 2dabb8d886 196/372: Merge branch 'master' into rethink-multiline-annotations, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate e1a0917d98 197/372: - fixed 'annotate-previous-annotation-ends' and 'annotate-next-annotation-ends', ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate e7ca823566 201/372: Merge branch 'master' into org-mode-fix, ELPA Syncer, 2022/02/04