[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 9bd79da 074/348: ivy.el (ivy-set-prompt): New API
From: |
Oleh Krehel |
Subject: |
[elpa] master 9bd79da 074/348: ivy.el (ivy-set-prompt): New API |
Date: |
Sat, 8 Apr 2017 11:03:29 -0400 (EDT) |
branch: master
commit 9bd79da7d9f9cac95342d729ca2f2348fde20825
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
ivy.el (ivy-set-prompt): New API
* ivy.el (ivy-prompt): Called to possibly update the prompt in
`post-command-hook'.
* counsel.el (counsel-prompt-function): Mark as obsolete. Will be
removed after a few months.
(counsel-prompt-function-default): Change from 1 arg to 0 args.
(counsel-prompt-function-dir): Change from 1 arg to 0 args.
(counsel-git):
(counsel-git-grep):
(counsel-ag): Use `ivy-set-prompt'.
* Makefile: New target "obsolete". Used to check if obsolete warnings
work properly for the current obsolete variables.
* targets/obsolete-config.el: Used in conjunction with "make obsolete".
Re #424
---
Makefile | 3 +++
counsel.el | 46 +++++++++++++++++++++++++---------------------
ivy.el | 17 ++++++++++++++++-
targets/obsolete-config.el | 4 ++++
4 files changed, 48 insertions(+), 22 deletions(-)
diff --git a/Makefile b/Makefile
index ca1d043..649949e 100644
--- a/Makefile
+++ b/Makefile
@@ -13,6 +13,9 @@ compile:
plain:
$(emacs) -Q $(LOAD) --eval "(progn (package-initialize) (ivy-mode))" -l
ivy-hydra.el
+obsolete:
+ $(emacs) -batch -l targets/obsolete-config.el
+
clean:
rm -f *.elc
diff --git a/counsel.el b/counsel.el
index 3f7396a..be8d9bf 100644
--- a/counsel.el
+++ b/counsel.el
@@ -203,9 +203,14 @@ Update the minibuffer with the amount of lines collected
every
(function :tag "Custom"))
:group 'ivy)
-(defun counsel-prompt-function-default (prompt)
- "Return PROMPT appended with a semicolon."
- (format "%s: " prompt))
+(make-obsolete-variable
+ 'counsel-prompt-function
+ "Use `ivy-set-prompt' instead"
+ "0.8.0 <2016-06-20 Mon>")
+
+(defun counsel-prompt-function-default ()
+ "Return prompt appended with a semicolon."
+ (format "%s: " (ivy-state-prompt ivy-last)))
(defun counsel-delete-process ()
(let ((process (get-process " *counsel*")))
@@ -832,6 +837,7 @@ Describe the selected candidate."
(interactive)
(setq counsel--git-dir (locate-dominating-file
default-directory ".git"))
+ (ivy-set-prompt 'counsel-git counsel-prompt-function)
(if (null counsel--git-dir)
(error "Not in a git repository")
(setq counsel--git-dir (expand-file-name
@@ -842,8 +848,7 @@ Describe the selected candidate."
"git ls-files --full-name --")
"\n"
t)))
- (ivy-read (funcall counsel-prompt-function "Find file")
- cands
+ (ivy-read "Find file" cands
:action #'counsel-git-action))))
(defun counsel-git-action (x)
@@ -881,11 +886,11 @@ Describe the selected candidate."
'("git --no-pager grep --full-name -n --no-color -i -e %S")
"History for `counsel-git-grep' shell commands.")
-(defun counsel-prompt-function-dir (prompt)
- "Return PROMPT appended with the parent directory."
+(defun counsel-prompt-function-dir ()
+ "Return prompt appended with the parent directory."
(let ((directory counsel--git-grep-dir))
(format "%s [%s]: "
- prompt
+ (ivy-state-prompt ivy-last)
(let ((dir-list (eshell-split-path directory)))
(if (> (length dir-list) 3)
(apply #'concat
@@ -963,6 +968,7 @@ When CMD is a string, use it as a \"git grep\" command.
When CMD is non-nil, prompt for a specific \"git grep\" command.
INITIAL-INPUT can be given as the initial minibuffer input."
(interactive "P")
+ (ivy-set-prompt 'counsel-git-grep counsel-prompt-function)
(cond
((stringp cmd)
(setq counsel-git-grep-cmd cmd))
@@ -979,17 +985,15 @@ INITIAL-INPUT can be given as the initial minibuffer
input."
(if (null counsel--git-grep-dir)
(error "Not in a git repository")
(setq counsel--git-grep-count (counsel--gg-count "" t))
- (ivy-read
- (funcall counsel-prompt-function "git grep")
- 'counsel-git-grep-function
- :initial-input initial-input
- :matcher #'counsel-git-grep-matcher
- :dynamic-collection (> counsel--git-grep-count 20000)
- :keymap counsel-git-grep-map
- :action #'counsel-git-grep-action
- :unwind #'swiper--cleanup
- :history 'counsel-git-grep-history
- :caller 'counsel-git-grep)))
+ (ivy-read "git grep" 'counsel-git-grep-function
+ :initial-input initial-input
+ :matcher #'counsel-git-grep-matcher
+ :dynamic-collection (> counsel--git-grep-count 20000)
+ :keymap counsel-git-grep-map
+ :action #'counsel-git-grep-action
+ :unwind #'swiper--cleanup
+ :history 'counsel-git-grep-history
+ :caller 'counsel-git-grep)))
(defun counsel-git-grep-switch-cmd ()
"Set `counsel-git-grep-cmd' to a different value."
@@ -1441,9 +1445,9 @@ INITIAL-INPUT can be given as the initial minibuffer
input."
(read-directory-name (concat
(car (split-string counsel-ag-base-command))
" in directory: ")))))
+ (ivy-set-prompt 'counsel-ag counsel-prompt-function)
(setq counsel--git-grep-dir (or initial-directory default-directory))
- (ivy-read (funcall counsel-prompt-function
- (car (split-string counsel-ag-base-command)))
+ (ivy-read (car (split-string counsel-ag-base-command))
'counsel-ag-function
:initial-input initial-input
:dynamic-collection t
diff --git a/ivy.el b/ivy.el
index 6c067b3..49b4db5 100644
--- a/ivy.el
+++ b/ivy.el
@@ -186,6 +186,14 @@ Only \"./\" and \"../\" apply here. They appear in reverse
order."
actions
(plist-get ivy--actions-list cmd))))))
+(defvar ivy--prompts-list nil)
+
+(defun ivy-set-prompt (caller prompt-fn)
+ "Associate CALLER with PROMPT-FN.
+PROMPT-FN is a function of no arguments that returns a prompt string."
+ (setq ivy--prompts-list
+ (plist-put ivy--prompts-list caller prompt-fn)))
+
(defvar ivy--display-transformers-list nil
"A list of str->str transformers per command.")
@@ -1975,9 +1983,16 @@ The returned value should be the updated PROMPT.")
`(face ivy-match-required-face ,@std-props))
prompt)
+(defun ivy-prompt ()
+ "Return the current prompt."
+ (let ((fn (plist-get ivy--prompts-list (ivy-state-caller ivy-last))))
+ (if fn
+ (funcall fn)
+ ivy--prompt)))
+
(defun ivy--insert-prompt ()
"Update the prompt according to `ivy--prompt'."
- (when ivy--prompt
+ (when (setq ivy--prompt (ivy-prompt))
(unless (memq this-command '(ivy-done ivy-alt-done ivy-partial-or-done
counsel-find-symbol))
(setq ivy--prompt-extra ""))
diff --git a/targets/obsolete-config.el b/targets/obsolete-config.el
new file mode 100644
index 0000000..8d79b70
--- /dev/null
+++ b/targets/obsolete-config.el
@@ -0,0 +1,4 @@
+(add-to-list 'load-path default-directory)
+(require 'counsel)
+(setq counsel-prompt-function 'counsel-prompt-function-default)
+(byte-compile-file (expand-file-name "targets/obsolete-config.el"))
- [elpa] master 23bd7a4 075/348: counsel.el (counsel-git): Add :caller, (continued)
- [elpa] master 23bd7a4 075/348: counsel.el (counsel-git): Add :caller, Oleh Krehel, 2017/04/08
- [elpa] master 74358c2 070/348: Purge all dependency on helm-rhythmbox, Oleh Krehel, 2017/04/08
- [elpa] master 56aa605 076/348: ivy.el (ivy-add-prompt-count): Refactor from ivy--reset-state, Oleh Krehel, 2017/04/08
- [elpa] master 9c01abf 003/348: doc/Changelog.org: Add hlines, Oleh Krehel, 2017/04/08
- [elpa] master e53f256 087/348: ivy.el (ivy-minibuffer-map): Move ivy-toggle-regexp-quote from "M-q" to "M-r", Oleh Krehel, 2017/04/08
- [elpa] master af5f097 108/348: counsel.el (counsel-locate-action-extern): Make interactive, Oleh Krehel, 2017/04/08
- [elpa] master 0028c8c 106/348: counsel.el (counsel-outline): New command, Oleh Krehel, 2017/04/08
- [elpa] master 1d8b4f8 110/348: ivy.el (ivy-sort-matches-functions-alist): New sorting for ivy-switch-buffer, Oleh Krehel, 2017/04/08
- [elpa] master 027fbac 114/348: swiper.el (swiper-multi-action-2): Fix swiper-all, Oleh Krehel, 2017/04/08
- [elpa] master d6cf677 077/348: ivy.el (ivy-prompt): Add warning, Oleh Krehel, 2017/04/08
- [elpa] master 9bd79da 074/348: ivy.el (ivy-set-prompt): New API,
Oleh Krehel <=
- [elpa] master 72dcca5 082/348: ivy.el (ivy-push-view): Work properly for dired-mode, Oleh Krehel, 2017/04/08
- [elpa] master 3d7e1ef 083/348: ivy.el (ivy--switch-buffer-action): Improve, Oleh Krehel, 2017/04/08
- [elpa] master 055e7b8 102/348: counsel.el (counsel-git-grep-cmd-history): Update default, Oleh Krehel, 2017/04/08
- [elpa] master 7e188d5 100/348: counsel.el (counsel-git-grep): Customize re-builder, Oleh Krehel, 2017/04/08
- [elpa] master 1da8b6c 086/348: Fix foo!bar syntax for swiper, Oleh Krehel, 2017/04/08
- [elpa] master 57c0f5e 095/348: ivy.el (ivy-set-view-recur): Account for mulitple same kind splits, Oleh Krehel, 2017/04/08
- [elpa] master c84b681 109/348: ivy.el (ivy-switch-buffer): Reset index to 0 on input, Oleh Krehel, 2017/04/08
- [elpa] master 0f4acb3 115/348: Make swiper-all async, Oleh Krehel, 2017/04/08
- [elpa] master 81e14ce 111/348: counsel.el (counsel-semantic): Fix warnings, Oleh Krehel, 2017/04/08
- [elpa] master 9e87993 113/348: ivy.el (ivy-state): directory field stores default-directory, Oleh Krehel, 2017/04/08