[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master cdca2fc 141/184: counsel.el (counsel-switch-buffer): Re-us
From: |
Oleh Krehel |
Subject: |
[elpa] master cdca2fc 141/184: counsel.el (counsel-switch-buffer): Re-use ivy-switch-buffer |
Date: |
Wed, 16 Oct 2019 13:15:10 -0400 (EDT) |
branch: master
commit cdca2fcd8ee8397d6dee6dd141f3a9d46064d25b
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
counsel.el (counsel-switch-buffer): Re-use ivy-switch-buffer
* ivy.el (ivy-unwind-fns-alist): New defvar.
Reduce code duplication by having `counsel-switch-buffer' become a
customized `ivy-switch-buffer'.
Re #1895
---
counsel.el | 29 ++++++++++-------------------
ivy.el | 23 +++++++++++++++--------
2 files changed, 25 insertions(+), 27 deletions(-)
diff --git a/counsel.el b/counsel.el
index 12e30e4..a73fa03 100644
--- a/counsel.el
+++ b/counsel.el
@@ -5507,16 +5507,11 @@ The buffers are those opened during a session of
`counsel-switch-buffer'."
Display a preview of the selected ivy completion candidate buffer
in the current window."
(interactive)
- (ivy-read "Switch to buffer: " 'internal-complete-buffer
- :preselect (buffer-name (other-buffer (current-buffer)))
- :keymap ivy-switch-buffer-map
- :action #'ivy--switch-buffer-action
- :matcher #'ivy--switch-buffer-matcher
- :unwind #'counsel--switch-buffer-unwind
- :caller 'counsel-switch-buffer))
-
-(ivy-configure 'counsel-switch-buffer
- :update-fn #'counsel--switch-buffer-update-fn)
+ (let ((ivy-update-fns-alist
+ '((ivy-switch-buffer . counsel--switch-buffer-update-fn)))
+ (ivy-unwind-fns-alist
+ '((ivy-switch-buffer . counsel--switch-buffer-unwind))))
+ (ivy-switch-buffer)))
;;;###autoload
(defun counsel-switch-buffer-other-window ()
@@ -5524,15 +5519,11 @@ in the current window."
Display a preview of the selected ivy completion candidate buffer
in the current window."
(interactive)
- (ivy-read "Switch to buffer in other window: " 'internal-complete-buffer
- :preselect (buffer-name (other-buffer (current-buffer)))
- :action #'ivy--switch-buffer-other-window-action
- :matcher #'ivy--switch-buffer-matcher
- :unwind #'counsel--switch-buffer-unwind
- :caller 'counsel-switch-buffer-other-window))
-
-(ivy-configure 'counsel-switch-buffer-other-window
- :update-fn #'counsel--switch-buffer-update-fn)
+ (let ((ivy-update-fns-alist
+ '((ivy-switch-buffer-other-window .
counsel--switch-buffer-update-fn)))
+ (ivy-unwind-fns-alist
+ '((ivy-switch-buffer-other-window . counsel--switch-buffer-unwind))))
+ (ivy-switch-buffer-other-window)))
(defun counsel-open-buffer-file-externally (buffer)
"Open the file associated with BUFFER with an external program."
diff --git a/ivy.el b/ivy.el
index f846610..bf5bdaf 100644
--- a/ivy.el
+++ b/ivy.el
@@ -1888,6 +1888,14 @@ Examples: `toggle-input-method', (lambda () (insert
\"^\")), etc.
May supersede `ivy-initial-inputs-alist'."
:type '(alist :key-type symbol :value-type function))
+(defvar ivy--occurs-list nil
+ "A list of custom occur generators per command.")
+
+(defun ivy-set-occur (cmd occur)
+ "Assign CMD a custom OCCUR function."
+ (setq ivy--occurs-list
+ (plist-put ivy--occurs-list cmd occur)))
+
(defcustom ivy-update-fns-alist nil
"An alist associating commands to their :update-fn values."
:type '(alist
@@ -1897,11 +1905,15 @@ May supersede `ivy-initial-inputs-alist'."
(const :tag "Off" nil)
(const :tag "Call action on change" auto))))
+(defvar ivy-unwind-fns-alist nil
+ "An alist associating commands to their :unwind values.")
+
(cl-defun ivy-configure (caller
&key
initial-input
occur
update-fn
+ unwind-fn
more-chars)
"Configure `ivy-read' params for CALLER."
(declare (indent 1))
@@ -1911,6 +1923,8 @@ May supersede `ivy-initial-inputs-alist'."
(ivy-set-occur caller occur))
(when update-fn
(setf (alist-get caller ivy-update-fns-alist) update-fn))
+ (when unwind-fn
+ (setf (alist-get caller ivy-unwind-fns-alist) unwind-fn))
(when more-chars
(setf (alist-get caller ivy-more-chars-alist) more-chars)))
@@ -2051,6 +2065,7 @@ customizations apply to the current completion session."
(ivy-alist-setting ivy-display-functions-alist caller)))
result)
(setq update-fn (or update-fn (ivy-alist-setting ivy-update-fns-alist
caller)))
+ (setq unwind (or unwind (ivy-alist-setting ivy-unwind-fns-alist caller)))
(setq ivy-last
(make-ivy-state
:prompt prompt
@@ -4724,14 +4739,6 @@ When `ivy-calling' isn't nil, call `ivy-occur-press'."
(when (fboundp 'wgrep-setup)
(wgrep-setup)))
-(defvar ivy--occurs-list nil
- "A list of custom occur generators per command.")
-
-(defun ivy-set-occur (cmd occur)
- "Assign CMD a custom OCCUR function."
- (setq ivy--occurs-list
- (plist-put ivy--occurs-list cmd occur)))
-
(defun ivy--starts-with-dotslash (str)
(string-match-p "\\`\\.[/\\]" str))
- [elpa] master 2d840b8 157/184: ivy.el (ivy-configure): Add :sort-fn, (continued)
- [elpa] master 2d840b8 157/184: ivy.el (ivy-configure): Add :sort-fn, Oleh Krehel, 2019/10/16
- [elpa] master f0451db 173/184: ivy.el (ivy-occur-revert-buffer): Don't error if the swiper buffer was killed, Oleh Krehel, 2019/10/16
- [elpa] master 3bd1d87 182/184: counsel.el (counsel-locate-cmd-es): Encode command to local codepage, Oleh Krehel, 2019/10/16
- [elpa] master 8b4693c 169/184: counsel.el (counsel-imenu-action and -get-canditates-from): Revert., Oleh Krehel, 2019/10/16
- [elpa] master 882d6c4 161/184: counsel.el (counsel-imenu): Work with :update-fn 'auto, Oleh Krehel, 2019/10/16
- [elpa] master 1a9002b 168/184: ivy.el: Clean up obsolete aliases, Oleh Krehel, 2019/10/16
- [elpa] master c2d3a4c 184/184: Merge commit 'cd634c6f51458f81898ecf2821ac3169cb65a1eb' from ivy, Oleh Krehel, 2019/10/16
- [elpa] master 12f4771 124/184: ivy.el (ivy-completion-in-region): Add workaround for package-menu-filter, Oleh Krehel, 2019/10/16
- [elpa] master 2b974b4 139/184: ivy.el (ivy-update-fns-alist): New defcustom, Oleh Krehel, 2019/10/16
- [elpa] master 57e0b94 146/184: swiper.el (swiper--action): Set case-fold-search, Oleh Krehel, 2019/10/16
- [elpa] master cdca2fc 141/184: counsel.el (counsel-switch-buffer): Re-use ivy-switch-buffer,
Oleh Krehel <=
- [elpa] master a5701a9 159/184: ivy.el (ivy-configure): Add :format-fn, Oleh Krehel, 2019/10/16
- [elpa] master 4d533b2 178/184: counsel.el (counsel-dired): Filter to directories only, Oleh Krehel, 2019/10/16
- [elpa] master ec1ed07 171/184: counsel.el (counsel--find-file-1): Use dired-current-directory for dired, Oleh Krehel, 2019/10/16
- [elpa] master 1d8803e 181/184: Ensure that ripgrep on windows uses '/' as the path-separator, Oleh Krehel, 2019/10/16
- [elpa] master 7854d03 129/184: counsel.el (counsel-google): Add, Oleh Krehel, 2019/10/16
- [elpa] master cd634c6 183/184: doc/Changelog.org: Release 0.13.0, Oleh Krehel, 2019/10/16
- [elpa] master 0dfd70d 135/184: counsel.el (counsel-google-function): Require json, Oleh Krehel, 2019/10/16
- [elpa] master eed1f06 138/184: counsel.el (counsel--py-action): Don't auto-insert parens, Oleh Krehel, 2019/10/16
- [elpa] master 52295c4 137/184: swiper.el (swiper-isearch): Fix searching for "$^", Oleh Krehel, 2019/10/16
- [elpa] master 80c2669 142/184: ivy.el (ivy--alist-set): Work-around emacs-24.3 not having alist-get, Oleh Krehel, 2019/10/16