Function: ido-mode

ido-mode is an autoloaded, interactive and byte-compiled function defined in ido.el.gz.

Signature

(ido-mode &optional ARG)

Documentation

Toggle Ido mode on or off.

With ARG, turn Ido mode on if arg is positive, off otherwise. Turning on Ido mode will remap (via a minor-mode keymap) the default keybindings for the find-file and switch-to-buffer families of commands to the Ido versions of these functions. However, if ARG arg equals files, remap only commands for files, or if it equals buffers, remap only commands for buffer switching. This function also adds a hook to the minibuffer.

Probably introduced at or before Emacs version 27.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/ido.el.gz
;;;###autoload
(defun ido-mode (&optional arg)
  "Toggle Ido mode on or off.
With ARG, turn Ido mode on if arg is positive, off otherwise.
Turning on Ido mode will remap (via a minor-mode keymap) the default
keybindings for the `find-file' and `switch-to-buffer' families of
commands to the Ido versions of these functions.
However, if ARG arg equals `files', remap only commands for files, or
if it equals `buffers', remap only commands for buffer switching.
This function also adds a hook to the minibuffer."
  (interactive "P")
  (setq ido-mode
	(cond
	 ((null arg) (if ido-mode nil 'both))
	 ((eq arg t) 'both)
	 ((eq arg 'files) 'file)
	 ((eq arg 'buffers) 'buffer)
	 ((memq arg '(file buffer both)) arg)
	 ((> (prefix-numeric-value arg) 0) 'both)
	 (t nil)))

  (ido-everywhere (if (and ido-mode ido-everywhere) 1 -1))

  (when ido-mode
    (ido-common-initialization)
    (ido-load-history)

    (add-hook 'kill-emacs-hook #'ido-kill-emacs-hook)

    (let ((map (make-sparse-keymap)))
      (when (memq ido-mode '(file both))
	(define-key map [remap find-file] 'ido-find-file)
	(define-key map [remap find-file-read-only] 'ido-find-file-read-only)
	(define-key map [remap find-alternate-file] 'ido-find-alternate-file)
	(define-key map [remap write-file] 'ido-write-file)
	(define-key map [remap insert-file] 'ido-insert-file)
	(define-key map [remap list-directory] 'ido-list-directory)
	(define-key map [remap dired] 'ido-dired)
	(define-key map [remap find-file-other-window]
          'ido-find-file-other-window)
	(define-key map [remap find-file-read-only-other-window]
          'ido-find-file-read-only-other-window)
        (define-key map [remap find-alternate-file-other-window]
          #'ido-find-alternate-file-other-window)
        (define-key map [remap dired-other-window] #'ido-dired-other-window)
	(define-key map [remap find-file-other-frame]
          'ido-find-file-other-frame)
	(define-key map [remap find-file-read-only-other-frame]
          'ido-find-file-read-only-other-frame)
        (define-key map [remap dired-other-frame] #'ido-dired-other-frame))

      (when (memq ido-mode '(buffer both))
	(define-key map [remap switch-to-buffer] 'ido-switch-buffer)
	(define-key map [remap switch-to-buffer-other-window]
          'ido-switch-buffer-other-window)
	(define-key map [remap switch-to-buffer-other-frame]
          'ido-switch-buffer-other-frame)
	(define-key map [remap insert-buffer] 'ido-insert-buffer)
	(define-key map [remap kill-buffer] 'ido-kill-buffer)
	(define-key map [remap display-buffer] 'ido-display-buffer)
        (define-key map [remap display-buffer-other-frame]
          #'ido-display-buffer-other-frame))

      (if ido-minor-mode-map-entry
	  (setcdr ido-minor-mode-map-entry map)
	(setq ido-minor-mode-map-entry (cons 'ido-mode map))
	(add-to-list 'minor-mode-map-alist ido-minor-mode-map-entry))))

  (when (called-interactively-p 'any)
    (message "Ido mode %s" (if ido-mode "enabled" "disabled"))))