[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ivy-hydra 5430e11 107/395: ivy.el (ivy-regex): Add
From: |
Basil L. Contovounesios |
Subject: |
[elpa] externals/ivy-hydra 5430e11 107/395: ivy.el (ivy-regex): Add |
Date: |
Thu, 25 Feb 2021 08:31:42 -0500 (EST) |
branch: externals/ivy-hydra
commit 5430e11b700ecb69e9b247710377482aa1ce0981
Author: Oleh Krehel <ohwoeowho@gmail.com>
Commit: Oleh Krehel <ohwoeowho@gmail.com>
ivy.el (ivy-regex): Add
---
counsel.el | 8 ++++----
ivy-test.el | 4 +++-
ivy.el | 22 +++++++++++++---------
swiper.el | 42 +++++++++++++++++++++---------------------
4 files changed, 41 insertions(+), 35 deletions(-)
diff --git a/counsel.el b/counsel.el
index fd0dd9f..99132c0 100644
--- a/counsel.el
+++ b/counsel.el
@@ -215,7 +215,7 @@ respectively."
(when counsel--async-start
(setq counsel--async-duration
(time-to-seconds (time-since counsel--async-start))))
- (let ((re (ivy-re-to-str (funcall ivy--regex-function ivy-text))))
+ (let ((re (ivy-re-to-str ivy-regex)))
(if ivy--old-cands
(if (eq (ivy-alist-setting ivy-index-functions-alist)
'ivy-recompute-index-zero)
(ivy-set-index 0)
@@ -1629,13 +1629,13 @@ done") "\n" t)))
(defvar counsel-git-log-cmd "GIT_PAGER=cat git log --grep '%s'"
"Command used for \"git log\".")
-(defun counsel-git-log-function (str)
- "Search for STR in git log."
+(defun counsel-git-log-function (_)
+ "Search for `ivy-regex' in git log."
(or
(ivy-more-chars)
(progn
;; `counsel--yank-pop-format-function' uses this
- (setq ivy--old-re (funcall ivy--regex-function str))
+ (setq ivy--old-re ivy-regex)
(counsel--async-command
;; "git log --grep" likes to have groups quoted e.g. \(foo\).
;; But it doesn't like the non-greedy ".*?".
diff --git a/ivy-test.el b/ivy-test.el
index 2e9e25b..4b754d0 100644
--- a/ivy-test.el
+++ b/ivy-test.el
@@ -1357,7 +1357,9 @@ a buffer visiting a file."
(insert
"line0\nline1\nline line\nline line\nline5")
(let* ((input "li")
- (cands (swiper--isearch-function input))
+ (cands (progn
+ (ivy-set-text input)
+ (swiper--isearch-function input)))
(len (length cands)))
(should (equal cands '(3 9 15 20 25 30 35)))
(dotimes (index len)
diff --git a/ivy.el b/ivy.el
index d1ce135..168c6a5 100644
--- a/ivy.el
+++ b/ivy.el
@@ -563,9 +563,16 @@ of `history-length'.")
(defvar ivy-text ""
"Store the user's string as it is typed in.")
+(defvar ivy-regex ""
+ "Store the regex value that corresponds to `ivy-text'.")
+
+(defvar ivy--regex-function 'ivy--regex
+ "Current function for building a regex.")
+
(defun ivy-set-text (str)
"Set `ivy-text' to STR."
- (setq ivy-text str))
+ (setq ivy-text str)
+ (setq ivy-regex (funcall ivy--regex-function ivy-text)))
(defvar ivy--index 0
"Store the index of the current candidate.")
@@ -623,9 +630,6 @@ Either a string or a list for `ivy-re-match'.")
(defvar ivy--old-cands nil
"Store the candidates matched by `ivy--old-re'.")
-(defvar ivy--regex-function 'ivy--regex
- "Current function for building a regex.")
-
(defvar ivy--highlight-function 'ivy--highlight-default
"Current function for formatting the candidates.")
@@ -1134,8 +1138,7 @@ If the text hasn't changed as a result, forward to
`ivy-alt-done'."
(when (and
(eq (ivy-state-collection ivy-last) #'read-file-name-internal)
(= 1 (length
- (ivy--re-filter
- (funcall ivy--regex-function ivy-text) ivy--all-candidates)))
+ (ivy--re-filter ivy-regex ivy--all-candidates)))
(let ((default-directory ivy--directory))
(file-directory-p (ivy-state-current ivy-last))))
(ivy--directory-done)))
@@ -1681,7 +1684,8 @@ minibuffer."
"Toggle the regexp quoting."
(interactive)
(setq ivy--old-re nil)
- (cl-rotatef ivy--regex-function ivy--regexp-quote))
+ (cl-rotatef ivy--regex-function ivy--regexp-quote)
+ (setq ivy-regex (funcall ivy--regex-function ivy-text)))
(defvar avy-all-windows)
(defvar avy-action)
@@ -2240,7 +2244,7 @@ This is useful for recursive `ivy-read'."
(setq ivy--regexp-quote #'regexp-quote)
(setq ivy--old-text "")
(setq ivy--full-length nil)
- (ivy-set-text "")
+ (ivy-set-text (or initial-input ""))
(setq ivy--index 0)
(setq ivy-calling nil)
(setq ivy-use-ignore ivy-use-ignore-default)
@@ -3925,7 +3929,7 @@ in this case."
(defun ivy--highlight-default (str)
"Highlight STR, using the default method."
(unless ivy--old-re
- (setq ivy--old-re (funcall ivy--regex-function ivy-text)))
+ (setq ivy--old-re ivy-regex))
(let ((regexps
(if (listp ivy--old-re)
(mapcar #'car (cl-remove-if-not #'cdr ivy--old-re))
diff --git a/swiper.el b/swiper.el
index 9828ddc..5259457 100644
--- a/swiper.el
+++ b/swiper.el
@@ -168,7 +168,7 @@ Treated as non-nil when searching backwards."
(defun swiper--query-replace-setup ()
(with-ivy-window
(let ((end (window-end (selected-window) t))
- (re ivy--old-re))
+ (re ivy-regex))
(save-excursion
(beginning-of-line)
(while (re-search-forward re end t)
@@ -196,7 +196,7 @@ Treated as non-nil when searching backwards."
(swiper--query-replace-setup)
(unwind-protect
(let* ((enable-recursive-minibuffers t)
- (from ivy--old-re)
+ (from ivy-regex)
(groups (number-sequence 1 ivy--subexps))
(default
(list
@@ -670,18 +670,20 @@ When capture groups are present in the input, print them
instead of lines."
(buffer-name buffer)))
'face
'ivy-grep-info))
- (ivy-text (progn (string-match "\"\\(.*\\)\"" (buffer-name))
- (match-string 1 (buffer-name))))
- (re (mapconcat #'identity (ivy--split ivy-text) ".*?"))
+ (re
+ (progn
+ (string-match "\"\\(.*\\)\"" (buffer-name))
+ (ivy-set-text (match-string 1 (buffer-name)))
+ (mapconcat #'identity (ivy--split ivy-text) ".*?")))
(cands
(swiper--occur-cands
fname
(or cands
(save-window-excursion
- (setq ivy--old-re nil)
(switch-to-buffer buffer)
(if (eq (ivy-state-caller ivy-last) 'swiper)
(let ((ivy--regex-function 'swiper--re-builder))
+ (setq ivy--old-re nil)
(ivy--filter re (swiper--candidates)))
(swiper-isearch-function ivy-text)))))))
(if (string-match-p "\\\\(" re)
@@ -925,19 +927,17 @@ the face, window and priority of the overlay."
(or (display-graphic-p)
(not recenter-redisplay)))
-(defun swiper--positive-regexps (str)
- (let ((regexp-or-regexps
- (funcall ivy--regex-function str)))
- (if (listp regexp-or-regexps)
- (mapcar #'car (cl-remove-if-not #'cdr regexp-or-regexps))
- (list regexp-or-regexps))))
+(defun swiper--positive-regexps ()
+ (if (listp ivy-regex)
+ (mapcar #'car (cl-remove-if-not #'cdr ivy-regex))
+ (list ivy-regex)))
(defun swiper--update-input-ivy ()
"Called when `ivy' input is updated."
(with-ivy-window
(swiper--cleanup)
(when (> (length (ivy-state-current ivy-last)) 0)
- (let ((regexps (swiper--positive-regexps ivy-text))
+ (let ((regexps (swiper--positive-regexps))
(re-idx -1)
(case-fold-search (ivy--case-fold-p ivy-text)))
(dolist (re regexps)
@@ -1236,7 +1236,7 @@ otherwise continue prompting for buffers."
(or
(ivy-more-chars)
(let* ((buffers (cl-remove-if-not #'swiper-all-buffer-p (buffer-list)))
- (re-full (funcall ivy--regex-function str))
+ (re-full ivy-regex)
re re-tail
cands match
(case-fold-search (ivy--case-fold-p str)))
@@ -1422,7 +1422,7 @@ See `ivy-format-functions-alist' for further information."
(setq filtered-cands nil))))
(defun swiper--isearch-function (str)
- (let ((re-full (funcall ivy--regex-function str)))
+ (let ((re-full ivy-regex))
(unless (equal re-full "")
(let* ((case-fold-search (ivy--case-fold-p str))
(re
@@ -1460,7 +1460,7 @@ that we search only for one character."
(lambda ()
(with-ivy-window
(swiper--add-overlays (ivy--regex ivy-text))))))
- (dolist (re (swiper--positive-regexps ivy-text))
+ (dolist (re (swiper--positive-regexps))
(swiper--add-overlays re))))
(defun swiper-isearch-action (x)
@@ -1473,7 +1473,7 @@ that we search only for one character."
(when (and (or (eq this-command 'ivy-previous-line-or-history)
(and (eq this-command 'ivy-done)
(eq last-command 'ivy-previous-line-or-history)))
- (looking-back ivy--old-re (line-beginning-position)))
+ (looking-back ivy-regex (line-beginning-position)))
(goto-char (match-beginning 0)))
(isearch-range-invisible (point) (1+ (point)))
(swiper--maybe-recenter)
@@ -1541,13 +1541,13 @@ When not running `swiper-isearch' already, start it."
(defun swiper-isearch-format-function (cands)
(if (numberp (car-safe cands))
- (if (string= ivy--old-re "^$")
+ (if (string= ivy-regex "^$")
""
(mapconcat
#'identity
(swiper--isearch-format
ivy--index ivy--length ivy--old-cands
- ivy--old-re
+ ivy-regex
(ivy-state-current ivy-last)
(ivy-state-buffer ivy-last))
"\n"))
@@ -1570,7 +1570,7 @@ When not running `swiper-isearch' already, start it."
(let ((start 0)
(i 0))
(catch 'done
- (while (string-match ivy--old-re str start)
+ (while (string-match ivy-regex str start)
(if (= (match-beginning 0) (match-end 0))
(throw 'done t)
(setq start (match-end 0)))
@@ -1693,7 +1693,7 @@ Intended to be bound in `isearch-mode-map' and
`swiper-map'."
(swiper-isearch query))
(ivy-exit-with-action
(lambda (_)
- (when (looking-back ivy--old-re (line-beginning-position))
+ (when (looking-back ivy-regex (line-beginning-position))
(goto-char (match-beginning 0)))
(isearch-mode t)
(unless (string= ivy-text "")
- [elpa] externals/ivy-hydra 41bd988 082/395: ivy.el (ivy-alt-done): In an empty directory with no input return this directory, (continued)
- [elpa] externals/ivy-hydra 41bd988 082/395: ivy.el (ivy-alt-done): In an empty directory with no input return this directory, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 0f57db8 079/395: ivy.el (ivy--reset-state): Ensure default values are prepended, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra f8eb450 077/395: counsel.el (counsel-register): Fix for file registers in Emacs 27, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 7d94e67 087/395: Use the current prompt for shell history initial input, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra ce70661 095/395: counsel.el (counsel-grep-function): Simplfy and extend, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 51fe2ce 097/395: counsel.el (counsel--recentf-get-xdg-recent-files): Decode utf-8, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra fb6db46 093/395: counsel.el (counsel-flycheck-occur): Add, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra e3a72a5 096/395: Add XDG recent files to counsel-recentf., Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 00e5e0d 099/395: Apply resize to window size change hook., Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 4875c7b 101/395: ivy.el (ivy-current-match): Add :extend t, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 5430e11 107/395: ivy.el (ivy-regex): Add,
Basil L. Contovounesios <=
- [elpa] externals/ivy-hydra f40a465 117/395: ivy.el (ivy-avy-style): New defcustom, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra eb83a3c 110/395: ivy.el (ivy--update-minibuffer): Extract, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 5974f06 124/395: counsel.el (counsel-evil-marks): Improve, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra b8dd986 112/395: swiper.el (swiper-isearch-format-function): Fix for ivy-prescient, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 526c7aa 113/395: counsel-org-tag-action: message when a tag has been removed., Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 3fa1677 118/395: counsel.el (counsel--imenu-candidates): Use "Functions" only for Elisp, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra baddac7 129/395: counsel-kmacro: Handle potential error from `edmacro-fix-menu-commands`., Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 03be27a 127/395: counsel-kmacro: Small corrections in a few doc strings., Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra ff59888 136/395: ivy.el (ivy-read-action-format-columns): Add, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 4d497e2 132/395: Add support for adding additional multi-actions, Basil L. Contovounesios, 2021/02/25