[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 18da759 320/348: ivy.el: Remove ivy--current
From: |
Oleh Krehel |
Subject: |
[elpa] master 18da759 320/348: ivy.el: Remove ivy--current |
Date: |
Sat, 8 Apr 2017 11:04:22 -0400 (EDT) |
branch: master
commit 18da759270b40ec8ecbec32397e06d65cd599ef7
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
ivy.el: Remove ivy--current
Replace all GET with: (ivy-state-current ivy-last).
Replace all SET with: (setf (ivy-state-current ivy-last) value)
---
counsel.el | 8 +++----
ivy.el | 73 +++++++++++++++++++++++++++++++-------------------------------
swiper.el | 6 +++---
3 files changed, 43 insertions(+), 44 deletions(-)
diff --git a/counsel.el b/counsel.el
index 5c0390f..d154181 100644
--- a/counsel.el
+++ b/counsel.el
@@ -1250,7 +1250,7 @@ When REVERT is non-nil, regenerate the current
*ivy-occur* buffer."
(defun counsel-git-grep-recenter ()
(interactive)
(with-ivy-window
- (counsel-git-grep-action ivy--current)
+ (counsel-git-grep-action (ivy-state-current ivy-last))
(recenter-top-bottom)))
;;** `counsel-git-stash'
@@ -1941,7 +1941,7 @@ the command."
(line-end-position))))
:history 'counsel-git-grep-history
:update-fn (lambda ()
- (counsel-grep-action ivy--current))
+ (counsel-grep-action
(ivy-state-current ivy-last)))
:re-builder #'ivy--regex
:action #'counsel-grep-action
:unwind (lambda ()
@@ -2898,7 +2898,7 @@ selected candidate."
(list-colors-duplicates))
:require-match t
:update-fn (lambda ()
- (counsel-colors--update-highlight ivy--current))
+ (counsel-colors--update-highlight
(ivy-state-current ivy-last)))
:action #'counsel-colors-action-insert-name
:history 'counsel-colors-emacs-history
:caller 'counsel-colors-emacs
@@ -3086,7 +3086,7 @@ selected candidate."
:require-match t
:action #'counsel-colors-action-insert-name
:update-fn (lambda ()
- (counsel-colors--update-highlight ivy--current))
+ (counsel-colors--update-highlight
(ivy-state-current ivy-last)))
:history 'counsel-colors-web-history
:caller 'counsel-colors-web
:sort t)))
diff --git a/ivy.el b/ivy.el
index fa0ea2c..ad55d7e 100644
--- a/ivy.el
+++ b/ivy.el
@@ -346,7 +346,8 @@ action functions.")
;; A lambda that transforms candidates only for display
display-transformer-fn
directory
- caller)
+ caller
+ current)
(defvar ivy-last (make-ivy-state)
"The last parameters passed to `ivy-read'.
@@ -389,9 +390,6 @@ of `history-length'.")
(defvar ivy-text ""
"Store the user's string as it is typed in.")
-(defvar ivy--current ""
- "Current candidate.")
-
(defvar ivy--index 0
"Store the index of the current candidate.")
@@ -509,11 +507,12 @@ When non-nil, it should contain at least one %d.")
(defun ivy--done (text)
"Insert TEXT and exit minibuffer."
- (if (and ivy--directory
- (not (eq (ivy-state-history ivy-last) 'grep-files-history)))
- (insert (setq ivy--current (expand-file-name
- text ivy--directory)))
- (insert (setq ivy--current text)))
+ (insert
+ (setf (ivy-state-current ivy-last)
+ (if (and ivy--directory
+ (not (eq (ivy-state-history ivy-last) 'grep-files-history)))
+ (expand-file-name text ivy--directory)
+ text)))
(setq ivy-exit 'done)
(exit-minibuffer))
@@ -527,7 +526,7 @@ When non-nil, it should contain at least one %d.")
;; the action from `ivy-dispatching-done' may not need a
;; candidate at all
(eq this-command 'ivy-dispatching-done))
- (ivy--done ivy--current))
+ (ivy--done (ivy-state-current ivy-last)))
((memq (ivy-state-collection ivy-last)
'(read-file-name-internal internal-complete-buffer))
(if (or (not (eq confirm-nonexistent-file-or-buffer t))
@@ -555,7 +554,7 @@ key (a string), cmd and doc (a string)."
(format "%s\n%s\n"
(if (eq this-command 'ivy-read-action)
"Select action: "
- ivy--current)
+ (ivy-state-current ivy-last))
(mapconcat
(lambda (x)
(format "%s: %s"
@@ -636,7 +635,7 @@ When ARG is t, exit with current text, ignoring the
candidates."
(ivy--directory
(ivy--directory-done))
((eq (ivy-state-collection ivy-last) 'Info-read-node-name-1)
- (if (member ivy--current '("(./)" "(../)"))
+ (if (member (ivy-state-current ivy-last) '("(./)" "(../)"))
(ivy-quit-and-run
(ivy-read "Go to file: " 'read-file-name-internal
:action (lambda (x)
@@ -657,8 +656,8 @@ When ARG is t, exit with current text, ignoring the
candidates."
(ivy--exhibit))
((and
(> ivy--length 0)
- (not (string= ivy--current "./"))
- (setq dir (ivy-expand-file-if-directory ivy--current)))
+ (not (string= (ivy-state-current ivy-last) "./"))
+ (setq dir (ivy-expand-file-if-directory (ivy-state-current ivy-last))))
(ivy--cd dir)
(ivy--exhibit))
((and (not (string= ivy-text ""))
@@ -677,8 +676,8 @@ When ARG is t, exit with current text, ignoring the
candidates."
ivy-text))
((string-match
"\\`\\([^/]+?\\):\\(?:\\(.*\\)@\\)?\\(.*\\)\\'"
- ivy--current)
- (setq ivy-text ivy--current))))
+ (ivy-state-current ivy-last))
+ (setq ivy-text (ivy-state-current ivy-last)))))
(string-match
"\\`/\\([^/]+?\\):\\(?:\\(.*\\)@\\)?\\(.*\\)\\'"
ivy-text))
@@ -772,7 +771,7 @@ If the text hasn't changed as a result, forward to
`ivy-alt-done'."
"Exit the minibuffer with current input instead of current candidate."
(interactive)
(delete-minibuffer-contents)
- (insert (setq ivy--current
+ (insert (setf (ivy-state-current ivy-last)
(if ivy--directory
(expand-file-name ivy-text ivy--directory)
ivy-text)))
@@ -798,7 +797,7 @@ If the text hasn't changed as a result, forward to
`ivy-alt-done'."
:history (ivy-state-history ivy-last)
:preselect (unless (eq (ivy-state-collection ivy-last)
'read-file-name-internal)
- ivy--current)
+ (ivy-state-current ivy-last))
:keymap (ivy-state-keymap ivy-last)
:update-fn (ivy-state-update-fn ivy-last)
:sort (ivy-state-sort ivy-last)
@@ -1001,15 +1000,15 @@ Example use:
;; Previously, the cdr of the selected candidate
would be returned.
;; Now, the whole candidate is returned.
(let (idx)
- (if (setq idx (get-text-property 0 'idx
ivy--current))
+ (if (setq idx (get-text-property 0 'idx
(ivy-state-current ivy-last)))
(nth idx collection)
- (assoc ivy--current collection)))))
+ (assoc (ivy-state-current ivy-last)
collection)))))
(ivy--directory
- (expand-file-name ivy--current ivy--directory))
- ((equal ivy--current "")
+ (expand-file-name (ivy-state-current ivy-last)
ivy--directory))
+ ((equal (ivy-state-current ivy-last) "")
ivy-text)
(t
- ivy--current))))
+ (ivy-state-current ivy-last)))))
(if (eq action 'identity)
(funcall action x)
(select-window (ivy--get-window ivy-last))
@@ -1523,13 +1522,13 @@ customizations apply to the current completion session."
hist)
(when (eq ivy-exit 'done)
(let ((item (if ivy--directory
- ivy--current
+ (ivy-state-current ivy-last)
ivy-text)))
(unless (equal item "")
(set hist (cons (propertize item 'ivy-index ivy--index)
(delete item
(cdr (symbol-value hist))))))))
- ivy--current))
+ (ivy-state-current ivy-last)))
(remove-hook 'post-command-hook #'ivy--exhibit)
(ivy-overlay-cleanup)
(when (setq unwind (ivy-state-unwind ivy-last))
@@ -1538,11 +1537,11 @@ customizations apply to the current completion session."
(when recursive-ivy-last
(ivy--reset-state (setq ivy-last recursive-ivy-last)))))
(ivy-call)
- (when (> (length ivy--current) 0)
- (remove-text-properties 0 1 '(idx) ivy--current))
(when (and recursive-ivy-last
ivy-recursive-restore)
- (ivy--reset-state (setq ivy-last recursive-ivy-last))))))
+ (ivy--reset-state (setq ivy-last recursive-ivy-last)))
+ (when (> (length (ivy-state-current ivy-last)) 0)
+ (remove-text-properties 0 1 '(idx) (ivy-state-current ivy-last))))))
(defun ivy--reset-state (state)
"Reset the ivy to STATE.
@@ -2284,10 +2283,10 @@ If SUBEXP is nil, the text properties are applied to
the whole match."
(not (string= ivy-text "/")))
(let ((default-directory ivy--directory))
(and
- (not (equal ivy--current ""))
- (file-directory-p ivy--current)
- (file-exists-p ivy--current))))
- (ivy--cd (expand-file-name ivy--current ivy--directory)))))
+ (not (equal (ivy-state-current ivy-last) ""))
+ (file-directory-p (ivy-state-current ivy-last))
+ (file-exists-p (ivy-state-current ivy-last)))))
+ (ivy--cd (expand-file-name (ivy-state-current ivy-last)
ivy--directory)))))
(defcustom ivy-magic-tilde t
"When non-nil, ~ will move home when selecting files.
@@ -2944,7 +2943,7 @@ CANDS is a list of strings."
(when (>= ivy--index ivy--length)
(setq ivy--index (max (1- ivy--length) 0)))
(if (null cands)
- (setq ivy--current "")
+ (setf (ivy-state-current ivy-last) "")
(let* ((half-height (/ ivy-height 2))
(start (max 0 (- ivy--index half-height)))
(end (min (+ start (1- ivy-height)) ivy--length))
@@ -2952,7 +2951,7 @@ CANDS is a list of strings."
(cands (cl-subseq cands start end))
(index (- ivy--index start))
transformer-fn)
- (setq ivy--current (copy-sequence (nth index cands)))
+ (setf (ivy-state-current ivy-last) (copy-sequence (nth index cands)))
(when (setq transformer-fn (ivy-state-display-transformer-fn ivy-last))
(with-ivy-window
(setq cands (mapcar transformer-fn cands))))
@@ -3348,9 +3347,9 @@ Don't finish completion."
(interactive)
(delete-minibuffer-contents)
(if (and ivy--directory
- (string-match "/$" ivy--current))
- (insert (substring ivy--current 0 -1))
- (insert ivy--current)))
+ (string-match "/$" (ivy-state-current ivy-last)))
+ (insert (substring (ivy-state-current ivy-last) 0 -1))
+ (insert (ivy-state-current ivy-last))))
(defun ivy-toggle-fuzzy ()
"Toggle the re builder between `ivy--regex-fuzzy' and `ivy--regex-plus'."
diff --git a/swiper.el b/swiper.el
index 330c662..f8a9fce 100644
--- a/swiper.el
+++ b/swiper.el
@@ -551,13 +551,13 @@ Matched candidates should have `swiper-invocation-face'."
"Called when `ivy' input is updated."
(with-ivy-window
(swiper--cleanup)
- (when (> (length ivy--current) 0)
+ (when (> (length (ivy-state-current ivy-last)) 0)
(let* ((re (funcall ivy--regex-function ivy-text))
(re (if (stringp re) re (caar re)))
(re (replace-regexp-in-string
" " "\t"
re))
- (str (get-text-property 0 'swiper-line-number ivy--current))
+ (str (get-text-property 0 'swiper-line-number (ivy-state-current
ivy-last)))
(num (if (string-match "^[0-9]+" str)
(string-to-number (match-string 0 str))
0)))
@@ -871,7 +871,7 @@ Run `swiper' for those buffers."
:action 'swiper-all-action
:unwind #'swiper--cleanup
:update-fn (lambda ()
- (swiper-all-action ivy--current))
+ (swiper-all-action (ivy-state-current ivy-last)))
:dynamic-collection t
:keymap swiper-all-map
:caller 'swiper-multi)))
- [elpa] master 35b5d29 230/348: New example to show how to associate values, (continued)
- [elpa] master 35b5d29 230/348: New example to show how to associate values, Oleh Krehel, 2017/04/08
- [elpa] master e9c274a 236/348: Allow to customize ivy-display-function per caller, Oleh Krehel, 2017/04/08
- [elpa] master c14ceac 245/348: Add support for counsel-find-library, Oleh Krehel, 2017/04/08
- [elpa] master ca84f24 269/348: Add highlighter function configuration to ivy, Oleh Krehel, 2017/04/08
- [elpa] master 5701444 314/348: ivy.el (ivy-occur-revert-buffer): Restore ivy-occur-last, Oleh Krehel, 2017/04/08
- [elpa] master 13def15 318/348: ivy.el (ivy-case-fold-search): Add additional value 'always, Oleh Krehel, 2017/04/08
- [elpa] master 54c5447 319/348: counsel.el (counsel-grep-function): Add shell-quote-argument, Oleh Krehel, 2017/04/08
- [elpa] master bf8dc5f 326/348: Make swiper-avy work with more regexp builders, Oleh Krehel, 2017/04/08
- [elpa] master 03f90af 324/348: ivy.el (ivy-rotate-sort): Guard against nil sort, Oleh Krehel, 2017/04/08
- [elpa] master ac944ea 325/348: ivy.el: Remove with-ivy-window, Oleh Krehel, 2017/04/08
- [elpa] master 18da759 320/348: ivy.el: Remove ivy--current,
Oleh Krehel <=
- [elpa] master 20744aa 337/348: doc/Changelog.org: Prepare for 0.9.0, Oleh Krehel, 2017/04/08
- [elpa] master 13a3f2d 342/348: doc/Changelog.org: Sort stuff, Oleh Krehel, 2017/04/08
- [elpa] master 69dfed9 146/348: counsel.el (counsel-dpkg): Remove typo, Oleh Krehel, 2017/04/08
- [elpa] master 55a90c9 152/348: Make with-ivy-window not necessary in action, Oleh Krehel, 2017/04/08
- [elpa] master 9d693ec 158/348: Use a lighter color for ivy-remote in dark themes, Oleh Krehel, 2017/04/08
- [elpa] master 9b13aa4 170/348: ivy.el (ivy-flip): Allow to flip candidates/input, Oleh Krehel, 2017/04/08
- [elpa] master 2bc1d7b 276/348: ivy.el (ivy--occur-insert-lines): Scroll to first cand, Oleh Krehel, 2017/04/08
- [elpa] master b1c6cc8 300/348: swiper.el (swiper-all): Fix case-fold-search, Oleh Krehel, 2017/04/08
- [elpa] master c3f5f28 305/348: Add circe-mode to swiper-font-lock-exclude, Oleh Krehel, 2017/04/08
- [elpa] master 7100925 302/348: ivy.el (ivy-completing-read-handlers-alist): New defcustom, Oleh Krehel, 2017/04/08