[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 5a99dda 118/167: ivy.el (ivy--truncate-string): New defun
From: |
Oleh Krehel |
Subject: |
[elpa] master 5a99dda 118/167: ivy.el (ivy--truncate-string): New defun |
Date: |
Tue, 08 Dec 2015 10:50:25 +0000 |
branch: master
commit 5a99ddab228ab9a9c8142bbae89f2fc8b3742509
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
ivy.el (ivy--truncate-string): New defun
* ivy.el (ivy-format-function-default): Use `ivy--truncate-string'.
---
ivy.el | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/ivy.el b/ivy.el
index 7eb3898..bf89836 100644
--- a/ivy.el
+++ b/ivy.el
@@ -1847,6 +1847,13 @@ Prefix matches to NAME are put ahead of the list."
"Function to transform the list of candidates into a string.
This string will be inserted into the minibuffer.")
+(defun ivy--truncate-string (str width)
+ "Truncate STR to WIDTH."
+ (if (> (string-width str) width)
+ (concat (substring str 0 (min (- width 3)
+ (- (length str) 3))) "...")
+ str))
+
(defun ivy-format-function-default (cands)
"Transform CANDS into a string for minibuffer."
(if (bound-and-true-p truncate-lines)
@@ -1856,9 +1863,7 @@ This string will be inserted into the minibuffer.")
(mapconcat
(if truncate-lines
(lambda (s)
- (if (> (length s) ww)
- (concat (substring s 0 (- ww 3)) "...")
- s))
+ (ivy--truncate-string s ww))
#'identity)
cands "\n"))))
- [elpa] master 5d90542 112/167: ivy.el (ivy-sort-functions-alist): Update doc, (continued)
- [elpa] master 5d90542 112/167: ivy.el (ivy-sort-functions-alist): Update doc, Oleh Krehel, 2015/12/08
- [elpa] master adac116 126/167: Make ivy-completing-read handle history as cons, Oleh Krehel, 2015/12/08
- [elpa] master c580fe9 108/167: ivy.el (ivy-occur): Give full counsel-git-grep cands, Oleh Krehel, 2015/12/08
- [elpa] master bb68b67 122/167: Intermediate fix for :preselect with visual-line-mode, Oleh Krehel, 2015/12/08
- [elpa] master 5751119 124/167: README.md: Add more bindings, Oleh Krehel, 2015/12/08
- [elpa] master e47ec14 128/167: ivy.el (ivy-completing-read): Fix off by one, Oleh Krehel, 2015/12/08
- [elpa] master d5489af 100/167: doc/ivy.org: Start writing a manual, Oleh Krehel, 2015/12/08
- [elpa] master c4c1878 121/167: Fix swiper preselect issue with similar or identical lines, Oleh Krehel, 2015/12/08
- [elpa] master 7397bec 114/167: Allow user-specified matched candidate sorting, Oleh Krehel, 2015/12/08
- [elpa] master ce557d1 119/167: swiper.el (swiper--candidates): Replace "\t" with " ", Oleh Krehel, 2015/12/08
- [elpa] master 5a99dda 118/167: ivy.el (ivy--truncate-string): New defun,
Oleh Krehel <=
- [elpa] master 3101efd 136/167: swiper.el (swiper--action): push-mark only if exited the minibuffer, Oleh Krehel, 2015/12/08
- [elpa] master 63f3498 123/167: Add precise preselect for swiper with visual-line-mode, Oleh Krehel, 2015/12/08
- [elpa] master 74bb138 144/167: Update ivy format functions., Oleh Krehel, 2015/12/08
- [elpa] master 39e6733 129/167: Improve ivy TRAMP support, Oleh Krehel, 2015/12/08
- [elpa] master 63e714c 130/167: Allow access to TRAMP from "// C-j", Oleh Krehel, 2015/12/08
- [elpa] master 85bd44b 125/167: swiper.el: Modify the behavior with org-mode and visual-line-mode, Oleh Krehel, 2015/12/08
- [elpa] master 8fdf210 127/167: Switch to using ivy-exit-with-action, Oleh Krehel, 2015/12/08
- [elpa] master ce6ab7a 135/167: Perform string-match in the original buffer, Oleh Krehel, 2015/12/08
- [elpa] master bc00eaf 137/167: Fix `counsel-ag` on Windows, Oleh Krehel, 2015/12/08
- [elpa] master ed2367b 134/167: swiper.el (swiper--candidates): Require outline, Oleh Krehel, 2015/12/08