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

spacemacs

#1

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


#2

https://orgmode.org/Changes.html

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.


#3

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

  (eval-after-load 'org
  '(progn
    (add-to-list  'org-structure-template-alist
       (quote
        (("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"))))))

#4

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

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