:group 'ido)
(defcustom ido-ignore-extensions t
- "*Non-nil means ignore files in completion-ignored-extensions list."
+ "*Non-nil means ignore files in `completion-ignored-extensions' list."
:type 'boolean
:group 'ido)
(defcustom ido-show-dot-for-dired nil
"*Non-nil means to always put . as the first item in file name lists.
-This allows the current directory to be opened immediate with `dired'."
+This allows the current directory to be opened immediately with `dired'."
:type 'boolean
:group 'ido)
;;; Examples for setting the value of ido-ignore-files
;(setq ido-ignore-files '("^ " "\\.c$" "\\.h$"))
-(defcustom ido-default-file-method 'always-frame
- "*How to switch to new file when using `ido-find-file'.
+(defcustom ido-default-file-method 'raise-frame
+ "*How to visit a new file when using `ido-find-file'.
Possible values:
-`samewindow' Show new file in same window
-`otherwindow' Show new file in another window (same frame)
-`display' Display file in another window without switching to it
-`otherframe' Show new file in another frame
-`maybe-frame' If a file is visible in another frame, prompt to ask if you
- you want to see the file in the same window of the current
- frame or in the other frame
-`always-frame' If a file is visible in another frame, raise that
- frame; otherwise, visit the file in the same window"
- :type '(choice (const samewindow)
- (const otherwindow)
- (const display)
- (const otherframe)
- (const maybe-frame)
- (const always-frame))
+`selected-window' Show new file in selected window
+`other-window' Show new file in another window (same frame)
+`display' Display file in another window without selecting to it
+`other-frame' Show new file in another frame
+`maybe-frame' If a file is visible in another frame, prompt to ask if you
+ you want to see the file in the same window of the current
+ frame or in the other frame
+`raise-frame' If a file is visible in another frame, raise that
+ frame; otherwise, visit the file in the same window"
+ :type '(choice (const :tag "Visit in selected window" selected-window)
+ (const :tag "Visit in other window" other-window)
+ (const :tag "Display (no select) in other window" display)
+ (const :tag "Visit in other frame" other-frame)
+ (const :tag "Ask to visit in other frame" maybe-frame)
+ (const :tag "Raise frame if already visited" raise-frame))
:group 'ido)
-(defcustom ido-default-buffer-method 'always-frame
+(defcustom ido-default-buffer-method 'raise-frame
"*How to switch to new buffer when using `ido-switch-buffer'.
See `ido-default-file-method' for details."
- :type '(choice (const samewindow)
- (const otherwindow)
+ :type '(choice (const :tag "Show in selected window" selected-window)
+ (const :tag "Show in other window" other-window)
+ (const :tag "Display (no select) in other window" display)
+ (const :tag "Show in other frame" other-frame)
+ (const :tag "Ask to show in other frame" maybe-frame)
+ (const :tag "Raise frame if already shown" raise-frame))
+ :type '(choice (const selected-window)
+ (const other-window)
(const display)
- (const otherframe)
+ (const other-frame)
(const maybe-frame)
- (const always-frame))
+ (const raise-frame))
:group 'ido)
(defcustom ido-enable-flex-matching nil
(defcustom ido-enable-prefix nil
"*Non-nil means only match if the entered text is a prefix of file name.
This behavior is like the standard emacs-completion.
-Nil means to match if the entered text is an arbitrary substring.
+nil means to match if the entered text is an arbitrary substring.
Value can be toggled within `ido' using `ido-toggle-prefix'."
:type 'boolean
:group 'ido)
(defcustom ido-max-dir-file-cache 100
"*Maximum number of working directories to be cached.
-This is the size of the cache of file-name-all-completions results.
+This is the size of the cache of `file-name-all-completions' results.
Each cache entry is time stamped with the modification time of the
directory. Some systems, like Windows, have unreliable directory
modification times, so you may choose to disable caching on such
"*List of strings used by ido to display the alternatives in the minibuffer.
There are 10 elements in this list:
1st and 2nd elements are used as brackets around the prospect list,
-3rd element is the separator between prospects (ignored if ido-separator is set),
+3rd element is the separator between prospects (ignored if `ido-separator' is set),
4th element is the string inserted at the end of a truncated list of prospects,
5th and 6th elements are used as brackets around the common match string which
can be completed using TAB,
:group 'ido)
(defface ido-first-match '((t (:bold t)))
- "*Font used by ido for highlighting first match."
+ "*Face used by ido for highlighting first match."
:group 'ido)
(defface ido-only-match '((((class color))
(:foreground "ForestGreen"))
(t (:italic t)))
- "*Font used by ido for highlighting only match."
+ "*Face used by ido for highlighting only match."
:group 'ido)
(defface ido-subdir '((((min-colors 88) (class color))
(((class color))
(:foreground "red"))
(t (:underline t)))
- "*Font used by ido for highlighting subdirs in the alternatives."
+ "*Face used by ido for highlighting subdirs in the alternatives."
:group 'ido)
(defface ido-indicator '((((min-colors 88) (class color))
:background "red"
:width condensed))
(t (:inverse-video t)))
- "*Font used by ido for highlighting its indicators."
+ "*Face used by ido for highlighting its indicators."
:group 'ido)
(defface ido-incomplete-regexp
prefix - either nil or a fixed prefix for the dirname
The following variables are available, but should not be changed:
- ido-current-directory - the unabbreviated directory name
+ `ido-current-directory' - the unabbreviated directory name
item - equals `file' or `dir' depending on the current mode."
:type 'hook
:group 'ido)
(defvar ido-use-mycompletion-depth 0
"Non-nil means use `ido' completion feedback.
-Is set by ido functions to the current minibuffer-depth, so that
-it doesn't interfere with other minibuffer usage.")
+Is set by ido functions to the current `minibuffer-depth',
+so that it doesn't interfere with other minibuffer usage.")
(defvar ido-incomplete-regexp nil
"Non-nil if an incomplete regexp is entered.")
(define-key map "\C-t" 'ido-toggle-regexp)
(define-key map "\C-z" 'ido-undo-merge-work-directory)
(define-key map [(control ?\s)] 'ido-restrict-to-matches)
+ (define-key map [(meta ?\s)] 'ido-take-first-match)
(define-key map [(control ?@)] 'ido-restrict-to-matches)
(define-key map [right] 'ido-next-match)
(define-key map [left] 'ido-prev-match)
(define-key map "\C-l" 'ido-reread-directory)
(define-key map [(meta ?d)] 'ido-wide-find-dir-or-delete-dir)
(define-key map [(meta ?b)] 'ido-push-dir)
+ (define-key map [(meta ?v)] 'ido-push-dir-first)
(define-key map [(meta ?f)] 'ido-wide-find-file-or-pop-dir)
(define-key map [(meta ?k)] 'ido-forget-work-directory)
(define-key map [(meta ?m)] 'ido-make-directory)
(and d (cdr d)))))))
(if (member ido-default-item ido-ignore-item-temp-list)
(setq ido-default-item nil))
+ (ido-trace "new default" ido-default-item)
(setq ido-set-default-item nil))
(if ido-process-ignore-lists-inhibit
(not (if ido-directory-too-big
(file-exists-p (concat ido-current-directory ido-final-text))
(ido-existing-item-p))))
- (error "must specify valid item"))
+ (error "Must specify valid item"))
(t
(setq ido-selected
(cons (cons ido-current-directory ido-selected) ido-last-directory-list)))))
(ido-set-current-directory ido-current-directory ido-selected)
(if ido-input-stack
- (while ido-input-stack
- (let ((elt (car ido-input-stack)))
+ ; automatically pop stack elements which match existing files or directories
+ (let (elt)
+ (while (and (setq elt (car ido-input-stack))
+ (file-exists-p (concat ido-current-directory (cdr elt))))
(if (setq ido-input-stack (cdr ido-input-stack))
(ido-set-current-directory ido-current-directory (cdr elt))
(setq ido-text-init (cdr elt)))
(defun ido-edit-input ()
"Edit absolute file name entered so far with ido; terminate by RET."
(interactive)
- (setq ido-text-init (if ido-matches (car ido-matches) ido-text))
+ (setq ido-text-init (if ido-matches (ido-name (car ido-matches)) ido-text))
(setq ido-exit 'edit)
(exit-minibuffer))
;; buffer doesn't exist
((eq ido-create-new-buffer 'never)
- (message "no buffer matching `%s'" buf))
+ (message "No buffer matching `%s'" buf))
((and (eq ido-create-new-buffer 'prompt)
(not (y-or-n-p (format "No buffer matching `%s', create one? " buf))))
(let ((ido-current-directory (ido-expand-directory default))
(ido-context-switch-command switch-cmd)
ido-directory-nonreadable ido-directory-too-big
- (minibuffer-completing-file-name t)
filename)
(if (or (not ido-mode) (ido-is-slow-ftp-host))
(unless filename
(setq ido-saved-vc-hb vc-handled-backends)
- (setq filename (ido-read-internal item
- (or prompt "Find file: ")
- 'ido-file-history nil nil initial)))
+ (let ((minibuffer-completing-file-name t))
+ (setq filename (ido-read-internal item
+ (or prompt "Find file: ")
+ 'ido-file-history nil nil initial))))
;; Choose the file name: either the text typed in, or the head
;; of the list of matches
(setq default-directory ido-current-directory)
(ido-record-command 'write-file (concat ido-current-directory filename))
(ido-record-work-directory)
- (write-file filename))
+ (write-file (concat ido-current-directory filename)))
((eq method 'read-only)
(ido-record-work-file filename)
((and (= 1 (length ido-matches))
(not (and ido-enable-tramp-completion
(string-equal ido-current-directory "/")
- (string-match "..[@:]\\'" (car ido-matches)))))
+ (string-match "..[@:]\\'" (ido-name (car ido-matches))))))
;; only one choice, so select it.
(if (not ido-confirm-unique-completion)
(exit-minibuffer)
(setq ido-rescan (not ido-enable-prefix))
(delete-region (minibuffer-prompt-end) (point))
- (insert (car ido-matches))))
+ (insert (ido-name (car ido-matches)))))
(t ;; else there could be some completions
(setq res ido-common-match-string)
(defun ido-magic-backward-char ()
"Move backward in user input or perform magic action.
If no user input is present, or at start of input, perform magic actions:
-C-x C-f C-b switch to ido-switch-buffer.
-C-x C-d C-b switch to ido-switch-buffer.
-C-x d C-b switch to ido-switch-buffer.
-C-x C-b C-b fallback to non-ido switch-to-buffer."
+C-x C-f C-b switch to `ido-switch-buffer'.
+C-x C-d C-b switch to `ido-switch-buffer'.
+C-x d C-b switch to `ido-switch-buffer'.
+C-x C-b C-b fallback to non-ido `switch-to-buffer'."
(interactive)
(cond
((> (point) (minibuffer-prompt-end))
May be useful if cached version is no longer valid, but directory
timestamp has not changed (e.g. with ftp or on Windows)."
(interactive)
- (if (and ido-mode (eq ido-cur-item 'file))
+ (if (and ido-mode (memq ido-cur-item '(file dir)))
(progn
(if (ido-is-unc-root)
(setq ido-unc-hosts-cache t)
(exit-minibuffer))
(defun ido-enter-dired ()
- "Drop into dired from file switching."
+ "Drop into `dired' from file switching."
(interactive)
(setq ido-exit 'dired)
(exit-minibuffer))
(defun ido-enter-insert-buffer ()
- "Drop into insert buffer from insert file."
+ "Drop into `insert-buffer' from insert file."
(interactive)
(setq ido-exit 'insert-buffer)
(exit-minibuffer))
(defun ido-enter-insert-file ()
- "Drop into insert file from insert buffer."
+ "Drop into `insert-file' from insert buffer."
(interactive)
(setq ido-exit 'insert-file)
(exit-minibuffer))
(ido-delete-backward-word-updir 1)
(ido-wide-find-dir)))
+(defun ido-take-first-match ()
+ "Use first matching item as input text."
+ (interactive)
+ (when ido-matches
+ (setq ido-text-init (ido-name (car ido-matches)))
+ (setq ido-exit 'refresh)
+ (exit-minibuffer)))
+
(defun ido-push-dir ()
"Move to previous directory in file name, push current input on stack."
(interactive)
(setq ido-exit 'push)
(exit-minibuffer))
+(defun ido-push-dir-first ()
+ "Move to previous directory in file name, push first match on stack."
+ (interactive)
+ (if ido-matches
+ (setq ido-text (ido-name (car ido-matches))))
+ (setq ido-exit 'push)
+ (exit-minibuffer))
+
(defun ido-pop-dir (arg)
"Pop directory from input stack back to input.
With \\[universal-argument], pop all element."
"Insert file name of current buffer.
If repeated, insert text from buffer instead."
(interactive "P")
- (let* ((bfname (buffer-file-name ido-entry-buffer))
+ (let* ((bfname (or (buffer-file-name ido-entry-buffer)
+ (buffer-name ido-entry-buffer)))
(name (and bfname (file-name-nondirectory bfname))))
(when name
(setq ido-text-init
(if (or all
+ (eq last-command this-command)
(not (equal (file-name-directory bfname) ido-current-directory))
(not (string-match "\\.[^.]*\\'" name)))
name
(let ((oa (ido-file-extension-order a n))
(ob (ido-file-extension-order b n)))
(cond
- ((= oa ob)
- lessp)
((and oa ob)
- (if lessp
- (> oa ob)
- (< oa ob)))
+ (cond
+ ((= oa ob)
+ lessp)
+ (lessp
+ (> oa ob))
+ (t
+ (< oa ob))))
(oa
(not lessp))
(ob
(let ((filenames
(split-string
(shell-command-to-string
- (concat "find " dir " -name \"" (if prefix "" "*") file "*\" -type " (if finddir "d" "f") " -print"))))
+ (concat "find "
+ (shell-quote-argument dir)
+ " -name "
+ (shell-quote-argument
+ (concat (if prefix "" "*") file "*"))
+ " -type " (if finddir "d" "f") " -print"))))
filename d f
res)
(while filenames
(let* ((case-fold-search ido-case-fold)
(slash (and (not ido-enable-prefix) (ido-final-slash ido-text)))
(text (if slash (substring ido-text 0 -1) ido-text))
- (rexq (concat (if ido-enable-regexp text (regexp-quote text)) (if slash ".*/" "")))
+ (rex0 (if ido-enable-regexp text (regexp-quote text)))
+ (rexq (concat rex0 (if slash ".*/" "")))
(re (if ido-enable-prefix (concat "\\`" rexq) rexq))
- (full-re (and do-full (not ido-enable-regexp) (not (string-match "\$\\'" re))
- (concat "\\`" re "\\'")))
+ (full-re (and do-full (not ido-enable-regexp) (not (string-match "\$\\'" rex0))
+ (concat "\\`" rex0 (if slash "/" "") "\\'")))
+ (suffix-re (and do-full slash
+ (not ido-enable-regexp) (not (string-match "\$\\'" rex0))
+ (concat rex0 "/\\'")))
(prefix-re (and full-re (not ido-enable-prefix)
(concat "\\`" rexq)))
(non-prefix-dot (or (not ido-enable-dot-prefix)
(not ido-process-ignore-lists)
ido-enable-prefix
(= (length ido-text) 0)))
-
- full-matches
- prefix-matches
- matches)
+ full-matches suffix-matches prefix-matches matches)
(setq ido-incomplete-regexp nil)
(condition-case error
(mapcar
(lambda (item)
(let ((name (ido-name item)))
- (if (and (or non-prefix-dot
- (if (= (aref ido-text 0) ?.)
- (= (aref name 0) ?.)
- (/= (aref name 0) ?.)))
- (string-match re name))
- (cond
- ((and full-re (string-match full-re name))
- (setq full-matches (cons item full-matches)))
- ((and prefix-re (string-match prefix-re name))
- (setq prefix-matches (cons item prefix-matches)))
- (t (setq matches (cons item matches))))))
- t)
+ (if (and (or non-prefix-dot
+ (if (= (aref ido-text 0) ?.)
+ (= (aref name 0) ?.)
+ (/= (aref name 0) ?.)))
+ (string-match re name))
+ (cond
+ ((and full-re (string-match full-re name))
+ (setq full-matches (cons item full-matches)))
+ ((and suffix-re (string-match suffix-re name))
+ (setq suffix-matches (cons item suffix-matches)))
+ ((and prefix-re (string-match prefix-re name))
+ (setq prefix-matches (cons item prefix-matches)))
+ (t (setq matches (cons item matches))))))
+ t)
items)
(invalid-regexp
(setq ido-incomplete-regexp t
;; special-case single match, and handle appropriately
;; elsewhere.
matches (cdr error))))
- (if prefix-matches
- (setq matches (nconc prefix-matches matches)))
- (if full-matches
- (setq matches (nconc full-matches matches)))
+ (when prefix-matches
+ (ido-trace "prefix match" prefix-matches)
+ (setq matches (nconc prefix-matches matches)))
+ (when suffix-matches
+ (ido-trace "suffix match" (list text suffix-re suffix-matches))
+ (setq matches (nconc suffix-matches matches)))
+ (when full-matches
+ (ido-trace "full match" (list text full-re full-matches))
+ (setq matches (nconc full-matches matches)))
(when (and (null matches)
ido-enable-flex-matching
(> (length ido-text) 1)
((stringp nextstr)
(and (>= flen (setq slen (length nextstr)))
(string-equal (substring name (- flen slen)) nextstr)))
- ((fboundp nextstr) (funcall nextstr name))
+ ((functionp nextstr) (funcall nextstr name))
(t nil))
(setq ignorep t
ext-list nil
(setq nextstr (car re-list))
(if (cond
((stringp nextstr) (string-match nextstr name))
- ((fboundp nextstr) (funcall nextstr name))
+ ((functionp nextstr) (funcall nextstr name))
(t nil))
(setq ignorep t
re-list nil)
(funcall f completion-list
:help-string "ido "
:activate-callback
- '(lambda (x y z) (message "doesn't work yet, sorry!"))))
+ '(lambda (x y z) (message "Doesn't work yet, sorry!"))))
;; else running Emacs
;;(add-hook 'completion-setup-hook 'completion-setup-function)
(display-completion-list completion-list)))))))
"Kill the buffer at the head of `ido-matches'."
(interactive)
(let ((enable-recursive-minibuffers t)
- (buf (car ido-matches)))
+ (buf (ido-name (car ido-matches))))
(when buf
(kill-buffer buf)
;; Check if buffer still exists.
"Delete the file at the head of `ido-matches'."
(interactive)
(let ((enable-recursive-minibuffers t)
- (file (car ido-matches)))
+ (file (ido-name (car ido-matches))))
(if file
(setq file (concat ido-current-directory file)))
(when (and file
;;; VISIT CHOSEN BUFFER
(defun ido-visit-buffer (buffer method &optional record)
- "Visit file named FILE according to METHOD.
+ "Switch to BUFFER according to METHOD.
Record command in `command-history' if optional RECORD is non-nil."
-
+ (if (bufferp buffer)
+ (setq buffer (buffer-name buffer)))
(let (win newframe)
(cond
((eq method 'kill)
(ido-record-command 'kill-buffer buffer))
(kill-buffer buffer))
- ((eq method 'samewindow)
- (if record
- (ido-record-command 'switch-to-buffer buffer))
- (switch-to-buffer buffer))
-
- ((memq method '(always-frame maybe-frame))
- (cond
- ((and window-system
- (setq win (ido-window-buffer-p buffer))
- (or (eq method 'always-frame)
- (y-or-n-p "Jump to frame? ")))
- (setq newframe (window-frame win))
- (if (fboundp 'select-frame-set-input-focus)
- (select-frame-set-input-focus newframe)
- (raise-frame newframe)
- (select-frame newframe)
- (unless (featurep 'xemacs)
- (set-mouse-position (selected-frame) (1- (frame-width)) 0)))
- (select-window win))
- (t
- ;; No buffer in other frames...
- (if record
- (ido-record-command 'switch-to-buffer buffer))
- (switch-to-buffer buffer)
- )))
-
- ((eq method 'otherwindow)
+ ((eq method 'other-window)
(if record
(ido-record-command 'switch-to-buffer buffer))
(switch-to-buffer-other-window buffer))
((eq method 'display)
(display-buffer buffer))
- ((eq method 'otherframe)
+ ((eq method 'other-frame)
(switch-to-buffer-other-frame buffer)
- (unless (featurep 'xemacs)
- (select-frame-set-input-focus (selected-frame)))
+ (select-frame-set-input-focus (selected-frame)))
+
+ ((and (memq method '(raise-frame maybe-frame))
+ window-system
+ (setq win (ido-buffer-window-other-frame buffer))
+ (or (eq method 'raise-frame)
+ (y-or-n-p "Jump to frame? ")))
+ (setq newframe (window-frame win))
+ (select-frame-set-input-focus newframe)
+ (select-window win))
+
+ ;; (eq method 'selected-window)
+ (t
+ ;; No buffer in other frames...
+ (if record
+ (ido-record-command 'switch-to-buffer buffer))
+ (switch-to-buffer buffer)
))))
-(defun ido-window-buffer-p (buffer)
+(defun ido-buffer-window-other-frame (buffer)
;; Return window pointer if BUFFER is visible in another frame.
;; If BUFFER is visible in the current frame, return nil.
(let ((blist (ido-get-buffers-in-frames 'current)))
The buffer name is selected interactively by typing a substring.
For details of keybindings, do `\\[describe-function] ido'."
(interactive)
- (ido-buffer-internal 'otherwindow 'switch-to-buffer-other-window))
+ (ido-buffer-internal 'other-window 'switch-to-buffer-other-window))
;;;###autoload
(defun ido-display-buffer ()
For details of keybindings, do `\\[describe-function] ido'."
(interactive)
(if ido-mode
- (ido-buffer-internal 'otherframe)
+ (ido-buffer-internal 'other-frame)
(call-interactively 'switch-to-buffer-other-frame)))
;;;###autoload
The file name is selected interactively by typing a substring.
For details of keybindings, do `\\[describe-function] ido-find-file'."
(interactive)
- (ido-file-internal 'otherwindow 'find-file-other-window))
+ (ido-file-internal 'other-window 'find-file-other-window))
;;;###autoload
(defun ido-find-alternate-file ()
The file name is selected interactively by typing a substring.
For details of keybindings, do `\\[describe-function] ido-find-file'."
(interactive)
- (ido-file-internal 'otherframe 'find-file-other-frame))
+ (ido-file-internal 'other-frame 'find-file-other-frame))
;;;###autoload
(defun ido-write-file ()
;;;###autoload
(defun ido-dired ()
- "Call dired the ido way.
+ "Call `dired' the ido way.
The directory is selected interactively by typing a substring.
For details of keybindings, do `\\[describe-function] ido-find-file'."
(interactive)
(ido-file-internal 'dired 'dired nil "Dired: " 'dir)))
(defun ido-list-directory ()
- "Call list-directory the ido way.
+ "Call `list-directory' the ido way.
The directory is selected interactively by typing a substring.
For details of keybindings, do `\\[describe-function] ido-find-file'."
(interactive)
try-single-dir-match
refresh)
- (ido-trace "\nexhibit" this-command)
- (ido-trace "dir" ido-current-directory)
- (ido-trace "contents" contents)
- (ido-trace "list" ido-cur-list)
- (ido-trace "matches" ido-matches)
- (ido-trace "rescan" ido-rescan)
+ (when ido-trace-enable
+ (ido-trace "\nexhibit" this-command)
+ (ido-trace "dir" ido-current-directory)
+ (ido-trace "contents" contents)
+ (ido-trace "list" ido-cur-list)
+ (ido-trace "matches" ido-matches)
+ (ido-trace "rescan" ido-rescan))
(save-excursion
(goto-char (point-max))
(setq refresh t))
((string-equal contents "./")
(setq refresh t))
- ((string-match "\\`~[a-zA-Z0-9]+/\\'" contents)
+ ((string-match "\\`~[-_a-zA-Z0-9]+[$]?/\\'" contents)
(ido-trace "new home" contents)
(ido-set-current-home contents)
(setq refresh t))
((= (length contents) 2)
"/")
(ido-matches
- (concat ido-current-directory (car ido-matches)))
+ (concat ido-current-directory (ido-name (car ido-matches))))
(t
(concat ido-current-directory (substring contents 0 -1)))))
(setq ido-text-init (substring contents -1))
ido-matches
(or (eq ido-enter-matching-directory 'first)
(null (cdr ido-matches)))
- (ido-final-slash (car ido-matches))
+ (ido-final-slash (ido-name (car ido-matches)))
(or try-single-dir-match
(eq ido-enter-matching-directory t)))
(ido-trace "single match" (car ido-matches))
(ido-set-current-directory
- (concat ido-current-directory (car ido-matches)))
+ (concat ido-current-directory (ido-name (car ido-matches))))
(setq ido-exit 'refresh)
(exit-minibuffer))