ido-ubiquitous.el 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. This variable has no effect unless `ido-everywhere' is also
  31. non-nil.
  32. Set it to nil using let in around-advice for functions where
  33. the original `completing-read' is required. For example, if a
  34. function `foo' absolutely cannot use ido, but must instead use
  35. the original `completing-read', define some advice like this:
  36. (defadvice foo (around original-completing-read-only activate)
  37. (let (ido-ubiquitous-enabled) ad-do-it))"
  38. :group 'ido
  39. :type 'boolean)
  40. ;;;###autoload
  41. (defadvice completing-read (around ido-ubiquitous activate)
  42. (if (or (not ido-mode)
  43. (not ido-everywhere)
  44. (not ido-ubiquitous-enabled)
  45. (boundp 'ido-cur-item)) ; Avoid infinite loop from ido calling completing-read
  46. ad-do-it
  47. (let ((allcomp (all-completions "" collection predicate)))
  48. (if allcomp
  49. (setq ad-return-value
  50. (ido-completing-read prompt
  51. allcomp
  52. nil require-match initial-input hist def))
  53. ad-do-it))))
  54. (provide 'ido-ubiquitous) ;;; ido-ubiquitous.el ends here