emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master bd93a0f 081/167: ivy.el (ivy-state): Add a new field BUFFE


From: Oleh Krehel
Subject: [elpa] master bd93a0f 081/167: ivy.el (ivy-state): Add a new field BUFFER
Date: Tue, 08 Dec 2015 10:50:01 +0000

branch: master
commit bd93a0ff88dddfe22206b9c11c11494d68483bed
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    ivy.el (ivy-state): Add a new field BUFFER
    
    * ivy.el (ivy-resume): Update.
    (ivy-read): Update.
    
    * swiper.el (swiper--action): Use `ivy-state-buffer'.
---
 ivy.el    |   42 +++++++++++++++++++++++-------------------
 swiper.el |   28 ++++++++++++++++------------
 2 files changed, 39 insertions(+), 31 deletions(-)

diff --git a/ivy.el b/ivy.el
index e33d71c..b6c8b08 100644
--- a/ivy.el
+++ b/ivy.el
@@ -187,6 +187,8 @@ Only \"./\" and \"../\" apply here. They appear in reverse 
order."
   history preselect keymap update-fn sort
   ;; The window in which `ivy-read' was called
   window
+  ;; The buffer in which `ivy-read' was called
+  buffer
   action
   unwind
   re-builder
@@ -496,25 +498,26 @@ If the text hasn't changed as a result, forward to 
`ivy-alt-done'."
 (defun ivy-resume ()
   "Resume the last completion session."
   (interactive)
-  (ivy-read
-   (ivy-state-prompt ivy-last)
-   (ivy-state-collection ivy-last)
-   :predicate (ivy-state-predicate ivy-last)
-   :require-match (ivy-state-require-match ivy-last)
-   :initial-input ivy-text
-   :history (ivy-state-history ivy-last)
-   :preselect (unless (eq (ivy-state-collection ivy-last)
-                          'read-file-name-internal)
-                ivy--current)
-   :keymap (ivy-state-keymap ivy-last)
-   :update-fn (ivy-state-update-fn ivy-last)
-   :sort (ivy-state-sort ivy-last)
-   :action (ivy-state-action ivy-last)
-   :unwind (ivy-state-unwind ivy-last)
-   :re-builder (ivy-state-re-builder ivy-last)
-   :matcher (ivy-state-matcher ivy-last)
-   :dynamic-collection (ivy-state-dynamic-collection ivy-last)
-   :caller (ivy-state-caller ivy-last)))
+  (with-current-buffer (ivy-state-buffer ivy-last)
+    (ivy-read
+     (ivy-state-prompt ivy-last)
+     (ivy-state-collection ivy-last)
+     :predicate (ivy-state-predicate ivy-last)
+     :require-match (ivy-state-require-match ivy-last)
+     :initial-input ivy-text
+     :history (ivy-state-history ivy-last)
+     :preselect (unless (eq (ivy-state-collection ivy-last)
+                            'read-file-name-internal)
+                  ivy--current)
+     :keymap (ivy-state-keymap ivy-last)
+     :update-fn (ivy-state-update-fn ivy-last)
+     :sort (ivy-state-sort ivy-last)
+     :action (ivy-state-action ivy-last)
+     :unwind (ivy-state-unwind ivy-last)
+     :re-builder (ivy-state-re-builder ivy-last)
+     :matcher (ivy-state-matcher ivy-last)
+     :dynamic-collection (ivy-state-dynamic-collection ivy-last)
+     :caller (ivy-state-caller ivy-last))))
 
 (defvar ivy-calling nil
   "When non-nil, call the current action when `ivy--index' changes.")
@@ -1015,6 +1018,7 @@ customizations should apply to the current completion 
session."
          :sort sort
          :action action
          :window (selected-window)
+         :buffer (current-buffer)
          :unwind unwind
          :re-builder re-builder
          :matcher matcher
diff --git a/swiper.el b/swiper.el
index 7125823..ffbdea0 100644
--- a/swiper.el
+++ b/swiper.el
@@ -447,18 +447,22 @@ BEG and END, when specified, are the point bounds."
   "Goto line X."
   (if (null x)
       (user-error "No candidates")
-    (goto-char (point-min))
-    (funcall (if swiper-use-visual-line
-                 #'line-move
-               #'forward-line)
-             (1- (read (get-text-property 0 'display x))))
-    (re-search-forward
-     (ivy--regex ivy-text) (line-end-position) t)
-    (swiper--ensure-visible)
-    (when (/= (point) swiper--opoint)
-      (unless (and transient-mark-mode mark-active)
-        (push-mark swiper--opoint t)
-        (message "Mark saved where search started")))))
+    (with-ivy-window
+      (unless (equal (current-buffer)
+                     (ivy-state-buffer ivy-last))
+        (switch-to-buffer (ivy-state-buffer ivy-last)))
+      (goto-char (point-min))
+      (funcall (if swiper-use-visual-line
+                   #'line-move
+                 #'forward-line)
+               (1- (read (get-text-property 0 'display x))))
+      (re-search-forward
+       (ivy--regex ivy-text) (line-end-position) t)
+      (swiper--ensure-visible)
+      (when (/= (point) swiper--opoint)
+        (unless (and transient-mark-mode mark-active)
+          (push-mark swiper--opoint t)
+          (message "Mark saved where search started"))))))
 
 ;; (define-key isearch-mode-map (kbd "C-o") 'swiper-from-isearch)
 (defun swiper-from-isearch ()



reply via email to

[Prev in Thread] Current Thread [Next in Thread]