branch: master commit 8b07572789fc6f35c92ec5b7707c817e40bbe0dd Author: Oleh Krehel <ohwoeo...@gmail.com> Commit: Oleh Krehel <ohwoeo...@gmail.com>
ivy.el (ivy-configure): Add :display-transformer-fn --- counsel.el | 44 +++++++++++++++++++++----------------------- ivy.el | 24 +++++++++++------------- 2 files changed, 32 insertions(+), 36 deletions(-) diff --git a/counsel.el b/counsel.el index 713166b..3c09384 100644 --- a/counsel.el +++ b/counsel.el @@ -544,9 +544,6 @@ Used by commands `counsel-describe-variable' and (ivy-append-face var 'ivy-highlight-face) var)) -(ivy-set-display-transformer - 'counsel-describe-variable 'counsel-describe-variable-transformer) - ;;;###autoload (defun counsel-describe-variable () "Forward to `describe-variable'. @@ -567,7 +564,8 @@ Variables declared using `defcustom' are highlighted according to :caller 'counsel-describe-variable))) (ivy-configure 'counsel-describe-variable - :initial-input "^") + :initial-input "^" + :display-transformer-fn #'counsel-describe-variable-transformer) ;;** `counsel-describe-function' (ivy-set-actions @@ -585,9 +583,6 @@ Variables declared using `defcustom' are highlighted according to (ivy-append-face function-name 'ivy-highlight-face) function-name)) -(ivy-set-display-transformer - 'counsel-describe-function 'counsel-describe-function-transformer) - (defun ivy-function-called-at-point () (let ((f (function-called-at-point))) (and f (symbol-name f)))) @@ -620,7 +615,8 @@ to `ivy-highlight-face'." :caller 'counsel-describe-function))) (ivy-configure 'counsel-describe-function - :initial-input "^") + :initial-input "^" + :display-transformer-fn #'counsel-describe-function-transformer) ;;** `counsel-set-variable' (defvar counsel-set-variable-history nil @@ -928,17 +924,14 @@ when available, in that order of precedence." :caller 'counsel-M-x))) (ivy-configure 'counsel-M-x - :initial-input "^") + :initial-input "^" + :display-transformer-fn #'counsel-M-x-transformer) (ivy-set-actions 'counsel-M-x `(("d" counsel--find-symbol "definition") ("h" ,(lambda (x) (funcall counsel-describe-function-function (intern x))) "help"))) -(ivy-set-display-transformer - 'counsel-M-x - 'counsel-M-x-transformer) - ;;** `counsel-command-history' (defun counsel-command-history-action-eval (cmd) "Eval the command CMD." @@ -1335,7 +1328,6 @@ INITIAL-INPUT can be given as the initial minibuffer input." map)) (counsel-set-async-exit-code 'counsel-git-grep 1 "No matches found") -(ivy-set-display-transformer 'counsel-git-grep 'counsel-git-grep-transformer) (defvar counsel-git-grep-cmd-default "git --no-pager grep --full-name -n --no-color -i -I -e \"%s\"" "Initial command for `counsel-git-grep'.") @@ -1521,7 +1513,8 @@ When CMD is non-nil, prompt for a specific \"git grep\" command." (ivy-configure 'counsel-git-grep :occur #'counsel-git-grep-occur :unwind-fn #'counsel--grep-unwind - :index-fn #'ivy-recompute-index-swiper-async) + :index-fn #'ivy-recompute-index-swiper-async + :display-transformer-fn #'counsel-git-grep-transformer) (cl-pushnew 'counsel-git-grep ivy-highlight-grep-commands) @@ -1985,7 +1978,8 @@ When INITIAL-INPUT is non-nil, use it in the minibuffer during completion." 'counsel-find-file)) (ivy-configure 'counsel-find-file - :occur #'counsel-find-file-occur) + :occur #'counsel-find-file-occur + :display-transformer-fn #'ivy-read-file-transformer) (defvar counsel-find-file-occur-cmd "ls -a | %s | xargs -d '\\n' ls -d --group-directories-first" "Format string for `counsel-find-file-occur'.") @@ -2210,6 +2204,9 @@ When INITIAL-INPUT is non-nil, use it in the minibuffer during completion." (lambda (d) (dired (expand-file-name d))) 'counsel-dired)) +(ivy-configure 'counsel-dired + :display-transformer-fn #'ivy-read-file-transformer) + ;;** `counsel-recentf' (defvar recentf-list) (declare-function recentf-mode "recentf") @@ -2260,6 +2257,9 @@ When INITIAL-INPUT is non-nil, use it in the minibuffer during completion." :require-match t :caller 'counsel-buffer-or-recentf)) +(ivy-configure 'counsel-buffer-or-recentf + :display-transformer-fn #'counsel-buffer-or-recentf-transformer) + (ivy-set-actions 'counsel-buffer-or-recentf '(("j" find-file-other-window "other window") @@ -2272,9 +2272,6 @@ When INITIAL-INPUT is non-nil, use it in the minibuffer during completion." (ivy-append-face var 'ivy-highlight-face) var)) -(ivy-set-display-transformer - 'counsel-buffer-or-recentf 'counsel-buffer-or-recentf-transformer) - ;;** `counsel-bookmark' (defcustom counsel-bookmark-avoid-dired nil "If non-nil, open directory bookmarks with `counsel-find-file'. @@ -2756,7 +2753,6 @@ regex string." (defvar counsel--regex-look-around nil) (counsel-set-async-exit-code 'counsel-ag 1 "No matches found") -(ivy-set-display-transformer 'counsel-ag 'counsel-git-grep-transformer) (defconst counsel--command-args-separator "-- ") @@ -2852,7 +2848,8 @@ CALLER is passed to `ivy-read'." (ivy-configure 'counsel-ag :occur #'counsel-ag-occur - :unwind-fn #'counsel--grep-unwind) + :unwind-fn #'counsel--grep-unwind + :display-transformer-fn #'counsel-git-grep-transformer) (defun counsel-cd () "Change the directory for the currently running Ivy grep-like command. @@ -2945,7 +2942,6 @@ Note: don't use single quotes for the regex." :type 'string) (counsel-set-async-exit-code 'counsel-rg 1 "No matches found") -(ivy-set-display-transformer 'counsel-rg 'counsel-git-grep-transformer) (defun counsel--rg-targets () "Return a list of files to operate on, based on `dired-mode' marks." @@ -2987,7 +2983,9 @@ Example input with inclusion and exclusion file patterns: (ivy-configure 'counsel-rg :occur #'counsel-ag-occur - :unwind-fn #'counsel--grep-unwind) + :unwind-fn #'counsel--grep-unwind + :display-transformer-fn #'counsel-git-grep-transformer) + (cl-pushnew 'counsel-rg ivy-highlight-grep-commands) ;;** `counsel-grep' diff --git a/ivy.el b/ivy.el index 07eaf0d..247e5b2 100644 --- a/ivy.el +++ b/ivy.el @@ -1918,6 +1918,7 @@ May supersede `ivy-initial-inputs-alist'." update-fn unwind-fn index-fn + display-transformer-fn more-chars) "Configure `ivy-read' params for CALLER." (declare (indent 1)) @@ -1931,6 +1932,8 @@ May supersede `ivy-initial-inputs-alist'." (ivy--alist-set 'ivy-unwind-fns-alist caller unwind-fn)) (when index-fn (ivy--alist-set 'ivy-index-functions-alist caller index-fn)) + (when display-transformer-fn + (ivy-set-display-transformer caller display-transformer-fn)) (when more-chars (ivy--alist-set 'ivy-more-chars-alist caller more-chars))) @@ -3875,13 +3878,6 @@ Note: The usual last two arguments are flipped for convenience.") olen (length str) 'ivy-completions-annotations str)) str)) -(ivy-set-display-transformer - 'counsel-find-file 'ivy-read-file-transformer) -(ivy-set-display-transformer - 'counsel-dired 'ivy-read-file-transformer) -(ivy-set-display-transformer - 'read-file-name-internal 'ivy-read-file-transformer) - (defun ivy-read-file-transformer (str) "Transform candidate STR when reading files." (if (ivy--dirname-p str) @@ -4318,11 +4314,6 @@ Skip buffers that match `ivy-ignore-buffers'." (and (eq ivy-use-ignore t) res))))) -(ivy-set-display-transformer - 'ivy-switch-buffer 'ivy-switch-buffer-transformer) -(ivy-set-display-transformer - 'internal-complete-buffer 'ivy-switch-buffer-transformer) - (defun ivy-append-face (str face) "Append to STR the property FACE." (setq str (copy-sequence str)) @@ -4364,7 +4355,8 @@ Skip buffers that match `ivy-ignore-buffers'." :caller 'ivy-switch-buffer)) (ivy-configure 'ivy-switch-buffer - :occur #'ivy-switch-buffer-occur) + :occur #'ivy-switch-buffer-occur + :display-transformer-fn #'ivy-switch-buffer-transformer) ;;;###autoload (defun ivy-switch-view () @@ -5057,6 +5049,12 @@ make decisions based on the whole marked list." (require 'ffap) (funcall ffap-url-fetcher url)) +(ivy-configure 'read-file-name-internal + :display-transformer-fn #'ivy-read-file-transformer) + +(ivy-configure 'internal-complete-buffer + :display-transformer-fn #'ivy-switch-buffer-transformer) + (provide 'ivy) ;;; ivy.el ends here