ido-mode

The ido-mode for Emacs changes several dialogs for buffers and file names to use a different completion function. It is the successor to iswitchb, which provided that functionality only for buffer switching.

This completion function provides direct feedback of the possible completions in the input line, and allows the input to be substrings. It is difficult to describe, just try it: M-x ido-find-file.

Configuration

(ido-mode 1)
(setq ;; Use it for many file dialogs
      ido-everywhere t
      ;; Don’t be case sensitive
      ido-case-fold t
      ;; If the file at point exists, use that
      ido-use-filename-at-point t
      ;; Or if it is an URL…
      ido-use-url-at-point t
      ;; Even if TAB completes uniquely,
      ;; still wait for RET
      ido-confirm-unique-completion t
      ;; If the input does not exist,
      ;; don’t look in unexpected places.
      ;; I probably want a new file.
      ido-auto-merge-work-directories-length -1)

;; Some changes in the mode map.
(add-hook 'ido-setup-hook
          (lambda ()
            ;; I use C-x C-f to get file names,
            ;; and use C-c C-u to get the file
            ;; name in the kill ring.
            (define-key ido-mode-map
                        (kbd "C-c")
                        (make-sparse-keymap))
            (define-key ido-mode-map
                        (kbd "C-c C-u")
                        'fc-ido-copy-selection)
            ;; UP and DOWN should look in previous
            ;; places, not cycle through directories.
            (define-key ido-mode-map
                        (kbd "")
                        'ido-prev-work-directory)
            (define-key ido-mode-map
                        (kbd "")
                        'ido-next-work-directory)))

(defun fc-ido-copy-selection ()
  "Copy the current ido selection to the kill ring."
  (interactive)
  (kill-new
   (abbreviate-file-name
    (concat ido-current-directory
            ido-text))))