[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 0f29d08 4/4: Merge commit '05b6fc7acf98d44bd71d625bc6056a4
From: |
Oleh Krehel |
Subject: |
[elpa] master 0f29d08 4/4: Merge commit '05b6fc7acf98d44bd71d625bc6056a4125981a70' from swiper |
Date: |
Sat, 18 Apr 2015 17:20:52 +0000 |
branch: master
commit 0f29d08a92830faa51023d192cd352279944e9e6
Merge: 98af823 05b6fc7
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Merge commit '05b6fc7acf98d44bd71d625bc6056a4125981a70' from swiper
---
packages/swiper/ivy.el | 109 ++++++++++++++++++++++++++----------------------
1 files changed, 59 insertions(+), 50 deletions(-)
diff --git a/packages/swiper/ivy.el b/packages/swiper/ivy.el
index de556ca..78a50a3 100644
--- a/packages/swiper/ivy.el
+++ b/packages/swiper/ivy.el
@@ -66,6 +66,11 @@ Set this to nil if you don't want the count."
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 +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 +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 +399,9 @@ The history, defaults and input-method arguments are
ignored for now."
"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"
@@ -362,9 +409,6 @@ Turning on Ivy mode will set `completing-read-function' to
(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
@@ -378,13 +422,6 @@ Turning on Ivy mode will set `completing-read-function' to
(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
@@ -428,24 +465,6 @@ Otherwise, store nil.")
;; 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
@@ -459,10 +478,6 @@ Otherwise, store nil.")
(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 +524,6 @@ Should be run via minibuffer `post-command-hook'."
(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