spacemacs org-mode <s 不能补全代码块

请问高手 spacemacs org mode 中如何输入<s后按TAB补全代码而不是<s>,怎么样配置才能补全#+BEGIN_SRC #+END_SRC?

2 个赞

Change in the structure template expansion

Org 9.2 comes with a new template expansion mechanism, combining org-insert-structure-template bound to C-c C-, .

If you customized the org-structure-template-alist option manually, you probably need to udpate it, see the docstring for accepted values.

If you prefer using previous patterns, e.g. <s , you can activate them again by requiring Org Tempo library:

(require 'org-tempo)

or add it to org-modules .

If you need complex templates, look at the tempo-define-template function or at solutions like Yasnippet.

2 个赞

@ wenpin 谢谢大神这么快回复!之后我在user-config里面添加下面还是不起作用。

  (eval-after-load 'org
    (add-to-list  'org-structure-template-alist
        (("a" . "export ascii")
         ("c" . "center")
         ("C" . "comment")
         ("e" . "example")
         ("E" . "export")
         ("h" . "export html")
         ("l" . "export latex")
         ("q" . "quote")
         ;;("s" . "src")
         ("s" "#+BEGIN_SRC emacs-lisp\n?\n#+END_SRC")
         ("v" . "verse")
         ("n" . "note")
         ("d" . "description"))))))

好像我搞混了这两者,再仔细看版本Org 9.2 文档,当前org中快速插入代码块有如下选择。

  1. 第一种方式是使用org-structure-template-alist,快捷键C-c C-,选择相应的template前缀
  2. 第二种还是选择以前的匹配模式<s TAB需要添加到user-config
  (require 'org-tempo)
2 个赞


emacs 28.0.50的org是9.3的。其他的module都用不着,只加上org-tempo即可。

  (defvar org-modules
1 个赞