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

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

[nongnu] elpa/annotate 4dc3e70920 059/372: fixes bug for too-wide charac


From: ELPA Syncer
Subject: [nongnu] elpa/annotate 4dc3e70920 059/372: fixes bug for too-wide characters
Date: Fri, 4 Feb 2022 16:58:18 -0500 (EST)

branch: elpa/annotate
commit 4dc3e70920c99b952bd9fcd06c0465c5c45e3afd
Author: Bastian Bechtold <bastian.bechtold@jade-hs.de>
Commit: Bastian Bechtold <bastian.bechtold@jade-hs.de>

    fixes bug for too-wide characters
    
    replaces `string-width` with `length` for calculating the length of a
    string. This fixes a bug with non-monospace characters which might have
    a longer `string-width` than `length`.
---
 annotate.el | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/annotate.el b/annotate.el
index f363f864de..6de7866df5 100644
--- a/annotate.el
+++ b/annotate.el
@@ -230,7 +230,7 @@ An example might look like this:"
                           (point))))
           (end-of-line)
           (insert "\n" comment-start
-                  (make-string (max 0 (- ov-start bol (string-width 
comment-start))) ? )
+                  (make-string (max 0 (- ov-start bol (length comment-start))) 
? )
                   (make-string (max 0 (- eol ov-start)) ?~)))
         ;; fully underline second to second-to-last line
         (while (< (progn (forward-line)
@@ -242,14 +242,14 @@ An example might look like this:"
                             (point))))
             (end-of-line)
             (insert "\n" comment-start
-                    (make-string (max 0 (- eol bol (string-width 
comment-start))) ?~))))
+                    (make-string (max 0 (- eol bol (length comment-start))) 
?~))))
         ;; partially underline last line
         (let ((bol (progn (beginning-of-line)
                           (point)))
               (ov-end (overlay-end ov)))
           (end-of-line)
           (insert "\n" comment-start
-                  (make-string (max 0 (- ov-end bol (string-width 
comment-start))) ?~)))
+                  (make-string (max 0 (- ov-end bol (length comment-start))) 
?~)))
         ;; insert actual annotation text
         (insert "\n" comment-start annotate-integrate-marker (overlay-get ov 
'annotation)))
        ;; overlay is within one line
@@ -260,7 +260,7 @@ An example might look like this:"
                           (point))))
           (end-of-line)
           (insert "\n" comment-start
-                  (make-string (max 0 (- ov-start bol (string-width 
comment-start))) ? )
+                  (make-string (max 0 (- ov-start bol (length comment-start))) 
? )
                   (if (= bol ov-start)
                       (make-string (max 0 (- ov-end ov-start 1)) ?~)
                     (make-string (max 0 (- ov-end ov-start)) ?~))
@@ -411,19 +411,19 @@ annotation plus the newline."
         ;; if the annotation won't fit at the end of the line:
         (lineated (if (< line-width annotate-annotation-column) "" "\n"))
         (current-pos 0))
-    (while (< current-pos (string-width text))
+    (while (< current-pos (length text))
       (let ((current-line
              (substring text current-pos
-                        (min (string-width text)
+                        (min (length text)
                              (+ 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)))
+                   (< (+ current-pos (length current-line)) (length 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) ? )
+        (let ((postfix (if (< (+ current-pos (length current-line)) (length 
text))
+                           (make-string (- available-width (length 
current-line) 1) ? )
                          "")))
           (setq lineated (concat lineated current-line postfix "\n")
                 current-pos (+ current-pos (length current-line))))))



reply via email to

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