ido-describe-fns.el 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. ;;; ido-describe-fns.el --- -*- lexical-binding: t -*-
  2. ;; Copyright (C) 2017 Ryan C. Thompson
  3. ;; Filename: ido-describe-fns.el
  4. ;; Author: Ryan C. Thompson
  5. ;; Created: Tue May 16 18:23:13 2017 (-0400)
  6. ;; Version: 3.17
  7. ;; Package-Requires: ((emacs "26") (ido-completing-read+ 3.17) (ido-ubiquitous 3.17))
  8. ;; URL: https://github.com/DarwinAwardWinner/ido-ubiquitous
  9. ;; Keywords: ido, completion, convenience
  10. ;; This file is NOT part of GNU Emacs.
  11. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  12. ;;
  13. ;;; Commentary:
  14. ;; This package is an extension for ido-ubiquitous that implements ido
  15. ;; completion for the new implementation of the `describe-*' family of
  16. ;; commands. In Emacs 26 and above, these commands no longer work with
  17. ;; ido-ubiquitous because they now use a function-based collection
  18. ;; argument to implement auto-loading of the file corresponding to the
  19. ;; prefix you entered in order to offer completions of symbols from
  20. ;; that file.
  21. ;; Note that there is no separate mode to enable. If
  22. ;; `ido-ubiquitous-mode' is already enabled, then simply loading this
  23. ;; package will enable it as well.
  24. ;; This package has no effect in Emacs versions earlier than 26, so it
  25. ;; is safe to install it unconditionally in an Emacs config shared by
  26. ;; multiple Emacs versions.
  27. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  28. ;;
  29. ;; This program is free software: you can redistribute it and/or modify
  30. ;; it under the terms of the GNU General Public License as published by
  31. ;; the Free Software Foundation, either version 3 of the License, or (at
  32. ;; your option) any later version.
  33. ;;
  34. ;; This program is distributed in the hope that it will be useful, but
  35. ;; WITHOUT ANY WARRANTY; without even the implied warranty of
  36. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  37. ;; General Public License for more details.
  38. ;;
  39. ;; You should have received a copy of the GNU General Public License
  40. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  41. ;;
  42. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  43. ;;
  44. ;;; Code:
  45. (defconst ido-describe-fns-version "3.17"
  46. "Currently running version of ido-describe-fns.
  47. Note that when you update ido-describe-fns, this variable may not
  48. be updated until you restart Emacs.")
  49. (require 'ido)
  50. (require 'ido-completing-read+)
  51. (require 'ido-ubiquitous)
  52. (defun ido-descfns-maybe-load-prefixes (string)
  53. "Load any files needed to complete the current input.
  54. This function auto-loads new files in the same way as
  55. `help--symbol-completion-table', but without doing any
  56. completion.
  57. Returns non-nil if any new files were loaded."
  58. (when (bound-and-true-p help-definition-prefixes)
  59. (let* ((old-load-history load-history)
  60. (prefixes (radix-tree-prefixes (help-definition-prefixes) string)))
  61. (help--load-prefixes prefixes)
  62. (not (eq load-history old-load-history)))))
  63. ;; `ido-exhibit' is the ido post-command hook
  64. (defadvice ido-exhibit (before ido-descfns activate)
  65. "Maybe load new files and update possible ido completions.
  66. Has no effect unless `ido-descfns-enable-this-call' is non-nil."
  67. (when (and (ido-ubiquitous-active)
  68. (ido-descfns-maybe-load-prefixes ido-text))
  69. (with-no-warnings
  70. (setq ido-cur-list
  71. (all-completions "" obarray (nth 2 ido-cr+-orig-completing-read-args)))
  72. (ido-ubiquitous--debug-message "ido-describe-fns loaded new files. `ido-cur-list' now has %i items" (length ido-cur-list)))))
  73. (provide 'ido-describe-fns)
  74. ;;; ido-describe-fns.el ends here