[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/annotate 47dba946e8 075/372: - removed spurious newline ch
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/annotate 47dba946e8 075/372: - removed spurious newline character at the end of annotation text; |
Date: |
Fri, 4 Feb 2022 16:58:20 -0500 (EST) |
branch: elpa/annotate
commit 47dba946e870e8983d893f536194401adf15fcf7
Author: cage <cage-invalid@invalid>
Commit: cage <cage-invalid@invalid>
- removed spurious newline character at the end of annotation text;
- improved positioning of annotation text when annotated text is made
of a long (more than window width) line.
---
annotate.el | 78 +++++++++++++++++++++++++++++++++++++++++--------------------
1 file changed, 53 insertions(+), 25 deletions(-)
diff --git a/annotate.el b/annotate.el
index 3d78ce7fed..536a069c98 100644
--- a/annotate.el
+++ b/annotate.el
@@ -513,26 +513,54 @@ to 'maximum-width'."
(grouped (reverse (%group words '()))))
grouped))))
+(cl-defun annotate-safe-subseq (seq from to &optional (value-if-limits-invalid
seq))
+ "This return 'value-if-limits-invalid' sequence if 'from' or 'to' are
invalids"
+ (cond
+ ((< to from)
+ value-if-limits-invalid)
+ ((or (< from 0)
+ (> from (length seq))
+ (> to (length seq)))
+ value-if-limits-invalid)
+ (t
+ (cl-subseq seq from to))))
+
(defun annotate-lineate (text line-width)
"Breaks `text` into lines to fit in the annotation space"
- (let* ((theoretical-line-width (- (window-body-width)
- annotate-annotation-column))
- (available-width (if (> theoretical-line-width 0)
- theoretical-line-width
- line-width))
- (lineated-list (annotate-group-by-width text
available-width))
- (max-width (apply #'max
- (mapcar #'string-width lineated-list)))
- (lineated (cl-mapcar (lambda (a)
- (let* ((size (string-width
a))
- (rest-width (max (-
max-width
- size)
- 0))
- (padding (make-string
rest-width
-
? )))
- (concat a padding "\n")))
- lineated-list)))
- (apply #'concat lineated)))
+ (cl-labels ((pad (string max-width add-newline-p)
+ (if (null string)
+ ""
+ (let* ((size (string-width string))
+ (rest-width (max (- max-width
+ size)
+ 0))
+ (padding (make-string rest-width
+ ? )))
+ (if add-newline-p
+ (concat string padding "\n")
+ (concat string padding)))))
+ (%subseq (seq from to)
+ (if (= (length seq) 1)
+ nil
+ (annotate-safe-subseq seq from to nil))))
+ (let* ((theoretical-line-width (- (window-body-width)
+ annotate-annotation-column))
+ (available-width (if (> theoretical-line-width 0)
+ theoretical-line-width
+ line-width))
+ (lineated-list (annotate-group-by-width text
available-width))
+ (max-width (apply #'max
+ (mapcar #'string-width
lineated-list)))
+ (all-but-last-lineated-list (%subseq lineated-list 0 (1- (length
lineated-list))))
+ (last-line (if all-but-last-lineated-list
+ (car (last lineated-list))
+ (cl-first lineated-list)))
+ (lineated (cl-mapcar (lambda (a)
+ (pad a max-width t))
+ all-but-last-lineated-list)))
+ (apply #'concat
+ (append lineated
+ (list (pad last-line max-width nil)))))))
(defun annotate--annotation-builder ()
"Searches the line before point for annotations, and returns a
@@ -555,16 +583,16 @@ to 'maximum-width'."
(dolist (ov overlays)
(if (overlay-get ov 'annotation)
(dolist (l (save-match-data
- (split-string
- (annotate-lineate (overlay-get ov 'annotation)
- (- eol bol)) "\n")))
+ (split-string (annotate-lineate (overlay-get ov
'annotation)
+ (- eol bol))
+ "\n")))
(setq text
(concat text prefix
(propertize l 'face 'annotate-annotation)
"\n"))
- ;; white space before for all but the first annotation
+ ;; white space before for all but the first annotation line
(setq prefix (make-string annotate-annotation-column ? )))))
- ;; build facecpec with the annotation text as display property
+ ;; build facespec with the annotation text as display property
(if (string= text "")
;; annotation has been removed: remove display prop
(list 'face 'default 'display nil)
@@ -708,8 +736,8 @@ an overlay and it's annotation."
(progn (beginning-of-line) (point))
(progn (end-of-line) (point))))
(prefix-length (- annotate-annotation-column (string-width
line-text))))
- (if (< prefix-length 2)
- (make-string 2 ? )
+ (if (< prefix-length 1)
+ (concat "\n" (make-string annotate-annotation-column ? ))
(make-string prefix-length ? )))))
(defun annotate-bounds ()
- [nongnu] elpa/annotate f823c3cf09 354/372: - changed default for asking confirm before deleting an annotation: the value is now 'nil' (do not prompt for confirmation)., (continued)
- [nongnu] elpa/annotate f823c3cf09 354/372: - changed default for asking confirm before deleting an annotation: the value is now 'nil' (do not prompt for confirmation)., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 3bb813cd62 360/372: - updated NEWS.org and Changelog., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 140eb6b6cb 363/372: - updated NEWS.org;, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate b22f594f3b 336/372: Merge pull request #107 from cage2/prevent-saving-empty-db, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate de86b9b22e 341/372: - removed uses of regular expressions from 'annotate-unwrap-text'., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate e083073ead 371/372: - updated Changelog;, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 0901aa52bc 367/372: - added the others procedures to import an annotation database., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate f08923762f 063/372: fix typo in documentation, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 16f7202d7c 091/372: - fixed docstring., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 7c759ba9eb 082/372: - fixed english language error., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 47dba946e8 075/372: - removed spurious newline character at the end of annotation text;,
ELPA Syncer <=
- [nongnu] elpa/annotate 91f1d49368 087/372: - squeezed contiguous spaces in docstring., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate f85f8e00a1 088/372: - remove file size limit for hash calculation., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate bf80059e7a 071/372: - use comment ends string in modes that allow it (e.g. html-mode);, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate f01b98de03 096/372: - restored the kill buffer key command., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 1313777f03 098/372: - added args to local function., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 0bbdbea410 095/372: - improved appereance of summary window, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate edaafc69a9 052/372: no more broken annotations with umlauts, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate c42db2cdf9 034/372: don't mark buffer as modified on load or clear, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 38eb69da8b 107/372: - added a secondary color for highlight and annotation text, the two, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate af6d1bd39a 055/372: tiny bugfix, ELPA Syncer, 2022/02/04