[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master e3dabec 143/184: counsel.el: Use ivy-configure :unwind-fn
From: |
Oleh Krehel |
Subject: |
[elpa] master e3dabec 143/184: counsel.el: Use ivy-configure :unwind-fn |
Date: |
Wed, 16 Oct 2019 13:15:10 -0400 (EDT) |
branch: master
commit e3dabec86a78b97331fb175583e5600e9ddf6476
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
counsel.el: Use ivy-configure :unwind-fn
---
counsel.el | 50 ++++++++++++++------------
swiper.el | 118 ++++++++++++++++++++++++++++++-------------------------------
2 files changed, 86 insertions(+), 82 deletions(-)
diff --git a/counsel.el b/counsel.el
index a73fa03..2286d9c 100644
--- a/counsel.el
+++ b/counsel.el
@@ -426,9 +426,11 @@ Update the minibuffer with the amount of lines collected
every
(setq ivy-completion-end (point))
(ivy-read "Candidate: " company-candidates
:action #'ivy-completion-in-region-action
- :unwind #'company-abort
:caller 'counsel-company))))
+(ivy-configure 'counsel-company
+ :unwind-fn #'company-abort)
+
;;** `counsel-irony'
(declare-function irony-completion-candidates-async "ext:irony-completion")
(declare-function irony-completion-symbol-bounds "ext:irony-completion")
@@ -1483,6 +1485,10 @@ On success, RESULT-FN is called in output buffer with no
arguments."
"Forward COMMAND to `counsel--call'."
(counsel--call command))
+(defun counsel--grep-unwind ()
+ (counsel-delete-process)
+ (swiper--cleanup))
+
;;;###autoload
(defun counsel-git-grep (&optional initial-input initial-directory cmd)
"Grep for a string in the current Git repository.
@@ -1500,10 +1506,6 @@ When CMD is non-nil, prompt for a specific \"git grep\"
command."
(if proj
#'counsel-git-grep-proj-function
#'counsel-git-grep-function))
- (unwind-function
- (lambda ()
- (counsel-delete-process)
- (swiper--cleanup)))
(default-directory (or initial-directory
(if proj
(car proj)
@@ -1513,12 +1515,13 @@ When CMD is non-nil, prompt for a specific \"git grep\"
command."
:dynamic-collection t
:keymap counsel-git-grep-map
:action #'counsel-git-grep-action
- :unwind unwind-function
:history 'counsel-git-grep-history
:caller 'counsel-git-grep))))
(ivy-configure 'counsel-git-grep
- :occur #'counsel-git-grep-occur)
+ :occur #'counsel-git-grep-occur
+ :unwind-fn #'counsel--grep-unwind)
+
(cl-pushnew 'counsel-git-grep ivy-highlight-grep-commands)
(defun counsel-git-grep-proj-function (str)
@@ -1753,9 +1756,11 @@ currently checked out."
(ivy-read "Grep log: " #'counsel-git-log-function
:dynamic-collection t
:action #'counsel-git-log-action
- :unwind #'counsel-delete-process
:caller 'counsel-git-log))
+(ivy-configure 'counsel-git-log
+ :unwind-fn #'counsel-delete-process)
+
(add-to-list 'ivy-format-functions-alist '(counsel-git-log .
counsel--git-log-format-function))
(add-to-list 'ivy-height-alist '(counsel-git-log . 4))
(add-to-list 'counsel-async-split-string-re-alist '(counsel-git-log . "^commit
"))
@@ -2505,9 +2510,11 @@ INITIAL-INPUT can be given as the initial minibuffer
input."
(with-ivy-window
(find-file
(concat (file-remote-p default-directory) file)))))
- :unwind #'counsel-delete-process
:caller 'counsel-locate))
+(ivy-configure 'counsel-locate
+ :unwind-fn #'counsel-delete-process)
+
;;** `counsel-fzf'
(defvar counsel-fzf-cmd "fzf -f \"%s\""
"Command for `counsel-fzf'.")
@@ -2556,11 +2563,11 @@ FZF-PROMPT, if non-nil, is passed as `ivy-read' prompt
argument."
:re-builder #'ivy--regex-fuzzy
:dynamic-collection t
:action #'counsel-fzf-action
- :unwind #'counsel-delete-process
:caller 'counsel-fzf))
(ivy-configure 'counsel-fzf
- :occur #'counsel-fzf-occur)
+ :occur #'counsel-fzf-occur
+ :unwind-fn #'counsel-delete-process)
(defun counsel-fzf-action (x)
"Find file X in current fzf directory."
@@ -2840,13 +2847,11 @@ CALLER is passed to `ivy-read'."
:keymap counsel-ag-map
:history 'counsel-git-grep-history
:action #'counsel-git-grep-action
- :unwind (lambda ()
- (counsel-delete-process)
- (swiper--cleanup))
:caller (or caller 'counsel-ag))))
(ivy-configure 'counsel-ag
- :occur #'counsel-ag-occur)
+ :occur #'counsel-ag-occur
+ :unwind-fn #'counsel--grep-unwind)
(defun counsel-cd ()
"Change the directory for the currently running Ivy grep-like command.
@@ -2980,7 +2985,8 @@ Example input with inclusion and exclusion file patterns:
:caller 'counsel-rg)))
(ivy-configure 'counsel-rg
- :occur #'counsel-ag-occur)
+ :occur #'counsel-ag-occur
+ :unwind-fn #'counsel--grep-unwind)
(cl-pushnew 'counsel-rg ivy-highlight-grep-commands)
;;** `counsel-grep'
@@ -3095,15 +3101,13 @@ When non-nil, INITIAL-INPUT is the initial search
pattern."
:history 'counsel-grep-history
:re-builder #'ivy--regex
:action #'counsel-grep-action
- :unwind (lambda ()
- (counsel-delete-process)
- (swiper--cleanup))
:caller 'counsel-grep))
(unless res
(goto-char init-point)))))
(ivy-configure 'counsel-grep
:update-fn 'auto
+ :unwind-fn #'counsel--grep-unwind
:occur #'counsel-grep-occur
:more-chars 2)
@@ -3201,9 +3205,11 @@ INITIAL-INPUT can be given as the initial minibuffer
input."
(find-file file-name)
(unless (string-match "pdf$" x)
(swiper ivy-text)))))
- :unwind #'counsel-delete-process
:caller 'counsel-recoll))
+(ivy-configure 'counsel-recoll
+ :unwind-fn #'counsel-delete-process)
+
;;* Org
;;** `counsel-org-tag'
(defvar counsel-org-tags nil
@@ -3837,12 +3843,12 @@ Obeys `widen-automatically', which see."
(error "\
Position of selected mark outside accessible part of buffer")))
(goto-char pos))))
- :unwind #'counsel--mark-ring-unwind
:caller 'counsel-mark-ring)
(message "Mark ring is empty"))))
(ivy-configure 'counsel-mark-ring
- :update-fn #'counsel--mark-ring-update-fn)
+ :update-fn #'counsel--mark-ring-update-fn
+ :unwind-fn #'counsel--mark-ring-unwind)
;;** `counsel-package'
(defvar package--initialized)
diff --git a/swiper.el b/swiper.el
index 324ac6e..6af5a25 100644
--- a/swiper.el
+++ b/swiper.el
@@ -550,17 +550,6 @@ numbers; replaces calculating the width from buffer line
count."
"The point when `swiper' starts.")
;;;###autoload
-(defun swiper (&optional initial-input)
- "`isearch-forward' with an overview.
-When non-nil, INITIAL-INPUT is the initial search pattern."
- (interactive)
- (swiper--ivy (swiper--candidates) initial-input))
-
-(ivy-configure 'swiper
- :occur #'swiper-occur
- :update-fn #'swiper--update-input-ivy)
-
-;;;###autoload
(defun swiper-backward (&optional initial-input)
"`isearch-backward' with an overview.
When non-nil, INITIAL-INPUT is the initial search pattern."
@@ -769,51 +758,58 @@ line numbers. For the buffer, use `ivy--regex' instead."
"When non-nil don't go back to search start on abort."
:type 'boolean)
-(defun swiper--ivy (candidates &optional initial-input)
- "Select one of CANDIDATES and move there.
+;;;###autoload
+(defun swiper (&optional initial-input)
+ "`isearch-forward' with an overview.
When non-nil, INITIAL-INPUT is the initial search pattern."
- (swiper--init)
- (setq swiper-invocation-face
- (plist-get (text-properties-at (point)) 'face))
- (let ((preselect
- (if (or swiper-use-visual-line (null search-invisible))
- (count-screen-lines
- (point-min)
- (save-excursion (beginning-of-visual-line) (point)))
- (1- (line-number-at-pos))))
- (minibuffer-allow-text-properties t)
- res)
- (unwind-protect
- (and
- (setq res
- (ivy-read
- "Swiper: "
- candidates
- :initial-input initial-input
- :keymap swiper-map
- :preselect
- (if initial-input
- (cl-position-if
- (lambda (x)
- (= (1+ preselect) (get-text-property 0
'swiper-line-number x)))
- (progn
- (setq ivy--old-re nil)
- (ivy--filter initial-input candidates)))
- preselect)
- :require-match t
- :unwind #'swiper--cleanup
- :action #'swiper--action
- :re-builder #'swiper--re-builder
- :history 'swiper-history
- :caller 'swiper))
- (point))
- (unless (or res swiper-stay-on-quit)
- (goto-char swiper--opoint))
- (unless (or res (string= ivy-text ""))
- (cl-pushnew ivy-text swiper-history))
- (setq swiper--current-window-start nil)
- (when swiper--reveal-mode
- (reveal-mode 1)))))
+ (interactive)
+ (let ((candidates (swiper--candidates)))
+ (swiper--init)
+ (setq swiper-invocation-face
+ (plist-get (text-properties-at (point)) 'face))
+ (let ((preselect
+ (if (or swiper-use-visual-line (null search-invisible))
+ (count-screen-lines
+ (point-min)
+ (save-excursion (beginning-of-visual-line) (point)))
+ (1- (line-number-at-pos))))
+ (minibuffer-allow-text-properties t)
+ res)
+ (unwind-protect
+ (and
+ (setq res
+ (ivy-read
+ "Swiper: "
+ candidates
+ :initial-input initial-input
+ :keymap swiper-map
+ :preselect
+ (if initial-input
+ (cl-position-if
+ (lambda (x)
+ (= (1+ preselect) (get-text-property 0
'swiper-line-number x)))
+ (progn
+ (setq ivy--old-re nil)
+ (ivy--filter initial-input candidates)))
+ preselect)
+ :require-match t
+ :action #'swiper--action
+ :re-builder #'swiper--re-builder
+ :history 'swiper-history
+ :caller 'swiper))
+ (point))
+ (unless (or res swiper-stay-on-quit)
+ (goto-char swiper--opoint))
+ (unless (or res (string= ivy-text ""))
+ (cl-pushnew ivy-text swiper-history))
+ (setq swiper--current-window-start nil)
+ (when swiper--reveal-mode
+ (reveal-mode 1))))))
+
+(ivy-configure 'swiper
+ :occur #'swiper-occur
+ :update-fn #'swiper--update-input-ivy
+ :unwind-fn #'swiper--cleanup)
(defun swiper-toggle-face-matching ()
"Toggle matching only the candidates with `swiper-invocation-face'."
@@ -1134,9 +1130,11 @@ Run `swiper' for those buffers."
(let ((swiper-window-width (- (- (frame-width) (if (display-graphic-p) 0 1))
4)))
(ivy-read "Swiper: " swiper-multi-candidates
:action #'swiper-multi-action-2
- :unwind #'swiper--cleanup
:caller 'swiper-multi)))
+(ivy-configure 'swiper-multi
+ :unwind-fn #'swiper--cleanup)
+
(defun swiper-multi-action-1 (x)
"Add X to list of selected buffers `swiper-multi-buffers'.
If X is already part of the list, remove it instead. Quit the selection if
@@ -1278,14 +1276,14 @@ See `ivy-format-functions-alist' for further
information."
(let ((swiper-window-width (- (frame-width) (if (display-graphic-p) 0 1))))
(ivy-read "swiper-all: " 'swiper-all-function
:action #'swiper-all-action
- :unwind #'swiper--cleanup
:dynamic-collection t
:keymap swiper-all-map
:initial-input initial-input
:caller 'swiper-all)))
(ivy-configure 'swiper-all
- :update-fn 'auto)
+ :update-fn 'auto
+ :unwind-fn #'swiper--cleanup)
(add-to-list 'ivy-format-functions-alist '(swiper-multi .
swiper--all-format-function))
(add-to-list 'ivy-format-functions-alist '(swiper-all .
swiper--all-format-function))
@@ -1609,7 +1607,6 @@ When not running `swiper-isearch' already, start it."
:dynamic-collection t
:require-match t
:action #'swiper-isearch-action
- :unwind #'swiper--cleanup
:re-builder #'swiper--re-builder
:history 'swiper-history
:caller 'swiper-isearch))
@@ -1623,7 +1620,8 @@ When not running `swiper-isearch' already, start it."
(ivy-configure 'swiper-isearch
:occur #'swiper-occur
- :update-fn 'auto)
+ :update-fn 'auto
+ :unwind-fn #'swiper--cleanup)
;;;###autoload
(defun swiper-isearch-backward (&optional initial-input)
- [elpa] master 1a74a21 110/184: ivy-occur: setup for next-error., (continued)
- [elpa] master 1a74a21 110/184: ivy-occur: setup for next-error., Oleh Krehel, 2019/10/16
- [elpa] master 30adc93 115/184: Add actions to counsel-switch-buffer, Oleh Krehel, 2019/10/16
- [elpa] master 892e44a 079/184: doc: Add full text of licences, Oleh Krehel, 2019/10/16
- [elpa] master 4645e89 121/184: swiper.el (swiper-action-copy): Add and bind to "M-o w", Oleh Krehel, 2019/10/16
- [elpa] master 77997ea 120/184: counsel.el (counsel-M-x-transformer): Handle read-only strings, Oleh Krehel, 2019/10/16
- [elpa] master 1984068 122/184: doc/ivy.org: Update GFDL license to no Invariant Sections, Oleh Krehel, 2019/10/16
- [elpa] master 881cbc5 130/184: counsel.el (counsel-google-function): Use request in async mode, Oleh Krehel, 2019/10/16
- [elpa] master b39f383 125/184: counsel.el (counsel-git-grep-occur): Re-use counsel-grep-like-occur, Oleh Krehel, 2019/10/16
- [elpa] master c9f1889 136/184: swiper.el (swiper--query-replace-setup): Fix "^$" issue, Oleh Krehel, 2019/10/16
- [elpa] master b9bb7c6 140/184: ivy.el (ivy-configure): New function to configure many things at once, Oleh Krehel, 2019/10/16
- [elpa] master e3dabec 143/184: counsel.el: Use ivy-configure :unwind-fn,
Oleh Krehel <=
- [elpa] master f16ac0e 148/184: ivy.el (ivy--format): Set case-fold-search, Oleh Krehel, 2019/10/16
- [elpa] master 501ac71 151/184: ivy.el (ivy-occur-revert-buffer): Re-use ivy-highlight-grep-commands, Oleh Krehel, 2019/10/16
- [elpa] master 6b0c41b 167/184: ivy.el (ivy-sort-file-function-using-ido): Make obsolete, Oleh Krehel, 2019/10/16
- [elpa] master 22cc602 160/184: counsel.el (counsel-find-symbol): Should not show up in counsel-M-x, Oleh Krehel, 2019/10/16
- [elpa] master b85f857 166/184: .github/FUNDING.yml: Add github, Oleh Krehel, 2019/10/16
- [elpa] master 722250c 162/184: counsel.el (counsel-imenu-action): Handle nil case, Oleh Krehel, 2019/10/16
- [elpa] master 9970ae6 180/184: counsel.el (counsel-read-directory-name): Add, Oleh Krehel, 2019/10/16
- [elpa] master 7054901 176/184: ivy.el (ivy-occur-revert-buffer): Make more generic, Oleh Krehel, 2019/10/16
- [elpa] master fcef913 023/184: swiper-isearch: Fix regexes in "ignore-order" case, Oleh Krehel, 2019/10/16
- [elpa] master 0b85d9d 030/184: counsel.el (counsel-at-git-issue-p): Add vc-git-log-view-mode, Oleh Krehel, 2019/10/16