emacs - 列出所有必需的功能

标签 emacs elisp

elisp 中是否有一个函数可以列出 emacs 当前可用的所有功能?

可用功能是指所有可以用作 (require 'some-symbol) 参数而不会出错的符号(即使它们尚未加载)。

最佳答案

有趣的问题。好吧,假设您只是遍历您的 load-path 并在 provide 之类的东西上进行 grep - 这是您正在寻找的“功能”列表吗?

(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)
...

(运行它的好处是在我自己的加载路径中显示了一些过时的目录)。

编辑:这是一个结合了 Bruce 和 tripleee 的建议的小版本:

(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))

关于emacs - 列出所有必需的功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18173799/

相关文章:

emacs - emacs 中的字体锁定模式是什么?

emacs - Elisp 调试器不弹出

emacs - 显示 Emacs 中当前缓冲区的语法表名称

emacs - 如何轻松地试验涉及移动光标(插入符号)的 elisp 代码?

emacs - Emacs下Coq/Proof General中关键字和运算符的Unicode字形

Emacs Lisp 宏步进器

Emacs TAGS 表被 lex/yacc 文件中的 #line 指令混淆

emacs - 有没有办法在 Windows 上的 emacs 下运行 MIT 方案解释​​器?

emacs - org--agenda-prefix-format %?不起作用

emacs - 如何设置defcustom变量