ido-ubiquitous.el 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. (defcustom 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
  31. the original `completing-read' is required. For example, if a
  32. function `foo' absolutely cannot use ido, but must instead use
  33. the original `completing-read', define some advice like this:
  34. (defadvice foo (around original-completing-read-only activate)
  35. (let (ido-ubiquitous-enabled) ad-do-it))"
  36. :group 'ido
  37. :type 'boolean)
  38. ;;;###autoload
  39. (defadvice completing-read (around use-ido-when-possible activate)
  40. (if (or (not ido-mode)
  41. (not ido-ubiquitous-enabled) ; Manual override disable ido
  42. (and (boundp 'ido-cur-list)
  43. ido-cur-list)) ; Avoid infinite loop from ido calling this
  44. ad-do-it
  45. (let ((allcomp (all-completions "" collection predicate)))
  46. (if allcomp
  47. (setq ad-return-value
  48. (ido-completing-read prompt allcomp
  49. nil require-match initial-input hist def))
  50. ad-do-it))))
  51. (provide 'ido-ubiquitous) ;;; ido-ubiquitous.el ends here