[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/annotate 0ae5752526 161/372: Merge pull request #54 from c
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/annotate 0ae5752526 161/372: Merge pull request #54 from cage2/annotations-on-their-own-line |
Date: |
Fri, 4 Feb 2022 16:58:55 -0500 (EST) |
branch: elpa/annotate
commit 0ae5752526dbf9cab4574f374841d93824a103b8
Merge: 3e76557cf7 2292d5c6c8
Author: cage2 <1257703+cage2@users.noreply.github.com>
Commit: GitHub <noreply@github.com>
Merge pull request #54 from cage2/annotations-on-their-own-line
Annotations on their own line
---
annotate.el | 98 +++++++++++++++++++++++++++++++++++++++++++++++--------------
1 file changed, 76 insertions(+), 22 deletions(-)
diff --git a/annotate.el b/annotate.el
index 98e528d0e0..9bed16f2ba 100644
--- a/annotate.el
+++ b/annotate.el
@@ -140,6 +140,30 @@ database is not filtered at all."
:type 'boolean
:group 'annotate)
+(defcustom annotate-annotation-max-size-not-place-new-line 15
+ "The maximum `string-width` allowed for an annotation to be
+ placed on the right margin of the window instead of its own line
+ after the annotated text."
+ :type 'number
+ :group 'annotate)
+
+(defcustom annotate-annotation-position-policy :by-length
+ "policy for annotation's position:
+ - :newline
+ always in a new-line
+ - :margin
+ always on right margin
+ - :by-length
+ decide by text's length
+
+ if the length is more than the value of
+ `annotate-annotation-max-size-not-place-new-line' place the
+ annotation on a new line, place on the right margin
+ otherwise.
+"
+ :type 'symbol
+ :group 'annotate)
+
(defconst annotate-warn-file-changed-control-string
(concat "The file '%s' has changed on disk "
"from the last time the annotations were saved.\n"
@@ -756,10 +780,14 @@ to 'maximum-width'."
(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
+ (let ((prefix-first (annotate-make-prefix)) ; white spaces
+ ; before first
+ ; line of
+ ; annotation
+ (prefix-rest (make-string annotate-annotation-column ? ))
(bol (progn (beginning-of-line) (point)))
(eol (progn (end-of-line) (point)))
- (text "")
+ (annotation-text "")
(overlays nil)
(annotation-counter 1))
;; include previous line if point is at bol:
@@ -782,36 +810,62 @@ to 'maximum-width'."
(<= (overlay-start a)
newline-position
(overlay-end a))))
- (overlays-in bol eol))
+ (overlays-in bol eol))
(lambda (x y)
(< (overlay-end x) (overlay-end y)))))
- ;; put each annotation on its own line
+ ;; configure each annotation's properties and place it on the
+ ;; the window. The actual position of the annotation (newline
+ ;; or right marigin) is indicated by the value of the
+ ;; variable: `annotate-annotation-position-policy'.
(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)))
+ (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))
+ (annotation-long-p (> (string-width (overlay-get ov
'annotation))
+
annotate-annotation-max-size-not-place-new-line))
+ (position-new-line-p (cl-case
annotate-annotation-position-policy
+ (:new-line
+ t)
+ (:by-length
+ annotation-long-p)
+ (otherwise
+ nil)))
+ (multiline-annotation (if position-new-line-p
+ (list (overlay-get ov 'annotation))
+ (save-match-data
+ (split-string (annotate-lineate
(overlay-get ov
+
'annotation)
+ (-
eol bol))
+ "\n"))))
+ (annotation-stopper (if position-new-line-p
+ (if (= annotation-counter
+ (length overlays))
+ "\n"
+ "")
+ "\n")))
+ (cl-incf annotation-counter)
(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
+ (when position-new-line-p
+ (setf prefix-first " \n"))
+ (dolist (l multiline-annotation)
+ (setq annotation-text
+ (concat annotation-text
+ prefix-first
(propertize l 'face face)
- "\n"))
+ annotation-stopper))
;; white space before for all but the first annotation line
- (setq prefix (make-string annotate-annotation-column ? )))))
+ (if position-new-line-p
+ (setq prefix-first (concat prefix-first prefix-rest))
+ (setq prefix-first prefix-rest)))))
;; build facespec with the annotation text as display property
- (if (string= text "")
+ (if (string= annotation-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))))))
+ (list 'face 'default 'display annotation-text))))))
(defun annotate--remove-annotation-property (begin end)
"Cleans up annotation properties associated with a region."
- [nongnu] elpa/annotate 8e8d5d125e 130/372: - fixed macro: "annotate-with-inhibit-modification-hooks"., (continued)
- [nongnu] elpa/annotate 8e8d5d125e 130/372: - fixed macro: "annotate-with-inhibit-modification-hooks"., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate fbd21602e8 129/372: - refactored 'annotate-actual-file-name' and used where appropriate., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 7127180360 145/372: - added 'cl-' prefix to 'remove-if';, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate e43d2f9e65 069/372: - fixed left margin of annotation, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate a51b5239b9 062/372: fixes incorrect annotation display for wide characters, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 0d315a806e 105/372: - fixed first argument of 'lwarn';, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 1ed168a79e 131/372: Merge pull request #47 from cage2/master, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate c8aea8392d 135/372: - rewritten filename juggling to make it works with info file in, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 286646bc0c 137/372: - made recongnizable code that refers to info file annotation. (2/3), ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 13391d9576 157/372: - expanded a comment and a docstring., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 0ae5752526 161/372: Merge pull request #54 from cage2/annotations-on-their-own-line,
ELPA Syncer <=
- [nongnu] elpa/annotate c21b95273e 177/372: Merge pull request #57 from cage2/master, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 2ccdad1504 193/372: - starting with a new method to render multiline annotations, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 71f316be2f 236/372: - added dependency on 'info'., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 7a96192be2 248/372: - according to documentation the secon argument of 'signal' must be a list., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate f2b085d279 288/372: - fixed typos., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 26ea8e3631 266/372: - prevented getting shared value for 'annotate-file' in '%load-annotation-data'., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate b505af0f27 300/372: - updated NEWS, Changelog and version number., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 17958167da 298/372: Merge pull request #96 from cage2/master, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 784df37cba 313/372: - updated version number., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 9cdc2a90fb 350/372: - added prompt to confirm deletion also when deleting annotation's text;, ELPA Syncer, 2022/02/04