]> code.delx.au - gnu-emacs-elpa/commitdiff
Merge commit 'e084b5d9feab3dd1246e51ce1fddde3db6024f7d' from swiper
authorOleh Krehel <ohwoeowho@gmail.com>
Sat, 23 May 2015 11:23:54 +0000 (13:23 +0200)
committerOleh Krehel <ohwoeowho@gmail.com>
Sat, 23 May 2015 11:23:54 +0000 (13:23 +0200)
Conflicts:
packages/swiper/ivy.el

1  2 
packages/swiper/README.md
packages/swiper/counsel.el
packages/swiper/ivy.el
packages/swiper/swiper.el

index d80cf2bfa6411aa10646f8b866babe7fd61e85f8,d70eeaf42a86db304896c0c1b80e80d3d00a462f..d70eeaf42a86db304896c0c1b80e80d3d00a462f
@@@ -15,16 -15,28 +15,28 @@@ The package uses the `ivy` back end fo
  
  There's also a ten minute [video demo](https://www.youtube.com/watch?v=VvnJQpTFVDc).
  
+ ## Ivy
+ Ivy is a generic completion method for Emacs, similar to
+ `icomplete-mode`. It aims to be more efficient, more simple, and more
+ pleasant to use than the alternatives. It's also highly customizable
+ and very small.
+ To try it, just call <kbd>M-x</kbd> `ivy-mode`, and all generic
+ completion, including file and buffer names, will be done with Ivy.
  ## Installation
  
  You can install the package from MELPA / GNU ELPA.
- Here is some minimal configuration:
+ Here is some typical configuration:
  
  ```elisp
  (ivy-mode 1)
  (setq ivy-use-virtual-buffers t)
  (global-set-key "\C-s" 'swiper)
  (global-set-key "\C-r" 'swiper)
+ (global-set-key (kbd "C-c C-r") 'ivy-resume)
+ (global-set-key [f6] 'ivy-resume)
  ```
  
  ## Issues
index 2fce67f4bdc1f8d0f92a9993ed90c54a0c5ecd7a,c0581e5fdc8056016525ea818d60576c63b4f33d..c0581e5fdc8056016525ea818d60576c63b4f33d
@@@ -5,7 -5,7 +5,7 @@@
  ;; Author: Oleh Krehel <ohwoeowho@gmail.com>
  ;; URL: https://github.com/abo-abo/swiper
  ;; Version: 0.1.0
- ;; Package-Requires: ((emacs "24.1") (swiper "0.3.0"))
+ ;; Package-Requires: ((emacs "24.1") (swiper "0.4.0"))
  ;; Keywords: completion, matching
  
  ;; This file is part of GNU Emacs.
    (ivy-set-action 'counsel--find-symbol)
    (ivy-done))
  
- (defun counsel--find-symbol ()
-   (let ((full-name (get-text-property 0 'full-name ivy--current)))
+ (defun counsel--find-symbol (x)
+   "Find symbol definition that corresponds to string X."
+   (let ((full-name (get-text-property 0 'full-name x)))
      (if full-name
          (find-library full-name)
-       (let ((sym (read ivy--current)))
+       (let ((sym (read x)))
          (cond ((boundp sym)
                 (find-variable sym))
                ((fboundp sym)
@@@ -90,9 -91,9 +91,9 @@@
       :history 'counsel-describe-symbol-history
       :require-match t
       :sort t
-      :action (lambda ()
+      :action (lambda (x)
                 (describe-variable
-                 (intern ivy--current))))))
+                 (intern x))))))
  
  (defun counsel-describe-function ()
    "Forward to `describe-function'."
                :history 'counsel-describe-symbol-history
                :require-match t
                :sort t
-               :action (lambda ()
+               :action (lambda (x)
                          (describe-function
-                          (intern ivy--current))))))
+                          (intern x))))))
  
  (defvar info-lookup-mode)
  (declare-function info-lookup->completions "info-look")
                    "git ls-files --full-name --")
                   "\n"
                   t))
-          (file (ivy-read "Find file: " cands)))
-     (when file
-       (find-file file))))
+          (action (lambda (x) (find-file x))))
+     (ivy-read "Find file: " cands
+               :action action)))
  
  (defvar counsel--git-grep-dir nil
    "Store the base git directory.")
      (counsel-git-grep-action)
      (recenter-top-bottom)))
  
