[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 67224c0 171/272: counsel.el (counsel-prompt-function): New
From: |
Oleh Krehel |
Subject: |
[elpa] master 67224c0 171/272: counsel.el (counsel-prompt-function): New defcustom |
Date: |
Mon, 25 Apr 2016 10:13:23 +0000 |
branch: master
commit 67224c0d68f5ed6228cba5bd5d2e4f4fcdf095be
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
counsel.el (counsel-prompt-function): New defcustom
* counsel.el (counsel-prompt-function-default):
(counsel-prompt-function-dir): New defun.
(counsel-git):
(counsel-git-grep):
(counsel-ag): Update.
To show the root dir:
(setq counsel-prompt-function 'counsel-prompt-function-dir)
Fixes #424
---
counsel.el | 51 ++++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 40 insertions(+), 11 deletions(-)
diff --git a/counsel.el b/counsel.el
index 2c0c480..62d6c1a 100644
--- a/counsel.el
+++ b/counsel.el
@@ -163,6 +163,31 @@ Update the minibuffer with the amount of lines collected
every
(ivy--format ivy--all-candidates)))
(setq counsel--async-time (current-time)))))
+(defcustom counsel-prompt-function 'counsel-prompt-function-default
+ "A function to return a full prompt string from a basic prompt string."
+ :type
+ '(choice
+ (const :tag "Plain" counsel-prompt-function-default)
+ (const :tag "Directory" counsel-prompt-function-dir)
+ (function :tag "Custom")))
+
+(defun counsel-prompt-function-default (prompt)
+ "Return PROMPT appended with a semicolon."
+ (format "%s: " prompt))
+
+(defun counsel-prompt-function-dir (prompt)
+ "Return PROMPT appended with the parent directory."
+ (let ((directory counsel--git-grep-dir))
+ (format " [%s]: "
+ (let ((dir-list (split-string directory "/")))
+ (if (> (length dir-list) 3)
+ (mapconcat
+ #'identity
+ (append '("..")
+ (cl-subseq dir-list (- (length dir-list) 3)))
+ "/")
+ directory)))))
+
(defun counsel-delete-process ()
(let ((process (get-process " *counsel*")))
(when process
@@ -691,7 +716,8 @@ Describe the selected candidate."
"git ls-files --full-name --")
"\n"
t)))
- (ivy-read "Find file: " cands
+ (ivy-read (funcall counsel-prompt-function "Find file")
+ cands
:action #'counsel-git-action)))
(defun counsel-git-action (x)
@@ -812,15 +838,17 @@ 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 "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
+ (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)))
(defun counsel-git-grep-switch-cmd ()
"Set `counsel-git-grep-cmd' to a different value."
@@ -1249,7 +1277,8 @@ command. %S will be replaced by the regex string. The
default is
INITIAL-INPUT can be given as the initial minibuffer input."
(interactive)
(setq counsel--git-grep-dir (or initial-directory default-directory))
- (ivy-read "ag: " 'counsel-ag-function
+ (ivy-read (funcall counsel-prompt-function "ag")
+ 'counsel-ag-function
:initial-input initial-input
:dynamic-collection t
:history 'counsel-git-grep-history
- [elpa] master 96828c2 100/272: ivy.el (ivy-read): Identify extra-actions by caller as well, (continued)
- [elpa] master 96828c2 100/272: ivy.el (ivy-read): Identify extra-actions by caller as well, Oleh Krehel, 2016/04/25
- [elpa] master d425392 178/272: Correctly expand the file name at point, Oleh Krehel, 2016/04/25
- [elpa] master 8201f36 224/272: ivy.el (ivy-occur-revert-buffer): Improve for counsel-git-grep, Oleh Krehel, 2016/04/25
- [elpa] master 20f11b7 159/272: New command ivy-occur-revert-buffer bound to "g", Oleh Krehel, 2016/04/25
- [elpa] master d8da9c4 188/272: counsel.el (counsel-mode): Allow use of describe-prefix-bindings, Oleh Krehel, 2016/04/25
- [elpa] master ab795d0 265/272: Don't highlight that match in the file name part, Oleh Krehel, 2016/04/25
- [elpa] master 255457a 177/272: Fixed counsel-list-processes-action-switch to use correct buffer., Oleh Krehel, 2016/04/25
- [elpa] master 48b5638 129/272: ivy.el (ivy-next-history-element): Don't add symbol bounds for file names, Oleh Krehel, 2016/04/25
- [elpa] master 41dfae6 194/272: ivy.el (ivy--format-function-generic): Fix doc, Oleh Krehel, 2016/04/25
- [elpa] master f0de338 198/272: ivy.el (ivy--directory-done): Fix when ivy-text is a dir, Oleh Krehel, 2016/04/25
- [elpa] master 67224c0 171/272: counsel.el (counsel-prompt-function): New defcustom,
Oleh Krehel <=
- [elpa] master 0c5f68c 183/272: counsel.el (counsel-pt): Add, Oleh Krehel, 2016/04/25
- [elpa] master 692002d 184/272: counsel.el (counsel-pt): Remove unused args, Oleh Krehel, 2016/04/25
- [elpa] master 0bad922 083/272: Provide the :caller in most calls to ivy-read, Oleh Krehel, 2016/04/25
- [elpa] master dabd1f8 205/272: ivy.el (ivy-avy): Make "C-g" cancel gracefully, Oleh Krehel, 2016/04/25
- [elpa] master e8f2064 117/272: Rename counsel-symbol-at-point to ivy-thing-at-point, Oleh Krehel, 2016/04/25
- [elpa] master 8d04638 202/272: counsel.el: Fix breakage due to helm-rhythmbox, Oleh Krehel, 2016/04/25
- [elpa] master 6ae91f7 213/272: Make ivy-set-sources work also for sync completion, Oleh Krehel, 2016/04/25
- [elpa] master f7c7114 037/272: ivy-test.el (ivy--regex-ignore-order): New test, Oleh Krehel, 2016/04/25
- [elpa] master 1088078 266/272: When selecting a non-existing key in an alist, return that key, Oleh Krehel, 2016/04/25
- [elpa] master 341b5a2 229/272: counsel-grep should pick candidates closest to point, Oleh Krehel, 2016/04/25