【问题标题】:Emacs stock major modes listEmacs 库存主要模式列表
【发布时间】:2011-04-04 08:44:40
【问题描述】:

是否有选择 Emacs 模式的命令列表?我如何知道我的平台上有哪些模式可用?我的意思是您在M-x 之后键入的模式名称列表。

【问题讨论】:

    标签: emacs


    【解决方案1】:

    键入M-x *-mode <Tab>,emacs 将列出所有以-mode 结尾的交互式命令当前加载的

    如果没有先在加载路径中加载所有 elisp 文件,我不确定您是否可以轻松查看 require 之后可用的模式。

    【讨论】:

    • 库存的应该都定义了自动加载,所以你应该可以接受。 Apropos (C-h a) 在这里可能也不错。
    • @spong,如果您真的想要那些尚未加载的,您可能可以编写一个 elisp 函数来加载加载路径中的所有内容,然后执行此操作。不过,这可能不是一个好主意。
    【解决方案2】:

    一个列出主要模式的函数,通过一些猜测来避免列出次要模式和其他以 -mode 结尾的函数:

    (defun list-major-modes ()
      "Returns list of potential major mode names (without the final -mode).
    Note, that this is guess work."
      (interactive)
      (let (l)
        (mapatoms #'(lambda (f) (and
                     (commandp f)
                     (string-match "-mode$" (symbol-name f))
                     ;; auto-loaded
                     (or (and (autoloadp (symbol-function f))
                          (let ((doc (documentation f)))
                        (when doc
                          (and
                           (let ((docSplit (help-split-fundoc doc f)))
                             (and docSplit ;; car is argument list
                              (null (cdr (read (car docSplit)))))) ;; major mode starters have no arguments
                           (if (string-match "[mM]inor" doc) ;; If the doc contains "minor"...
                               (string-match "[mM]ajor" doc) ;; it should also contain "major".
                             t) ;; else we cannot decide therefrom
                           ))))
                     (null (help-function-arglist f)))
                     (setq l (cons (substring (symbol-name f) 0 -5) l)))))
        (when (called-interactively-p 'any)
          (with-current-buffer (get-buffer-create "*Major Modes*")
        (clear-buffer-delete)
        (let ((standard-output (current-buffer)))
          (display-completion-list l)
          (display-buffer (current-buffer)))))
        l))
    

    【讨论】:

      【解决方案3】:
      C-h a mode
      

      显示所有模式的摘要

      【讨论】:

      • C-h a -mode$ RET 会更好。
      【解决方案4】:

      【讨论】:

      • 某些模式似乎丢失了,例如区域不在任何地方
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-08
      • 2015-04-29
      • 1970-01-01
      相关资源
      最近更新 更多