Is there a function in elisp which lists all features currently available in emacs?
By available feature, I mean all the symbols which can be used as arguments to (require 'some-symbol)
without getting an error (even if they haven't been loaded yet).
Interesting question. Well, let's say you just traverse your load-path
and grep on something like provide
- is that the list of "features" you're looking for?
(dolist (dirname load-path)
(shell-command (concat "grep '\(provide' " dirname "/*.el") "tmp")
(switch-to-buffer "tmp")
(append-to-buffer "provided" (point-min) (point-max))
(switch-to-buffer "provided"))
/Users/keith/.emacs.d/slime//hyperspec.el:(provide 'hyperspec)
/Users/keith/.emacs.d/slime//slime-autoloads.el: (provide 'slime-autoloads))
/Users/keith/.emacs.d/slime//slime.el:(provide 'slime)
/Users/keith/.emacs.d/geiser-0.4/elisp//geiser-autodoc.el:(provide 'geiser-autodoc)
/Users/keith/.emacs.d/geiser-0.4/elisp//geiser-base.el:(provide 'geiser-base)
/Users/keith/.emacs.d/geiser-0.4/elisp//geiser-company.el:(provide 'geiser-company)
/Users/keith/.emacs.d/geiser-0.4/elisp//geiser-compile.el:(provide 'geiser-compile)
/Users/keith/.emacs.d/geiser-0.4/elisp//geiser-completion.el:(provide 'geiser-completion)
/Users/keith/.emacs.d/geiser-0.4/elisp//geiser-connection.el:(provide 'geiser-connection)
...
(Running this provided the bonus of showing me some obsolete directories in my own load-path).
EDIT: Here's a little version incorporating Bruce's and tripleee's suggestions:
(defun list-features ()
(dolist (dirname load-path)
(shell-command (concat "grep --no-filename --text '\(provide\\|\(autoload' " dirname "/*.(el|elc)") "tmp")
(switch-to-buffer "tmp")
(append-to-buffer "features" (point-min) (point-max)))
;; Remove duplicates from finding provided functions in both .el and .elc files
(switch-to-buffer "features")
(shell-command-on-region (point-min) (point-max) "sort -u" nil t nil nil))