`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
(lambda (cmd)
(when (featurep 'smex)
(smex-rank (intern cmd)))
(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
(command-execute (intern cmd) 'record)))
:sort sort
:keymap counsel-describe-map
-(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.
"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."
(defun ivy--truncate-string (str width)
"Truncate STR to WIDTH."
(defun ivy-format-function-default (cands)
"Transform CANDS into a string for 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)
(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)))
+(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")
(defface ivy-minibuffer-match-face-1
'((((class color) (background light))
:background "#d3d3d3")
(setq cands (mapcar
#'ivy--format-minibuffer-line
cands))
(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)
(let* ((ivy--index index)
(res (concat "\n" (funcall ivy-format-function cands))))
(put-text-property 0 (length res) 'read-only nil res)