[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 3c098bd 5/8: The :action parameter to ivy-read should take
From: |
Oleh Krehel |
Subject: |
[elpa] master 3c098bd 5/8: The :action parameter to ivy-read should take one arg |
Date: |
Sat, 23 May 2015 11:31:03 +0000 |
branch: master
commit 3c098bd91f3f0bdd5cd20313490f83c41f9c0774
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
The :action parameter to ivy-read should take one arg
* ivy.el (ivy-next-line-and-call): Update.
(ivy-previous-line-and-call): Update.
(ivy-read): Update.
(ivy--switch-buffer-action): Update.
* swiper.el (swiper-query-replace): Update.
* counsel.el (counsel--find-symbol): Update.
(counsel-describe-variable): Update.
(counsel-describe-function): Update.
(counsel-git): Update.
(counsel-git-grep-action): Update.
---
counsel.el | 42 ++++++++++++++++++++++--------------------
ivy.el | 26 ++++++++++++++------------
swiper.el | 2 +-
3 files changed, 37 insertions(+), 33 deletions(-)
diff --git a/counsel.el b/counsel.el
index fb831ae..c59e5cd 100644
--- a/counsel.el
+++ b/counsel.el
@@ -51,11 +51,12 @@
(ivy-set-action 'counsel--find-symbol)
(ivy-done))
-(defun counsel--find-symbol ()
- (let ((full-name (get-text-property 0 'full-name ivy--current)))
+(defun counsel--find-symbol (x)
+ "Find symbol definition that corresponds to string X."
+ (let ((full-name (get-text-property 0 'full-name x)))
(if full-name
(find-library full-name)
- (let ((sym (read ivy--current)))
+ (let ((sym (read x)))
(cond ((boundp sym)
(find-variable sym))
((fboundp sym)
@@ -90,9 +91,9 @@
:history 'counsel-describe-symbol-history
:require-match t
:sort t
- :action (lambda ()
+ :action (lambda (x)
(describe-variable
- (intern ivy--current))))))
+ (intern x))))))
(defun counsel-describe-function ()
"Forward to `describe-function'."
@@ -110,9 +111,9 @@
:history 'counsel-describe-symbol-history
:require-match t
:sort t
- :action (lambda ()
+ :action (lambda (x)
(describe-function
- (intern ivy--current))))))
+ (intern x))))))
(defvar info-lookup-mode)
(declare-function info-lookup->completions "info-look")
@@ -167,15 +168,16 @@
(defun counsel-git ()
"Find file in the current Git repository."
(interactive)
- (ivy-read "Find file: "
- (let ((default-directory (locate-dominating-file
- default-directory ".git")))
- (split-string
- (shell-command-to-string
- "git ls-files --full-name --")
- "\n"
- t))
- :action (lambda () (find-file ivy--current))))
+ (let* ((default-directory (locate-dominating-file
+ default-directory ".git"))
+ (cands (split-string
+ (shell-command-to-string
+ "git ls-files --full-name --")
+ "\n"
+ t))
+ (action (lambda (x) (find-file x))))
+ (ivy-read "Find file: " cands
+ :action action)))
(defvar counsel--git-grep-dir nil
"Store the base git directory.")
@@ -222,8 +224,8 @@
(counsel-git-grep-action)
(recenter-top-bottom)))
-(defun counsel-git-grep-action ()
- (let ((lst (split-string ivy--current ":")))
+(defun counsel-git-grep-action (x)
+ (let ((lst (split-string x ":")))
(find-file (expand-file-name (car lst) counsel--git-grep-dir))
(goto-char (point-min))
(forward-line (1- (string-to-number (cadr lst))))
@@ -352,9 +354,9 @@ The libraries are offered from `load-path'."
dir) cands)))))))
(maphash (lambda (_k v) (push (car v) res)) cands)
(ivy-read "Load library: " (nreverse res)
- :action (lambda ()
+ :action (lambda (x)
(load-library
- (get-text-property 0 'full-name ivy--current)))
+ (get-text-property 0 'full-name x)))
:keymap counsel-describe-map)))
(provide 'counsel)
diff --git a/ivy.el b/ivy.el
index c36d622..8a54fd2 100644
--- a/ivy.el
+++ b/ivy.el
@@ -330,7 +330,7 @@ If the text hasn't changed as a result, forward to
`ivy-alt-done'."
(mapcar (lambda (str) (substring str
(string-match postfix str)))
ivy--old-cands))))
(cond ((eq new t) nil)
- ((string= new ivy-text) nil)
+ ((string= new ivy-text) nil)
(new
(delete-region (minibuffer-prompt-end) (point-max))
(setcar (last parts) new)
@@ -432,7 +432,7 @@ Call the permanent action if possible."
(ivy--exhibit)
(when (ivy-state-action ivy-last)
(with-selected-window (ivy-state-window ivy-last)
- (funcall (ivy-state-action ivy-last)))))
+ (funcall (ivy-state-action ivy-last) ivy--current))))
(defun ivy-previous-line-and-call (&optional arg)
"Move cursor vertically down ARG candidates.
@@ -442,7 +442,7 @@ Call the permanent action if possible."
(ivy--exhibit)
(when (ivy-state-action ivy-last)
(with-selected-window (ivy-state-window ivy-last)
- (funcall (ivy-state-action ivy-last)))))
+ (funcall (ivy-state-action ivy-last) ivy--current))))
(defun ivy-previous-history-element (arg)
"Forward to `previous-history-element' with ARG."
@@ -623,7 +623,8 @@ UPDATE-FN is called each time the current candidate(s) is
changed.
When SORT is t, refer to `ivy-sort-functions-alist' for sorting.
-ACTION is a lambda to call after a result was selected.
+ACTION is a lambda to call after a result was selected. It should
+take a single argument, usually a string.
UNWIND is a lambda to call before exiting.
@@ -750,7 +751,7 @@ candidates with each input."
(when (setq unwind (ivy-state-unwind ivy-last))
(funcall unwind)))
(when (setq action (ivy-state-action ivy-last))
- (funcall action)))))
+ (funcall action ivy--current)))))
(defun ivy-completing-read (prompt collection
&optional predicate require-match initial-input
@@ -1233,16 +1234,17 @@ When VIRTUAL is non-nil, add virtual buffers."
(and virtual
(ivy--virtual-buffers)))))
-(defun ivy--switch-buffer-action ()
- "Finalizer for `ivy-switch-buffer'."
- (if (zerop (length ivy--current))
+(defun ivy--switch-buffer-action (buffer)
+ "Switch to BUFFER.
+BUFFER may be a string or nil."
+ (if (zerop (length buffer))
(switch-to-buffer
ivy-text nil 'force-same-window)
- (let ((virtual (assoc ivy--current ivy--virtual-buffers)))
+ (let ((virtual (assoc buffer ivy--virtual-buffers)))
(if virtual
(find-file (cdr virtual))
(switch-to-buffer
- ivy--current nil 'force-same-window)))))
+ buffer nil 'force-same-window)))))
(defun ivy-switch-buffer ()
"Switch to another buffer."
@@ -1250,8 +1252,8 @@ When VIRTUAL is non-nil, add virtual buffers."
(if (not ivy-mode)
(call-interactively 'switch-to-buffer)
(ivy-read "Switch to buffer: " 'internal-complete-buffer
- :action #'ivy--switch-buffer-action
- :preselect (buffer-name (other-buffer (current-buffer))))))
+ :preselect (buffer-name (other-buffer (current-buffer)))
+ :action #'ivy--switch-buffer-action)))
(provide 'ivy)
diff --git a/swiper.el b/swiper.el
index 7955817..ab1d022 100644
--- a/swiper.el
+++ b/swiper.el
@@ -95,7 +95,7 @@
(from (ivy--regex ivy-text))
(to (query-replace-read-to from "Query replace" t)))
(delete-minibuffer-contents)
- (ivy-set-action (lambda ()
+ (ivy-set-action (lambda (_)
(with-selected-window swiper--window
(perform-replace from to
t t nil))))
- [elpa] master updated (08e02f3 -> 740b7e6), Oleh Krehel, 2015/05/23
- [elpa] master 4b505da 2/8: ivy.el (ivy-completing-read): Check for a cons initial-input, Oleh Krehel, 2015/05/23
- [elpa] master c19c5ed 3/8: counsel.el (counsel-git): Switch to action-style call, Oleh Krehel, 2015/05/23
- [elpa] master 57ca591 1/8: * swiper/ivy.el: Clean up regexps and pseudo-closures, Oleh Krehel, 2015/05/23
- [elpa] master 69491ad 4/8: Fixup "C-u C-j" for `ivy-switch-buffer', Oleh Krehel, 2015/05/23
- [elpa] master 9e5e52b 6/8: README.md: Add a secion on Ivy, Oleh Krehel, 2015/05/23
- [elpa] master 3c098bd 5/8: The :action parameter to ivy-read should take one arg,
Oleh Krehel <=
- [elpa] master e084b5d 7/8: swiper.el: Bump version, Oleh Krehel, 2015/05/23
- [elpa] master 740b7e6 8/8: Merge commit 'e084b5d9feab3dd1246e51ce1fddde3db6024f7d' from swiper, Oleh Krehel, 2015/05/23