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

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

[nongnu] elpa/annotate e1cafc819b 101/372: - removed newlines in snippet


From: ELPA Syncer
Subject: [nongnu] elpa/annotate e1cafc819b 101/372: - removed newlines in snippet text;
Date: Fri, 4 Feb 2022 16:58:22 -0500 (EST)

branch: elpa/annotate
commit e1cafc819be12e955596cd6466f131ef46ae676f
Author: cage <cage-invalid@invalid>
Commit: cage <cage-invalid@invalid>

    - removed newlines in snippet text;
    - fixed wrapping of snipped text even when the latter is trunxated;
    - take into account for very small  windows when text snippet is built.
---
 annotate.el | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/annotate.el b/annotate.el
index 919e4a45f3..5c6967e136 100644
--- a/annotate.el
+++ b/annotate.el
@@ -965,25 +965,27 @@ essentially what you get from:
   "Show a summary of all the annotations in a temp buffer"
   (interactive)
   (cl-labels ((ellipsize (text prefix-string)
-                         (let ((prefix-length  (string-width prefix-string))
-                               (ellipse-length (string-width 
annotate-ellipse-text-marker)))
+                         (let* ((prefix-length   (string-width prefix-string))
+                                (ellipse-length  (string-width 
annotate-ellipse-text-marker))
+                                (substring-limit (max 0
+                                                      (- (window-body-width)
+                                                         prefix-length
+                                                         ellipse-length
+                                                         2)))) ; this is for 
quotation marks
                            (if (> (string-width text)
                                   (+ (window-body-width)
                                      prefix-length
-                                     ellipse-length))
-                               (concat (substring text
-                                                  0
-                                                  (- (window-body-width)
-                                                     prefix-length
-                                                     ellipse-length))
+                                     ellipse-length
+                                     2)) ; this is for quotation marks
+                               (concat (substring text 0 substring-limit)
                                        annotate-ellipse-text-marker)
                              text)))
               (wrap      (text)
                          (concat "\"" text "\""))
               (insert-item-summary (snippet-text button-text)
                                    (insert 
annotate-summary-list-prefix-snippet)
-                                   (insert (ellipsize (wrap snippet-text)
-                                                      
annotate-summary-list-prefix-snippet))
+                                   (insert (wrap (ellipsize snippet-text
+                                                            
annotate-summary-list-prefix-snippet)))
                                    (insert "\n")
                                    (insert annotate-summary-list-prefix)
                                    (insert-button (propertize (ellipsize 
button-text
@@ -1001,7 +1003,11 @@ essentially what you get from:
                                                      nil
                                                      (1- annotation-begin)
                                                      (1- annotation-end))
-                               (buffer-string))))
+                               (save-match-data
+                                 (replace-regexp-in-string "[\r\n]"
+                                                           " "
+                                                           (buffer-string))))))
+
     (with-current-buffer-window
      "*annotations*" nil nil
      (display-buffer "*annotations*")



reply via email to

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