ido-ubiquitous.el 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. ;;; ido-ubiquitous.el --- Use ido (nearly) everywhere.
  2. ;; Author: Ryan C. Thompson
  3. ;; URL: http://www.emacswiki.org/emacs/InteractivelyDoThings#toc13
  4. ;; Version: 0.2
  5. ;; Created: 2011-09-01
  6. ;; Keywords: convenience
  7. ;; EmacsWiki: InteractivelyDoThings
  8. ;; This file is NOT part of GNU Emacs.
  9. ;;; Commentary:
  10. ;;; License:
  11. ;; This program is free software; you can redistribute it and/or modify
  12. ;; it under the terms of the GNU General Public License as published by
  13. ;; the Free Software Foundation; either version 3, or (at your option)
  14. ;; any later version.
  15. ;;
  16. ;; This program is distributed in the hope that it will be useful,
  17. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. ;; GNU General Public License for more details.
  20. ;;
  21. ;; You should have received a copy of the GNU General Public License
  22. ;; along with GNU Emacs; see the file COPYING. If not, write to the
  23. ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  24. ;; Boston, MA 02110-1301, USA.
  25. ;;; Code:
  26. (require 'ido)
  27. ;;;###autoload
  28. (defvar ido-ubiquitous-enabled t
  29. "If non-nil, use ido-completing-read instead of completing-read if possible.
  30. Set it to nil using let in around-advice for functions where the
  31. original completing-read is required. For example, if a function
  32. foo absolutely must use the original completing-read, define some
  33. advice like this:
  34. (defadvice foo (around original-completing-read-only activate)
  35. (let (ido-ubiquitous-enabled) ad-do-it))")
  36. ;;;###autoload
  37. (defadvice completing-read (around use-ido-when-possible activate)
  38. (if (or (not ido-mode)
  39. (not ido-ubiquitous-enabled) ; Manual override disable ido
  40. (and (boundp 'ido-cur-list)
  41. ido-cur-list)) ; Avoid infinite loop from ido calling this
  42. ad-do-it
  43. (let ((allcomp (all-completions "" collection predicate)))
  44. (if allcomp
  45. (setq ad-return-value
  46. (ido-completing-read prompt allcomp
  47. nil require-match initial-input hist def))
  48. ad-do-it))))
  49. (provide 'ido-ubiquitous) ;;; ido-ubiquitous.el ends here