[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master ce0efb3 29/57: Allow to customize the minibuffer formatter
From: |
Oleh Krehel |
Subject: |
[elpa] master ce0efb3 29/57: Allow to customize the minibuffer formatter |
Date: |
Tue, 19 May 2015 14:21:31 +0000 |
branch: master
commit ce0efb381fd4268176f9bf5eb3ade72164cd5c53
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Allow to customize the minibuffer formatter
* ivy.el (ivy-format-function): New defvar.
(ivy-format-function-default): New defun.
(ivy-format-function-arrow): New defun, alternative for
`ivy-format-function'.
Fixes #87
---
ivy.el | 34 +++++++++++++++++++++++++++-------
1 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/ivy.el b/ivy.el
index ada698e..9b6ef69 100644
--- a/ivy.el
+++ b/ivy.el
@@ -1068,6 +1068,31 @@ CANDIDATES are assumed to be static."
(setq ivy--old-re (if cands re ""))
(setq ivy--old-cands cands)))
+(defvar 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.")
+
+(defun ivy-format-function-default (cands)
+ "Transform CANDS into a string for minibuffer."
+ (let ((ww (window-width)))
+ (mapconcat
+ (lambda (s)
+ (if (> (length s) ww)
+ (concat (substring s 0 (- ww 3)) "...")
+ 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))
+ cands "\n")))
+
(defun ivy--format (cands)
"Return a string for CANDS suitable for display in the minibuffer.
CANDS is a list of strings."
@@ -1090,13 +1115,8 @@ CANDS is a list of strings."
(setq ivy--current (copy-sequence (nth index cands)))
(setf (nth index cands)
(ivy--add-face ivy--current 'ivy-current-match))
- (let* ((ww (window-width))
- (res (concat "\n" (mapconcat
- (lambda (s)
- (if (> (length s) ww)
- (concat (substring s 0 (- ww 3)) "...")
- s))
- cands "\n"))))
+ (let* ((ivy--index index)
+ (res (concat "\n" (funcall ivy-format-function cands))))
(put-text-property 0 (length res) 'read-only nil res)
res))))
- [elpa] master 77abf00 25/57: ivy.el (ivy-backward-kill-word): Add and bind to "M-DEL", (continued)
- [elpa] master 77abf00 25/57: ivy.el (ivy-backward-kill-word): Add and bind to "M-DEL", Oleh Krehel, 2015/05/19
- [elpa] master 8c936bc 21/57: ivy.el (ivy-use-virtual-buffers): New defcustom, Oleh Krehel, 2015/05/19
- [elpa] master 9b9885d 33/57: ivy.el (ivy-partial-or-done): Fixup, Oleh Krehel, 2015/05/19
- [elpa] master d841418 24/57: Fix the transition from a bad regex to good one, Oleh Krehel, 2015/05/19
- [elpa] master 2ad5fb1 20/57: Add support for virtual buffers, Oleh Krehel, 2015/05/19
- [elpa] master f97622d 30/57: swiper.el (swiper-font-lock-ensure): Ignore fundamental-mode, Oleh Krehel, 2015/05/19
- [elpa] master 6d4f2b3 34/57: Fix the error switching to non-existent buffers, Oleh Krehel, 2015/05/19
- [elpa] master 16eb4a2 31/57: When completing file names, defer to `minibuffer-complete' for "TAB", Oleh Krehel, 2015/05/19
- [elpa] master b63c358 35/57: Properly update virtual buffers for "^ " interaction, Oleh Krehel, 2015/05/19
- [elpa] master d8f79fa 43/57: ivy.el (ivy-partial-or-done): Update doc, Oleh Krehel, 2015/05/19
- [elpa] master ce0efb3 29/57: Allow to customize the minibuffer formatter,
Oleh Krehel <=
- [elpa] master 9a2083a 27/57: Swiper should use the :re-builder argument, Oleh Krehel, 2015/05/19
- [elpa] master d8c2ef3 45/57: ivy.el (ivy-partial-or-done): More predictability, Oleh Krehel, 2015/05/19
- [elpa] master e05e3b7 39/57: ivy.el (ivy-read): Keep the last ivy--index for :dynamic-collection, Oleh Krehel, 2015/05/19
- [elpa] master 1cdb6ed 32/57: ivy.el (ivy-partial-or-done): Fixup, Oleh Krehel, 2015/05/19
- [elpa] master 5f2cf0c 28/57: Update test, Oleh Krehel, 2015/05/19
- [elpa] master 6405cb3 42/57: ivy.el (ivy-partial-or-done): Always forward to `ivy-alt-done', Oleh Krehel, 2015/05/19
- [elpa] master 10f9954 50/57: counsel.el (counsel-git-grep): Warn if not in a repository, Oleh Krehel, 2015/05/19
- [elpa] master 2cedcf5 37/57: Introduce :matcher for counsel-git-grep, Oleh Krehel, 2015/05/19
- [elpa] master 93faef3 41/57: ivy.el (ivy-delete-char): Add and bind to "C-d", Oleh Krehel, 2015/05/19
- [elpa] master 8630048 47/57: Fixed ivy--preselect-index on windows where the drives folders ends with a backslash (C:\, D:\), Oleh Krehel, 2015/05/19