:type 'boolean
:group 'ido)
+(defcustom ido-cannot-complete-command 'ido-completion-help
+ "*Command run when `ido-complete' can't complete any more.
+The most useful values are `ido-completion-help', which pops up a
+window with completion alternatives, or `ido-next-match' or
+`ido-prev-match', which cycle the buffer list."
+ :type 'function
+ :group 'ido)
+
+
(defcustom ido-record-commands t
"*Non-nil means that `ido' will record commands in command history.
Note that the non-ido equivalent command is recorded."
(defcustom ido-separator nil
"*String used by ido to separate the alternatives in the minibuffer.
Obsolete. Set 3rd element of `ido-decorations' instead."
- :type 'string
+ :type '(choice string (const nil))
:group 'ido)
(defcustom ido-decorations '( "{" "}" " | " " | ..." "[" "]" " [No match]" " [Matched]")
(defvar ido-buffer-history nil
"History of buffers selected using `ido-switch-buffer'.")
-(defvar ido-xemacs (string-match "XEmacs" (emacs-version))
- "Non-nil if we are running XEmacs. Otherwise, assume we are running Emacs.")
-
(defvar ido-last-directory-list nil
"List of last selected directory paths.
See `ido-enable-last-directory-history' for details.")
"List of file-name-all-completions results.
Each element in the list is of the form (dir (mtime) file...).")
+(defvar ido-ignore-item-temp-list nil
+ "List of items to ignore in current ido invocation.
+Intended to be let-bound by functions which calls ido repeatedly.
+Should never be set permanently.")
+
;; Temporary storage
(defvar ido-eoinput 1
(define-key map "\C-s" 'ido-next-match)
(define-key map "\C-t" 'ido-toggle-regexp)
(define-key map "\C-z" 'ido-undo-merge-work-directory)
+ (define-key map [(control ? )] 'ido-restrict-to-matches)
+ (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 "?" 'ido-completion-help)
(setq ido-rescan t)
(setq ido-rotate nil)
(setq ido-text "")
- (if ido-set-default-item
- (setq ido-default-item
- (cond
- ((eq item 'buffer)
- (if (bufferp default) (buffer-name default) default))
- ((stringp default) default)
- ((eq item 'file)
- (and ido-enable-last-directory-history
- (let ((d (assoc ido-current-directory ido-last-directory-list)))
- (and d (cdr d))))))
- ido-set-default-item nil))
+ (when ido-set-default-item
+ (setq ido-default-item
+ (cond
+ ((eq item 'buffer)
+ (if (bufferp default) (buffer-name default) default))
+ ((stringp default) default)
+ ((eq item 'file)
+ (and ido-enable-last-directory-history
+ (let ((d (assoc ido-current-directory ido-last-directory-list)))
+ (and d (cdr d)))))))
+ (if (member ido-default-item ido-ignore-item-temp-list)
+ (setq ido-default-item nil))
+ (setq ido-set-default-item nil))
(if ido-process-ignore-lists-inhibit
(setq ido-process-ignore-lists nil))
(t
(setq ido-selected
- (if (and ido-matches (equal ido-final-text ""))
- (ido-name (car ido-matches)) ;; possibly choose the default file
- (if (or (eq ido-exit 'takeprompt)
- (null ido-matches))
- ido-final-text
- ;; else take head of list
- (ido-name (car ido-matches)))))
+ (if (or (eq ido-exit 'takeprompt)
+ (null ido-matches))
+ ido-final-text
+ ;; else take head of list
+ (ido-name (car ido-matches))))
(cond
((eq item 'buffer)
(or (ido-is-root-directory)
(ido-set-current-directory (file-name-directory (substring ido-current-directory 0 -1))))
(setq ido-set-default-item t))
-
((and (string-equal ido-current-directory "/")
(string-match "..:\\'" ido-selected)) ;; Ange-ftp
(ido-set-current-directory "/" ido-selected)
;; Check buf is non-nil.
((not buf) nil)
+ ((= (length buf) 0) nil)
;; View buffer if it exists
((get-buffer buf)
((not ido-matches)
(when ido-completion-buffer
- (setq this-command 'ido-completion-help)
- (ido-completion-help)))
+ (call-interactively (setq this-command ido-cannot-complete-command))))
((= 1 (length ido-matches))
;; only one choice, so select it.
(delete-region (minibuffer-prompt-end) (point))
(insert res))
;; else nothing to complete
- (ido-completion-help)
+ (call-interactively (setq this-command ido-cannot-complete-command))
)))))
(defun ido-complete-space ()
(if (> i 0)
(setq ido-cur-list (ido-chop ido-cur-list (nth i ido-matches)))))))
+(defun ido-restrict-to-matches ()
+ "Set current item list to the currently matched items."
+ (interactive)
+ (when ido-matches
+ (setq ido-cur-list ido-matches
+ ido-text-init ""
+ ido-rescan nil
+ ido-exit 'keep)
+ (exit-minibuffer)))
+
(defun ido-chop (items elem)
"Remove all elements before ELEM and put them at the end of ITEMS."
(let ((ret nil)
res)
(while paths
(setq path (car paths)
- paths (cdr paths)
paths (cdr paths))
(if (and (string-match "^/" path)
(file-exists-p path))
(mapcar
(lambda (x)
(let ((name (buffer-name x)))
- (if (not (or (ido-ignore-item-p name ido-ignore-buffers) (memq name visible)))
+ (if (not (or (ido-ignore-item-p name ido-ignore-buffers) (member name visible)))
name)))
(buffer-list frame))))
(defun ido-get-bufname (win)
;; Used by `ido-get-buffers-in-frames' to walk through all windows
(let ((buf (buffer-name (window-buffer win))))
- (if (not (member buf ido-bufs-in-frame))
- ;; Only add buf if it is not already in list.
- ;; This prevents same buf in two different windows being
- ;; put into the list twice.
- (setq ido-bufs-in-frame
- (cons buf ido-bufs-in-frame)))))
+ (unless (or (member buf ido-bufs-in-frame)
+ (member buf ido-ignore-item-temp-list))
+ ;; Only add buf if it is not already in list.
+ ;; This prevents same buf in two different windows being
+ ;; put into the list twice.
+ (setq ido-bufs-in-frame
+ (cons buf ido-bufs-in-frame)))))
;;; FIND MATCHING ITEMS
(defun ido-ignore-item-p (name re-list &optional ignore-ext)
;; Return t if the buffer or file NAME should be ignored.
- (and ido-process-ignore-lists re-list
+ (or (member name ido-ignore-item-temp-list)
+ (and
+ ido-process-ignore-lists re-list
(let ((data (match-data))
(ext-list (and ignore-ext ido-ignore-extensions
completion-ignored-extensions))
(if ignorep
(setq ido-ignored-list (cons name ido-ignored-list)))
(set-match-data data)
- ignorep)))
+ ignorep))))
;; Private variable used by `ido-word-matching-substring'.
(ido-all-completions))
(t
(copy-sequence (or ido-matches ido-cur-list)))))))
- (if ido-xemacs
+ (if (featurep 'xemacs)
;; XEmacs extents are put on by default, doesn't seem to be
;; any way of switching them off.
;; This obscure code avoids a byte compiler warning in Emacs.
(select-frame-set-input-focus newframe)
(raise-frame newframe)
(select-frame newframe)
- (if (not ido-xemacs)
+ (unless (featurep 'xemacs)
(set-mouse-position (selected-frame) (1- (frame-width)) 0)))
(select-window win))
(t
(display-buffer buffer))
((eq method 'otherframe)
- (progn
- (switch-to-buffer-other-frame buffer)
- (if (not ido-xemacs)
- (if (fboundp 'select-frame-set-input-focus)
- (select-frame-set-input-focus (selected-frame))
- (set-mouse-position (selected-frame) (1- (frame-width)) 0)))
- )))))
+ (switch-to-buffer-other-frame buffer)
+ (unless (featurep 'xemacs)
+ (select-frame-set-input-focus (selected-frame)))
+ ))))
(defun ido-window-buffer-p (buffer)
;; If BUFFER is visible in the current frame, return nil.
(let ((blist (ido-get-buffers-in-frames 'current)))
;;If the buffer is visible in current frame, return nil
- (if (memq buffer blist)
+ (if (member buffer blist)
nil
;; maybe in other frame or icon
(get-buffer-window buffer 0) ; better than 'visible
"Minibuffer setup hook for `ido'."
;; Copied from `icomplete-minibuffer-setup-hook'.
(when (and (boundp 'ido-completing-read)
- (or ido-xemacs (= ido-use-mycompletion-depth (minibuffer-depth))))
+ (or (featurep 'xemacs)
+ (= ido-use-mycompletion-depth (minibuffer-depth))))
(add-hook 'pre-command-hook 'ido-tidy nil t)
(add-hook 'post-command-hook 'ido-exhibit nil t)
(setq cua-inhibit-cua-keys t)
- (when ido-xemacs
+ (when (featurep 'xemacs)
(ido-exhibit)
(goto-char (point-min)))
(run-hooks 'ido-minibuffer-setup-hook)))
(defun ido-read-file-name (prompt &optional dir default-filename mustmatch initial predicate)
"Read file name, prompting with PROMPT and completing in directory DIR.
See `read-file-name' for additional parameters."
- (message "%S %S %S %S" this-command ido-read-file-name-non-ido
- predicate (memq this-command ido-read-file-name-non-ido))
(cond
((or (eq predicate 'file-directory-p)
(memq this-command ido-read-file-name-as-directory-commands))
(ido-read-directory-name prompt dir default-filename mustmatch initial))
((and (not (memq this-command ido-read-file-name-non-ido))
(or (null predicate) (eq predicate 'file-exists-p)))
- (message "gotit")
(let (filename
ido-saved-vc-mt
(vc-master-templates (and (boundp 'vc-master-templates) vc-master-templates))