[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master f647bca 136/272: Simplify the ivy-format-function interfac
From: |
Oleh Krehel |
Subject: |
[elpa] master f647bca 136/272: Simplify the ivy-format-function interface |
Date: |
Mon, 25 Apr 2016 10:13:21 +0000 |
branch: master
commit f647bcad6e7504c2ce1bdeee46200facccc9a7a5
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Simplify the ivy-format-function interface
* ivy.el (ivy--format-function-generic): Third arg is no longer a list
of cons cells, but a list of strings instead.
(ivy-format-function-default):
(ivy-format-function-arrow):
(ivy-format-function-line): Take a string instead of a cons cell.
(ivy--format): Feed strings instead of cons cells to
`ivy-format-function'.
* ivy-test.el (ivy--format): Update test.
* counsel.el (counsel--yank-pop-format-function): Take a string instead
of a cons cell.
Re #399
---
counsel.el | 4 ++--
ivy-test.el | 2 +-
ivy.el | 44 +++++++++++++++++++++-----------------------
3 files changed, 24 insertions(+), 26 deletions(-)
diff --git a/counsel.el b/counsel.el
index fc69a1e..e534601 100644
--- a/counsel.el
+++ b/counsel.el
@@ -1465,14 +1465,14 @@ INITIAL-INPUT can be given as the initial minibuffer
input."
(defun counsel--yank-pop-format-function (cand-pairs)
(ivy--format-function-generic
- (lambda (str _extra)
+ (lambda (str)
(mapconcat
(lambda (s)
(ivy--add-face s 'ivy-current-match))
(split-string
(counsel--yank-pop-truncate str) "\n" t)
"\n"))
- (lambda (str _extra)
+ (lambda (str)
(counsel--yank-pop-truncate str))
cand-pairs
"\n"))
diff --git a/ivy-test.el b/ivy-test.el
index e857449..7533169 100644
--- a/ivy-test.el
+++ b/ivy-test.el
@@ -143,7 +143,7 @@
(ert-deftest ivy--format ()
(should (string= (let ((ivy--index 10)
- (ivy-format-function (lambda (x) (mapconcat (lambda
(y) (car y)) x "\n")))
+ (ivy-format-function (lambda (x) (mapconcat
#'identity x "\n")))
(cands '("NAME"
"SYNOPSIS"
"DESCRIPTION"
diff --git a/ivy.el b/ivy.el
index bff2454..ec51e68 100644
--- a/ivy.el
+++ b/ivy.el
@@ -2297,49 +2297,47 @@ This string is inserted into the minibuffer."
(- (length str) 3))) "...")
str))
-(defun ivy--format-function-generic (selected-fn other-fn cand-pairs separator)
+(defun ivy--format-function-generic (selected-fn other-fn strs separator)
"Transform CAND-PAIRS into a string for minibuffer.
SELECTED-FN and OTHER-FN each take two string arguments.
SEPARATOR is used to join the candidates."
(let ((i -1))
(mapconcat
- (lambda (pair)
- (let ((str (car pair))
- (extra (cdr pair))
- (curr (eq (cl-incf i) ivy--index)))
+ (lambda (str)
+ (let ((curr (eq (cl-incf i) ivy--index)))
(if curr
- (funcall selected-fn str extra)
- (funcall other-fn str extra))))
- cand-pairs
+ (funcall selected-fn str)
+ (funcall other-fn str))))
+ strs
separator)))
-(defun ivy-format-function-default (cand-pairs)
+(defun ivy-format-function-default (cands)
"Transform CAND-PAIRS into a string for minibuffer."
(ivy--format-function-generic
- (lambda (str extra)
- (concat (ivy--add-face str 'ivy-current-match) extra))
- #'concat
- cand-pairs
+ (lambda (str)
+ (ivy--add-face str 'ivy-current-match))
+ #'identity
+ cands
"\n"))
-(defun ivy-format-function-arrow (cand-pairs)
+(defun ivy-format-function-arrow (cands)
"Transform CAND-PAIRS into a string for minibuffer."
(ivy--format-function-generic
- (lambda (str extra)
- (concat "> " (ivy--add-face str 'ivy-current-match) extra))
- (lambda (str extra)
- (concat " " str extra))
- cand-pairs
+ (lambda (str)
+ (concat "> " (ivy--add-face str 'ivy-current-match)))
+ (lambda (str)
+ (concat " " str))
+ cands
"\n"))
-(defun ivy-format-function-line (cand-pairs)
+(defun ivy-format-function-line (cands)
"Transform CAND-PAIRS into a string for minibuffer."
(ivy--format-function-generic
(lambda (str extra)
(ivy--add-face (concat str extra "\n") 'ivy-current-match))
(lambda (str extra)
(concat str extra "\n"))
- cand-pairs
+ cands
""))
(defun ivy-add-face-text-property (start end face str)
@@ -2422,8 +2420,8 @@ CANDS is a list of strings."
(setq cands (mapcar transformer-fn cands))))
(let* ((ivy--index index)
(cands (mapcar
- (lambda (cand)
- (cons (ivy--format-minibuffer-line cand) nil)) cands))
+ #'ivy--format-minibuffer-line
+ cands))
(res (concat "\n" (funcall ivy-format-function cands))))
(put-text-property 0 (length res) 'read-only nil res)
res))))
- [elpa] master e12ff84 125/272: counsel.el (counsel-list-processes-action-switch): Improve, (continued)
- [elpa] master e12ff84 125/272: counsel.el (counsel-list-processes-action-switch): Improve, Oleh Krehel, 2016/04/25
- [elpa] master 1737ced 064/272: ivy.el (ivy-inhibit-action): New variable, Oleh Krehel, 2016/04/25
- [elpa] master 05a7b61 070/272: ivy.el (ivy--reset-state): Support a list of symbols as collection, Oleh Krehel, 2016/04/25
- [elpa] master 65ec32c 080/272: README.md: mention the manual more prominently, Oleh Krehel, 2016/04/25
- [elpa] master 4af5c2e 115/272: Add `counsel-locate-cmd-mdfind`, Oleh Krehel, 2016/04/25
- [elpa] master 022e658 090/272: When in prog-mode, "M-n" should wrap input with "\b", Oleh Krehel, 2016/04/25
- [elpa] master 9db8308 103/272: counsel.el: Organize the file with outlines, Oleh Krehel, 2016/04/25
- [elpa] master 1c04fb8 126/272: Add ivy-fixed-height-minibuffer, Oleh Krehel, 2016/04/25
- [elpa] master 7a0b243 130/272: Give ivy-read-read-action enough minibuffer space, Oleh Krehel, 2016/04/25
- [elpa] master 708ca11 141/272: ivy.el: Fix a few face declarations, Oleh Krehel, 2016/04/25
- [elpa] master f647bca 136/272: Simplify the ivy-format-function interface,
Oleh Krehel <=
- [elpa] master c2b330b 091/272: doc/ivy.org: Add @vindex and @kindex automatically, Oleh Krehel, 2016/04/25
- [elpa] master 4c99ec6 107/272: counsel.el: Shuffle functions, Oleh Krehel, 2016/04/25
- [elpa] master 0fd6a75 142/272: Move switch-to-buffer to :display-transformer-fn, Oleh Krehel, 2016/04/25
- [elpa] master f5a21db 157/272: ivy.el: define setq-local and defvar-local unless defined, Oleh Krehel, 2016/04/25
- [elpa] master 71644d9 190/272: ivy.el (ivy-read): Remove code that sets action index to 1, Oleh Krehel, 2016/04/25
- [elpa] master 220fd38 079/272: doc/ivy.org: Improve the markup, Oleh Krehel, 2016/04/25
- [elpa] master 50f3092 169/272: counsel.el (counsel--async-sentinel): Start refactor, Oleh Krehel, 2016/04/25
- [elpa] master 41b8b0d 113/272: ivy.el (ivy-occur): Add a warning, Oleh Krehel, 2016/04/25
- [elpa] master b39e449 228/272: counsel.el (counsel-ag-map): Add, Oleh Krehel, 2016/04/25
- [elpa] master 79f9cda 165/272: counsel-ag: Fix escaping problem, Oleh Krehel, 2016/04/25