[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 74bb138 144/167: Update ivy format functions.
From: |
Oleh Krehel |
Subject: |
[elpa] master 74bb138 144/167: Update ivy format functions. |
Date: |
Tue, 08 Dec 2015 10:50:36 +0000 |
branch: master
commit 74bb138e92042f039d1f418ba7829b92b593591b
Author: Stephen Whipple <address@hidden>
Commit: Oleh Krehel <address@hidden>
Update ivy format functions.
`ivy-format-function' now accessible via Customize system.
`ivy-format-function-default' and `ivy-format-function-arrow'
simplified.
New format `ivy-format-function-line' added.
`counsel-M-x' restores `ivy-format-function' before executing command.
Fixes #306
---
counsel.el | 3 ++-
ivy.el | 46 ++++++++++++++++++++++++++++------------------
2 files changed, 30 insertions(+), 19 deletions(-)
diff --git a/counsel.el b/counsel.el
index 020c917..5354d39 100644
--- a/counsel.el
+++ b/counsel.el
@@ -887,7 +887,8 @@ Optional INITIAL-INPUT is the initial input in the
minibuffer."
(lambda (cmd)
(when (featurep 'smex)
(smex-rank (intern cmd)))
- (let ((prefix-arg current-prefix-arg))
+ (let ((prefix-arg current-prefix-arg)
+ (ivy-format-function store))
(command-execute (intern cmd) 'record)))
:sort sort
:keymap counsel-describe-map
diff --git a/ivy.el b/ivy.el
index f83d0d0..c365d47 100644
--- a/ivy.el
+++ b/ivy.el
@@ -1894,9 +1894,13 @@ Prefix matches to NAME are put ahead of the list."
(error
cands)))
-(defvar ivy-format-function 'ivy-format-function-default
+(defcustom ivy-format-function 'ivy-format-function-default
"Function to transform the list of candidates into a string.
-This string will be inserted into the minibuffer.")
+This string will be inserted into the minibuffer."
+ :type '(choice
+ (const :tag "Default" ivy-format-function-default)
+ (const :tag "Arrow prefix" ivy-format-function-arrow)
+ (const :tag "Full line" ivy-format-function-line)))
(defun ivy--truncate-string (str width)
"Truncate STR to WIDTH."
@@ -1907,28 +1911,36 @@ This string will be inserted into the minibuffer.")
(defun ivy-format-function-default (cands)
"Transform CANDS into a string for minibuffer."
- (if (bound-and-true-p truncate-lines)
- (mapconcat #'identity cands "\n")
- (let ((ww (- (window-width)
- (if (and (boundp 'fringe-mode) (eq fringe-mode 0)) 1 0))))
- (mapconcat
- (if truncate-lines
- (lambda (s)
- (ivy--truncate-string s ww))
- #'identity)
- cands "\n"))))
+ (let ((i -1))
+ (mapconcat
+ (lambda (s)
+ (when (eq (cl-incf i) ivy--index)
+ (ivy--add-face s 'ivy-current-match))
+ s)
+ cands "\n")))
(defun ivy-format-function-arrow (cands)
"Transform CANDS into a string for minibuffer."
(let ((i -1))
(mapconcat
(lambda (s)
- (concat (if (eq (cl-incf i) ivy--index)
- "> "
- " ")
- s))
+ (let ((curr (eq (cl-incf i) ivy--index)))
+ (when curr
+ (ivy--add-face s 'ivy-current-match))
+ (concat (if curr "> " " ") s)))
cands "\n")))
+(defun ivy-format-function-line (cands)
+ "Transform CANDS into a string for minibuffer."
+ (let ((i -1))
+ (mapconcat
+ (lambda (s)
+ (let ((line (concat s "\n")))
+ (when (eq (cl-incf i) ivy--index)
+ (ivy--add-face line 'ivy-current-match))
+ line))
+ cands "")))
+
(defface ivy-minibuffer-match-face-1
'((((class color) (background light))
:background "#d3d3d3")
@@ -2032,8 +2044,6 @@ CANDS is a list of strings."
(setq cands (mapcar
#'ivy--format-minibuffer-line
cands))
- (setf (nth index cands)
- (ivy--add-face (nth index cands) 'ivy-current-match))
(let* ((ivy--index index)
(res (concat "\n" (funcall ivy-format-function cands))))
(put-text-property 0 (length res) 'read-only nil res)
- [elpa] master bb68b67 122/167: Intermediate fix for :preselect with visual-line-mode, (continued)
- [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, 2015/12/08
- [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 <=
- [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
- [elpa] master 80d4dde 141/167: Fix broken candidate index in ivy-resume, Oleh Krehel, 2015/12/08
- [elpa] master d9ecd2e 133/167: Fix the preselect for (swiper "one"), Oleh Krehel, 2015/12/08
- [elpa] master 073b071 115/167: Allow to sort files by last modification time., Oleh Krehel, 2015/12/08