- (defun counsel-git-grep-action ()
-   (let ((lst (split-string ivy--current ":")))
+ (defun counsel-git-grep-action (x)
+   (let ((lst (split-string x ":")))
      (find-file (expand-file-name (car lst) counsel--git-grep-dir))
      (goto-char (point-min))
      (forward-line (1- (string-to-number (cadr lst))))
@@@ -353,9 -354,9 +354,9 @@@ The libraries are offered from `load-pa
                                 dir) cands)))))))
      (maphash (lambda (_k v) (push (car v) res)) cands)
      (ivy-read "Load library: " (nreverse res)
-               :action (lambda ()
+               :action (lambda (x)
                          (load-library
-                          (get-text-property 0 'full-name ivy--current)))
+                          (get-text-property 0 'full-name x)))
                :keymap counsel-describe-map)))
  
  (provide 'counsel)
diff --combined packages/swiper/ivy.el
index e51c9bcd9c44404c6a314e6765f2960b546374d5,dd79848add8f8b7ad4f1a74b2308730acdbce887..dd79848add8f8b7ad4f1a74b2308730acdbce887
--- 2/ivy.el
@@@ -4,7 -4,6 +4,6 @@@
  
  ;; Author: Oleh Krehel <ohwoeowho@gmail.com>
  ;; URL: https://github.com/abo-abo/swiper
- ;; Version: 0.2.3
  ;; Package-Requires: ((emacs "24.1"))
  ;; Keywords: matching
  
@@@ -330,7 -329,7 +329,7 @@@ If the text hasn't changed as a result
                                (mapcar (lambda (str) (substring str (string-match postfix str)))
                                        ivy--old-cands))))
      (cond ((eq new t) nil)
-         ((string= new ivy-text) nil)
+           ((string= new ivy-text) nil)
            (new
             (delete-region (minibuffer-prompt-end) (point-max))
             (setcar (last parts) new)
    "Exit the minibuffer with the current input."
    (interactive)
    (delete-minibuffer-contents)
-   (insert ivy-text)
+   (insert (setq ivy--current ivy-text))
    (setq ivy-exit 'done)
    (exit-minibuffer))
  
@@@ -432,7 -431,7 +431,7 @@@ Call the permanent action if possible.
    (ivy--exhibit)
    (when (ivy-state-action ivy-last)
      (with-selected-window (ivy-state-window ivy-last)
-       (funcall (ivy-state-action ivy-last)))))
+       (funcall (ivy-state-action ivy-last) ivy--current))))
  
  (defun ivy-previous-line-and-call (&optional arg)
    "Move cursor vertically down ARG candidates.
@@@ -442,7 -441,7 +441,7 @@@ Call the permanent action if possible.
    (ivy--exhibit)
    (when (ivy-state-action ivy-last)
      (with-selected-window (ivy-state-window ivy-last)
-       (funcall (ivy-state-action ivy-last)))))
+       (funcall (ivy-state-action ivy-last) ivy--current))))
  
  (defun ivy-previous-history-element (arg)
    "Forward to `previous-history-element' with ARG."
@@@ -623,7 -622,8 +622,8 @@@ UPDATE-FN is called each time the curre
  
  When SORT is t, refer to `ivy-sort-functions-alist' for sorting.
  
- ACTION is a lambda to call after a result was selected.
+ ACTION is a lambda to call after a result was selected. It should
+ take a single argument, usually a string.
  
  UNWIND is a lambda to call before exiting.
  
@@@ -703,7 -703,7 +703,7 @@@ candidates with each input.
                (setq coll (cl-sort (copy-sequence coll) sort-fn))))))
      (when preselect
        (unless (or require-match
-                   (let ((re ,(format "\\`%s" preselect)))
+                   (let ((re (format "\\`%s" preselect)))
                      (cl-find-if (lambda (x) (string-match re x))
                                  coll)))
          (setq coll (cons preselect coll))))
            (when (setq unwind (ivy-state-unwind ivy-last))
              (funcall unwind)))
        (when (setq action (ivy-state-action ivy-last))
-         (funcall action)))))
+         (funcall action ivy--current)))))
  
  (defun ivy-completing-read (prompt collection
                              &optional predicate require-match initial-input
@@@ -773,7 -773,9 +773,9 @@@ The history, defaults and input-method 
    (ivy-read prompt collection
              :predicate predicate
              :require-match require-match
-             :initial-input initial-input
+             :initial-input (if (consp initial-input)
+                                (car initial-input)
+                              initial-input)
              :preselect (if (listp def) (car def) def)
              :history history
              :keymap nil
@@@ -1231,16 -1233,17 +1233,17 @@@ When VIRTUAL is non-nil, add virtual bu
      (and virtual
           (ivy--virtual-buffers)))))
  
- (defun ivy--switch-buffer-action ()
-   "Finalizer for `ivy-switch-buffer'."
-   (if (zerop (length ivy--current))
+ (defun ivy--switch-buffer-action (buffer)
+   "Switch to BUFFER.
+ BUFFER may be a string or nil."
+   (if (zerop (length buffer))
        (switch-to-buffer
         ivy-text nil 'force-same-window)
-     (let ((virtual (assoc ivy--current ivy--virtual-buffers)))
+     (let ((virtual (assoc buffer ivy--virtual-buffers)))
        (if virtual
            (find-file (cdr virtual))
          (switch-to-buffer
-          ivy--current nil 'force-same-window)))))
+          buffer nil 'force-same-window)))))
  
  (defun ivy-switch-buffer ()
    "Switch to another buffer."
    (if (not ivy-mode)
        (call-interactively 'switch-to-buffer)
      (ivy-read "Switch to buffer: " 'internal-complete-buffer
-               :action #'ivy--switch-buffer-action
-               :preselect (buffer-name (other-buffer (current-buffer))))))
+               :preselect (buffer-name (other-buffer (current-buffer)))
+               :action #'ivy--switch-buffer-action)))
  
  (provide 'ivy)
  
index 7955817bcc8f850c204ecb2dfa64083eb74b8cee,2f95a312c43cd7dc629be2579dd08425a813c4c8..2f95a312c43cd7dc629be2579dd08425a813c4c8
@@@ -4,7 -4,7 +4,7 @@@
  
  ;; Author: Oleh Krehel <ohwoeowho@gmail.com>
  ;; URL: https://github.com/abo-abo/swiper
- ;; Version: 0.4.0
+ ;; Version: 0.4.1
  ;; Package-Requires: ((emacs "24.1"))
  ;; Keywords: matching
  
@@@ -95,7 -95,7 +95,7 @@@
             (from (ivy--regex ivy-text))
             (to (query-replace-read-to from "Query replace" t)))
        (delete-minibuffer-contents)
-       (ivy-set-action (lambda ()
+       (ivy-set-action (lambda (_)
                          (with-selected-window swiper--window
                            (perform-replace from to
                                             t t nil))))