emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/annotate 067fe860ea 054/372: added word wrap for long anno


From: ELPA Syncer
Subject: [nongnu] elpa/annotate 067fe860ea 054/372: added word wrap for long annotations
Date: Fri, 4 Feb 2022 16:58:18 -0500 (EST)

branch: elpa/annotate
commit 067fe860eabcbad4894609c06f090c2c0f97773f
Author: Bastian Bechtold <basti@bastibe.de>
Commit: Bastian Bechtold <basti@bastibe.de>

    added word wrap for long annotations
---
 README.md   |  3 +++
 annotate.el | 19 +++++++++++++------
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/README.md b/README.md
index c0f5e140f7..6bc917e575 100644
--- a/README.md
+++ b/README.md
@@ -77,3 +77,6 @@ This package is released under the MIT license.
 
 - **2015-10-06 V0.4.4 Bastian Bechtold**  
   Added a new export system. Let's see if it turns out to be more useful than 
the previous one.
+  
+- **2016-08-25 V0.4.5 Bastian Bechtold**  
+  Bugfix release for unicode annotations and multiline annotations.
diff --git a/annotate.el b/annotate.el
index 7b4dae9174..972e49bdf9 100644
--- a/annotate.el
+++ b/annotate.el
@@ -412,14 +412,21 @@ annotation plus the newline."
         (lineated (if (< line-width annotate-annotation-column) "" "\n"))
         (current-pos 0))
     (while (< current-pos (string-width text))
-      (setq lineated
-            (concat
-             lineated
+      (let ((current-line
              (substring text current-pos
                         (min (string-width text)
-                             (+ current-pos available-width -1)))
-             "\n"))
-      (setq current-pos (+ current-pos available-width -1)))
+                             (+ current-pos available-width -1)))))
+        ;; strip partial last word if necessary, for word wrap:
+        (when (and (string-match "[^ ]$" current-line)
+                   (< (+ current-pos (length current-line)) (string-width 
text)))
+          (string-match "[ ][^ ]+$" current-line)
+          (setq current-line (replace-match " " nil nil current-line)))
+        ;; append white space to the end of continued lines
+        (let ((postfix (if (< (+ current-pos (length current-line)) 
(string-width text))
+                           (make-string (- available-width (string-width 
current-line) 1) ? )
+                         "")))
+          (setq lineated (concat lineated current-line postfix "\n")
+                current-pos (+ current-pos (length current-line))))))
     ;; strip trailing newline, if any
     (if (string= (substring lineated (1- (length lineated))) "\n")
         (substring lineated 0 (1- (length lineated)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]