[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/annotate a370187f0b 151/372: - initial working on placing
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/annotate a370187f0b 151/372: - initial working on placing an annotation on its own line if too long. |
Date: |
Fri, 4 Feb 2022 16:58:41 -0500 (EST) |
branch: elpa/annotate
commit a370187f0b4734d68a1030de5c4e22fb8520928f
Author: cage <cage-invalid@invalid>
Commit: cage <cage-invalid@invalid>
- initial working on placing an annotation on its own line if too long.
---
annotate.el | 62 ++++++++++++++++++++++++++++++++++++++++---------------------
1 file changed, 41 insertions(+), 21 deletions(-)
diff --git a/annotate.el b/annotate.el
index 7060c41777..20d249d0cb 100644
--- a/annotate.el
+++ b/annotate.el
@@ -140,6 +140,13 @@ 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)
+
(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,12 +763,13 @@ 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
- (bol (progn (beginning-of-line) (point)))
- (eol (progn (end-of-line) (point)))
- (text "")
- (overlays nil)
- (annotation-counter 1))
+ (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 "")
+ (overlays nil)
+ (annotation-counter 1))
;; include previous line if point is at bol:
(when (null (overlays-in bol eol))
(setq bol (1- bol)))
@@ -782,30 +790,42 @@ 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
(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))
+ (splitted-annotation (if annotation-long-p
+ (list (overlay-get ov 'annotation))
+ (save-match-data
+ (split-string (annotate-lineate
(overlay-get ov 'annotation)
+ (-
eol bol))
+ "\n"))))
+ (annotation-stopper (if annotation-long-p
+ ""
+ "\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")))
+ (when annotation-long-p
+ (setf prefix-first " \n"))
+ (dolist (l splitted-annotation)
(setq text
(concat text
- prefix
+ 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 annotation-long-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 "")
;; annotation has been removed: remove display prop
- [nongnu] elpa/annotate 7ebddc73a0 144/372: - enabled filtering of annotation database when a summary window is shown., (continued)
- [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
- [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 <=
- [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, 2022/02/04
- [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