summaryrefslogtreecommitdiff
path: root/lisp/ido.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/ido.el')
-rw-r--r--lisp/ido.el224
1 files changed, 115 insertions, 109 deletions
diff --git a/lisp/ido.el b/lisp/ido.el
index 57e79500413..520513b1d29 100644
--- a/lisp/ido.el
+++ b/lisp/ido.el
@@ -354,8 +354,8 @@ The following values are possible:
Setting this variable directly does not take effect;
use either \\[customize] or the function `ido-mode'."
- :set #'(lambda (_symbol value)
- (ido-mode (or value 0)))
+ :set (lambda (_symbol value)
+ (ido-mode (or value 0)))
:initialize #'custom-initialize-default
:require 'ido
:link '(emacs-commentary-link "ido.el")
@@ -554,7 +554,7 @@ See `ido-last-directory-list' and `ido-save-directory-list-file'."
"Maximum number of working directories to record.
This is the list of directories where files have most recently been opened.
See `ido-work-directory-list' and `ido-save-directory-list-file'."
- :type 'integer)
+ :type 'natnum)
(defcustom ido-work-directory-list-ignore-regexps nil
"List of regexps matching directories which should not be recorded.
@@ -620,9 +620,9 @@ hosts on first use of UNC path."
(function-item :tag "Use `NET VIEW'"
:value ido-unc-hosts-net-view)
(function :tag "Your own function"))
- :set #'(lambda (symbol value)
- (set symbol value)
- (setq ido-unc-hosts-cache t)))
+ :set (lambda (symbol value)
+ (set symbol value)
+ (setq ido-unc-hosts-cache t)))
(defcustom ido-downcase-unc-hosts t
"Non-nil if UNC host names should be downcased."
@@ -920,85 +920,76 @@ The fallback command is passed as an argument to the functions."
;;;; Keymaps
-(defvar ido-common-completion-map
- (let ((map (make-sparse-keymap)))
- (set-keymap-parent map minibuffer-local-map)
- (define-key map "\C-a" 'ido-toggle-ignore)
- (define-key map "\C-c" 'ido-toggle-case)
- (define-key map "\C-e" 'ido-edit-input)
- (define-key map "\t" 'ido-complete)
- (define-key map " " 'ido-complete-space)
- (define-key map "\C-j" 'ido-select-text)
- (define-key map "\C-m" 'ido-exit-minibuffer)
- (define-key map "\C-p" 'ido-toggle-prefix)
- (define-key map "\C-r" 'ido-prev-match)
- (define-key map "\C-s" 'ido-next-match)
- (define-key map [?\C-.] 'ido-next-match)
- (define-key map [?\C-,] 'ido-prev-match)
- (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 "?" 'ido-completion-help)
- (define-key map "\C-b" 'ido-magic-backward-char)
- (define-key map "\C-f" 'ido-magic-forward-char)
- (define-key map "\C-d" 'ido-magic-delete-char)
- map)
- "Keymap for all Ido commands.")
-
-(defvar ido-file-dir-completion-map
- (let ((map (make-sparse-keymap)))
- (set-keymap-parent map ido-common-completion-map)
- (define-key map "\C-x\C-b" 'ido-enter-switch-buffer)
- (define-key map "\C-x\C-f" 'ido-fallback-command)
- (define-key map "\C-x\C-d" 'ido-enter-dired)
- (define-key map [down] 'ido-next-match-dir)
- (define-key map [up] 'ido-prev-match-dir)
- (define-key map [(meta up)] 'ido-prev-work-directory)
- (define-key map [(meta down)] 'ido-next-work-directory)
- (define-key map [backspace] 'ido-delete-backward-updir)
- (define-key map "\d" 'ido-delete-backward-updir)
- (define-key map [remap delete-backward-char] 'ido-delete-backward-updir) ; BS
- (define-key map [remap backward-kill-word] 'ido-delete-backward-word-updir) ; M-DEL
- (define-key map [(control backspace)] 'ido-up-directory)
- (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)
- (define-key map [(meta ?n)] 'ido-next-work-directory)
- (define-key map [(meta ?o)] 'ido-prev-work-file)
- (define-key map [(meta control ?o)] 'ido-next-work-file)
- (define-key map [(meta ?p)] 'ido-prev-work-directory)
- (define-key map [(meta ?s)] 'ido-merge-work-directories)
- map)
- "Keymap for Ido file and directory commands.")
-
-(defvar ido-file-completion-map
- (let ((map (make-sparse-keymap)))
- (set-keymap-parent map ido-file-dir-completion-map)
- (define-key map "\C-k" 'ido-delete-file-at-head)
- (define-key map "\C-o" 'ido-copy-current-word)
- (define-key map "\C-w" 'ido-copy-current-file-name)
- (define-key map [(meta ?l)] 'ido-toggle-literal)
- map)
- "Keymap for Ido file commands.")
-
-(defvar ido-buffer-completion-map
- (let ((map (make-sparse-keymap)))
- (set-keymap-parent map ido-common-completion-map)
- (define-key map "\C-x\C-f" 'ido-enter-find-file)
- (define-key map "\C-x\C-b" 'ido-fallback-command)
- (define-key map "\C-k" 'ido-kill-buffer-at-head)
- (define-key map [?\C-\S-b] 'ido-bury-buffer-at-head)
- (define-key map "\C-o" 'ido-toggle-virtual-buffers)
- map)
- "Keymap for Ido buffer commands.")
+(defvar-keymap ido-common-completion-map
+ :doc "Keymap for all Ido commands."
+ :parent minibuffer-local-map
+ "C-a" #'ido-toggle-ignore
+ "C-c" #'ido-toggle-case
+ "C-e" #'ido-edit-input
+ "TAB" #'ido-complete
+ "SPC" #'ido-complete-space
+ "C-j" #'ido-select-text
+ "C-m" #'ido-exit-minibuffer
+ "C-p" #'ido-toggle-prefix
+ "C-r" #'ido-prev-match
+ "C-s" #'ido-next-match
+ "C-." #'ido-next-match
+ "C-," #'ido-prev-match
+ "C-t" #'ido-toggle-regexp
+ "C-z" #'ido-undo-merge-work-directory
+ "C-SPC" #'ido-restrict-to-matches
+ "M-SPC" #'ido-take-first-match
+ "C-@" #'ido-restrict-to-matches
+ "<right>" #'ido-next-match
+ "<left>" #'ido-prev-match
+ "?" #'ido-completion-help
+ "C-b" #'ido-magic-backward-char
+ "C-f" #'ido-magic-forward-char
+ "C-d" #'ido-magic-delete-char)
+
+(defvar-keymap ido-file-dir-completion-map
+ :doc "Keymap for Ido file and directory commands."
+ :parent ido-common-completion-map
+ "C-x C-b" #'ido-enter-switch-buffer
+ "C-x C-f" #'ido-fallback-command
+ "C-x C-d" #'ido-enter-dired
+ "<down>" #'ido-next-match-dir
+ "<up>" #'ido-prev-match-dir
+ "M-<up>" #'ido-prev-work-directory
+ "M-<down>" #'ido-next-work-directory
+ "<backspace>" #'ido-delete-backward-updir
+ "DEL" #'ido-delete-backward-updir
+ "<remap> <delete-backward-char>" #'ido-delete-backward-updir
+ "<remap> <backward-kill-word>" #'ido-delete-backward-word-updir
+ "C-<backspace>" #'ido-up-directory
+ "C-l" #'ido-reread-directory
+ "M-d" #'ido-wide-find-dir-or-delete-dir
+ "M-b" #'ido-push-dir
+ "M-v" #'ido-push-dir-first
+ "M-f" #'ido-wide-find-file-or-pop-dir
+ "M-k" #'ido-forget-work-directory
+ "M-m" #'ido-make-directory
+ "M-n" #'ido-next-work-directory
+ "M-o" #'ido-prev-work-file
+ "C-M-o" #'ido-next-work-file
+ "M-p" #'ido-prev-work-directory
+ "M-s" #'ido-merge-work-directories)
+
+(defvar-keymap ido-file-completion-map
+ :doc "Keymap for Ido file commands."
+ :parent ido-file-dir-completion-map
+ "C-o" #'ido-copy-current-word
+ "C-w" #'ido-copy-current-file-name
+ "M-l" #'ido-toggle-literal)
+
+(defvar-keymap ido-buffer-completion-map
+ :doc "Keymap for Ido buffer commands."
+ :parent ido-common-completion-map
+ "C-x C-f" #'ido-enter-find-file
+ "C-x C-b" #'ido-fallback-command
+ "C-k" #'ido-kill-buffer-at-head
+ "C-S-b" #'ido-bury-buffer-at-head
+ "C-o" #'ido-toggle-virtual-buffers)
;;;; Persistent variables
@@ -2247,8 +2238,7 @@ If cursor is not at the end of the user input, move to end of input."
(t
(add-to-history 'buffer-name-history buf)
(setq buf (get-buffer-create buf))
- (if (fboundp 'set-buffer-major-mode)
- (set-buffer-major-mode buf))
+ (set-buffer-major-mode buf)
(ido-visit-buffer buf method t))))))
(defun ido-record-work-directory (&optional dir)
@@ -3215,12 +3205,18 @@ instead removed from the current item list."
;; File list sorting
(defun ido-file-lessp (a b)
- ;; Simple compare two file names.
+ "Simple compare two file names."
+ (when ido-case-fold
+ (setq a (downcase a)
+ b (downcase b)))
(string-lessp (ido-no-final-slash a) (ido-no-final-slash b)))
(defun ido-file-extension-lessp (a b)
- ;; Compare file names according to ido-file-extensions-order list.
+ "Compare file names according to ido-file-extensions-order list."
+ (when ido-case-fold
+ (setq a (downcase a)
+ b (downcase b)))
(let ((n (compare-strings a 0 nil b 0 nil nil))
lessp p)
(if (eq n t)
@@ -3949,7 +3945,7 @@ If `ido-change-word-sub' cannot be found in WORD, return nil."
;; In the new buffer, go to the first completion.
;; FIXME: Perhaps this should be done in `ido-completion-help'.
(when (bobp)
- (next-completion 1)))))
+ (first-completion)))))
(defun ido-completion-auto-help ()
"Call `ido-completion-help' if `completion-auto-help' is non-nil."
@@ -3970,7 +3966,7 @@ If `ido-change-word-sub' cannot be found in WORD, return nil."
(if (and (eq last-command this-command) temp-buf)
;; scroll buffer
(let (win (buf (current-buffer)))
- (display-buffer temp-buf nil nil)
+ (display-buffer temp-buf)
(set-buffer temp-buf)
(setq win (get-buffer-window temp-buf))
(if (pos-visible-in-window-p (point-max) win)
@@ -3985,24 +3981,34 @@ If `ido-change-word-sub' cannot be found in WORD, return nil."
(set-buffer buf))
(setq display-it t))
(if (and ido-completion-buffer display-it)
- (with-output-to-temp-buffer ido-completion-buffer
- (let ((completion-list (sort
- (cond
- (ido-directory-too-big
- (message "Reading directory...")
- (setq ido-directory-too-big nil
- ido-ignored-list nil
- ido-cur-list (ido-all-completions)
- ido-rescan t)
- (ido-set-matches)
- (or ido-matches ido-cur-list))
- (ido-use-merged-list
- (ido-flatten-merged-list (or ido-matches ido-cur-list)))
- ((or full-list ido-completion-buffer-all-completions)
- (ido-all-completions))
- (t
- (copy-sequence (or ido-matches ido-cur-list))))
- #'ido-file-lessp)))
+ (with-temp-buffer-window ido-completion-buffer
+ '((display-buffer-reuse-window display-buffer-at-bottom)
+ (window-height . fit-window-to-buffer))
+ nil
+ (let* ((comps
+ (cond
+ (ido-directory-too-big
+ (message "Reading directory...")
+ (setq ido-directory-too-big nil
+ ido-ignored-list nil
+ ido-cur-list (ido-all-completions)
+ ido-rescan t)
+ (ido-set-matches)
+ (or ido-matches ido-cur-list))
+ (ido-use-merged-list
+ (ido-flatten-merged-list (or ido-matches ido-cur-list)))
+ ((or full-list ido-completion-buffer-all-completions)
+ (ido-all-completions))
+ (t
+ (copy-sequence (or ido-matches ido-cur-list)))))
+ (completion-list
+ ;; If we have an alist COMPLETIONS, transform to a
+ ;; simple list first.
+ (sort (if (and (consp comps)
+ (consp (car comps)))
+ (mapcar #'car comps)
+ comps)
+ #'ido-file-lessp)))
;;(add-hook 'completion-setup-hook #'completion-setup-function)
(display-completion-list completion-list))))))