diff options
| -rw-r--r-- | lisp/icomplete.el | 52 |
1 files changed, 37 insertions, 15 deletions
diff --git a/lisp/icomplete.el b/lisp/icomplete.el index e1d6236943c..777fdce13a0 100644 --- a/lisp/icomplete.el +++ b/lisp/icomplete.el | |||
| @@ -223,21 +223,7 @@ Last entry becomes the first and can be selected with | |||
| 223 | (push (car last) comps) | 223 | (push (car last) comps) |
| 224 | (completion--cache-all-sorted-completions beg end comps)))) | 224 | (completion--cache-all-sorted-completions beg end comps)))) |
| 225 | 225 | ||
| 226 | ;;; `ido-mode' emulation | 226 | ;;; Helpers for `fido-mode' (or `ido-mode' emulation) |
| 227 | ;;; | ||
| 228 | ;;; The following "magic-ido" commands can be bound in | ||
| 229 | ;;; `icomplete-mode-map' to make `icomplete-mode' behave more like | ||
| 230 | ;;; `ido-mode'. Evaluate this to try it out. | ||
| 231 | ;;; | ||
| 232 | ;;; (let ((imap icomplete-minibuffer-map)) | ||
| 233 | ;;; (define-key imap (kbd "C-k") 'icomplete-magic-ido-kill) | ||
| 234 | ;;; (define-key imap (kbd "C-d") 'icomplete-magic-ido-delete-char) | ||
| 235 | ;;; (define-key imap (kbd "RET") 'icomplete-magic-ido-ret) | ||
| 236 | ;;; (define-key imap (kbd "DEL") 'icomplete-magic-ido-backward-updir)) | ||
| 237 | ;;; | ||
| 238 | ;;; For more ido behaviour, you'll probably like this too: | ||
| 239 | ;;; | ||
| 240 | ;;; (setq icomplete-tidy-shadowed-file-names t) | ||
| 241 | ;;; | 227 | ;;; |
| 242 | (defun icomplete-magic-ido-kill () | 228 | (defun icomplete-magic-ido-kill () |
| 243 | "Kill line or current completion, like `ido-mode'. | 229 | "Kill line or current completion, like `ido-mode'. |
| @@ -312,6 +298,42 @@ require user confirmation." | |||
| 312 | (backward-kill-sexp 1) | 298 | (backward-kill-sexp 1) |
| 313 | (call-interactively 'backward-delete-char)))) | 299 | (call-interactively 'backward-delete-char)))) |
| 314 | 300 | ||
| 301 | (defvar icomplete-fido-mode-map | ||
| 302 | (let ((map (make-sparse-keymap))) | ||
| 303 | (define-key map (kbd "C-k") 'icomplete-magic-ido-kill) | ||
| 304 | (define-key map (kbd "C-d") 'icomplete-magic-ido-delete-char) | ||
| 305 | (define-key map (kbd "RET") 'icomplete-magic-ido-ret) | ||
| 306 | (define-key map (kbd "DEL") 'icomplete-magic-ido-backward-updir) | ||
| 307 | (define-key map (kbd "M-j") 'exit-minibuffer) | ||
| 308 | (define-key map (kbd "C-s") 'icomplete-forward-completions) | ||
| 309 | (define-key map (kbd "C-r") 'icomplete-backward-completions) | ||
| 310 | map) | ||
| 311 | "Keymap used by `fido-mode' in the minibuffer.") | ||
| 312 | |||
| 313 | (defun icomplete--fido-mode-setup () | ||
| 314 | "Setup `fido-mode''s minibuffer." | ||
| 315 | (use-local-map (make-composed-keymap icomplete-fido-mode-map | ||
| 316 | (current-local-map))) | ||
| 317 | (setq-local icomplete-tidy-shadowed-file-names t | ||
| 318 | icomplete-show-matches-on-no-input t | ||
| 319 | icomplete-hide-common-prefix nil | ||
| 320 | completion-styles '(flex) | ||
| 321 | completion-category-defaults nil)) | ||
| 322 | |||
| 323 | ;;;###autoload | ||
| 324 | (define-minor-mode fido-mode | ||
| 325 | "An enhanced `icomplete-mode' that emulates `ido-mode'. | ||
| 326 | |||
| 327 | This global minor mode makes minibuffer completion behave | ||
| 328 | more like `ido-mode' than regular `icomplete-mode'." | ||
| 329 | :global t :group 'icomplete | ||
| 330 | (remove-hook 'minibuffer-setup-hook #'icomplete-minibuffer-setup) | ||
| 331 | (remove-hook 'minibuffer-setup-hook #'icomplete--fido-mode-setup) | ||
| 332 | (when fido-mode | ||
| 333 | (setq icomplete-mode t) | ||
| 334 | (add-hook 'minibuffer-setup-hook #'icomplete-minibuffer-setup) | ||
| 335 | (add-hook 'minibuffer-setup-hook #'icomplete--fido-mode-setup))) | ||
| 336 | |||
| 315 | ;;;_ > icomplete-mode (&optional prefix) | 337 | ;;;_ > icomplete-mode (&optional prefix) |
| 316 | ;;;###autoload | 338 | ;;;###autoload |
| 317 | (define-minor-mode icomplete-mode | 339 | (define-minor-mode icomplete-mode |