]> code.delx.au - gnu-emacs-elpa/commitdiff
Merge commit '05b6fc7acf98d44bd71d625bc6056a4125981a70' from swiper
authorOleh Krehel <ohwoeowho@gmail.com>
Sat, 18 Apr 2015 17:09:42 +0000 (19:09 +0200)
committerOleh Krehel <ohwoeowho@gmail.com>
Sat, 18 Apr 2015 17:09:42 +0000 (19:09 +0200)
1  2 
packages/swiper/ivy.el

diff --combined packages/swiper/ivy.el
index de556ca0354e029ac38226a4ddd6af30077da507,4388834ac201e5f9e0cc60623b544d812c5b6cb6..78a50a3c7197a45ff1ec791f9eca3e5f24c8545c
--- 2/ivy.el
@@@ -36,8 -36,6 +36,8 @@@
  ;; re-building it into a regex.
  ;; So "for example" is transformed into "\\(for\\).*\\(example\\)".
  
 +(require 'cl-lib)
 +
  ;;; Code:
  ;;* Customization
  (defgroup ivy nil
@@@ -66,6 -64,11 +66,11 @@@ Set this to nil if you don't want the c
  This is usually meant as a quick exit out of the minibuffer."
    :type 'function)
  
+ (defcustom ivy-extra-directories '("../" "./")
+   "Add this to the front of the list when completing file names.
+ Only \"./\" and \"../\" apply here. They appear in reverse order."
+   :type 'list)
  ;;* User Visible
  ;;** Keymap
  (require 'delsel)
@@@ -99,6 -102,44 +104,44 @@@ of `history-length', which see."
  (defvar ivy--directory nil
    "Current directory when completing file names.")
  
+ (defvar ivy--length 0
+   "Store the amount of viable candidates.")
+ (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.")
+ (defvar ivy-exit nil
+   "Store 'done if the completion was successfully selected.
+ Otherwise, store nil.")
+ (defvar ivy--action nil
+   "Store a function to call at the end of `ivy--read'.")
+ (defvar ivy--all-candidates nil
+   "Store the candidates passed to `ivy-read'.")
+ (defvar ivy--default nil
+   "Default initial input.")
+ (defvar ivy--update-fn nil
+   "Current function to call when current candidate(s) update.")
+ (defvar ivy--prompt nil
+   "Store the format-style prompt.
+ When non-nil, it should contain one %d.")
+ (defvar ivy--old-re nil
+   "Store the old regexp.")
+ (defvar ivy--old-cands nil
+   "Store the candidates matched by `ivy--old-re'.")
  ;;** Commands
  (defun ivy-done ()
    "Exit the minibuffer with the selected candidate."
@@@ -223,17 -264,19 +266,19 @@@ Directories come first.
           (seq (all-completions "" 'read-file-name-internal)))
      (if (equal dir "/")
          seq
-       (cons "./" (cons "../"
-                        (cl-sort
-                         (delete "./" (delete "../" seq))
-                         (lambda (x y)
-                           (if (file-directory-p x)
-                               (if (file-directory-p y)
-                                   (string< x y)
-                                 t)
-                             (if (file-directory-p y)
-                                 nil
-                               (string< x y))))))))))
+       (setq seq (cl-sort
+                  (delete "./" (delete "../" seq))
+                  (lambda (x y)
+                    (if (file-directory-p x)
+                        (if (file-directory-p y)
+                            (string< x y)
+                          t)
+                      (if (file-directory-p y)
+                          nil
+                        (string< x y))))))
+       (dolist (dir ivy-extra-directories)
+         (push dir seq))
+       seq)))
  
  ;;** Entry Point
  (defun ivy-read (prompt collection
@@@ -354,7 -397,9 +399,9 @@@ The history, defaults and input-method 
      "Toggle Ivy mode on or off.
  With ARG, turn Ivy mode on if arg is positive, off otherwise.
  Turning on Ivy mode will set `completing-read-function' to
- `ivy-completing-read'."
+ `ivy-completing-read'.
+ \\{ivy-minibuffer-map}"
    :group 'ivy
    :global t
    :lighter " ivy"
        (setq completing-read-function 'ivy-completing-read)
      (setq completing-read-function 'completing-read-default)))
  
- (defvar ivy--action nil
-   "Store a function to call at the end of `ivy--read'.")
  (defun ivy--preselect-index (candidates initial-input preselect)
    "Return the index in CANDIDATES filtered by INITIAL-INPUT for PRESELECT."
    (when initial-input
       (string-match preselect x))
     candidates))
  
- (defvar ivy-text ""
-   "Stores the user's string as it is typed in.")
- (defvar ivy-exit nil
-   "Store 'done if the completion was successfully selected.
- Otherwise, store nil.")
  ;;* Implementation
  ;;** Regex
  (defvar ivy--subexps 0
    ;; show completions with empty input
    (ivy--exhibit))
  
- (defvar ivy--all-candidates nil
-   "Store the candidates passed to `ivy-read'.")
- (defvar ivy--index 0
-   "Store the index of the current candidate.")
- (defvar ivy--length 0
-   "Store the amount of viable candidates.")
- (defvar ivy--current ""
-   "Current candidate.")
- (defvar ivy--default nil
-   "Default initial input.")
- (defvar ivy--update-fn nil
-   "Current function to call when current candidate(s) update.")
  (defun ivy--input ()
    "Return the current minibuffer input."
    ;; assume one-line minibuffer input
      (goto-char (minibuffer-prompt-end))
      (delete-region (line-end-position) (point-max))))
  
- (defvar ivy--prompt nil
-   "Store the format-style prompt.
- When non-nil, it should contain one %d.")
  (defun ivy--insert-prompt ()
    "Update the prompt according to `ivy--prompt'."
    (when ivy--prompt
@@@ -509,12 -522,6 +524,6 @@@ Should be run via minibuffer `post-comm
          (forward-line 1)
          (insert text)))))
  
- (defvar ivy--old-re nil
-   "Store the old regexp.")
- (defvar ivy--old-cands nil
-   "Store the candidates matched by `ivy--old-re'.")
  (defun ivy--add-face (str face)
    "Propertize STR with FACE.
  `font-lock-append-text-property' is used, since it's better than