ido-ubiquitous.el 2.3 KB

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