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

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

[elpa] master 6db3d54 024/167: ivy.el (ivy--insert-prompt): Use newlines


From: Oleh Krehel
Subject: [elpa] master 6db3d54 024/167: ivy.el (ivy--insert-prompt): Use newlines instead of truncation
Date: Tue, 08 Dec 2015 10:49:40 +0000

branch: master
commit 6db3d543cd277147886fec70658a0477ca83fb6f
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    ivy.el (ivy--insert-prompt): Use newlines instead of truncation
    
    When the prompt string is longer than window-width, insert newlines
    appropriately so that the whole prompt fits in the window without
    scrolling.  Finally, when prompt+entered text would be larger than
    window-width, reformat the prompt so that entered text starts on a
    newline.  When completing file names, move the whole path to a new line
    in that case.
    
    Fixes #252
---
 ivy.el |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/ivy.el b/ivy.el
index 7885a9c..73ebbfa 100644
--- a/ivy.el
+++ b/ivy.el
@@ -1342,17 +1342,21 @@ Insert .* between each char."
                                   ivy--full-length)
                              ivy--length)))
                ivy--prompt-extra
-               tail)
-              (if ivy--directory
-                  (abbreviate-file-name ivy--directory)
-                ""))))
+               tail)))
+            (d-str (if ivy--directory
+                       (abbreviate-file-name ivy--directory)
+                     "")))
         (save-excursion
           (goto-char (point-min))
           (delete-region (point-min) (minibuffer-prompt-end))
-          (when (> (length n-str) (- (window-width) 35))
-            (setq n-str (concat (substring n-str 0
-                                           (max (- (window-width) 35)
-                                                10)) "... ")))
+          (if (> (+ (mod (+ (length n-str) (length d-str)) (window-width))
+                    (length ivy-text))
+                 (window-width))
+              (setq n-str (concat n-str "\n" d-str))
+            (setq n-str (concat n-str d-str)))
+          (let ((regex (format "\\([^\n]\\{%d\\}\\)[^\n]" (window-width))))
+            (while (string-match regex n-str)
+              (setq n-str (replace-match (concat (match-string 1 n-str) "\n") 
nil t n-str 1))))
           (set-text-properties 0 (length n-str)
                                `(face minibuffer-prompt ,@std-props)
                                n-str)



reply via email to

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