在一个组织模式文件中,使用如下代码:
#+begin_src emacs-lisp
(add-to-list 'org-tab-before-tab-emulation-hook
(lambda ()
(when (within-the-body-of-a-begin-src-block)
(indent-for-tab-command--as-if-in-lisp-mode))))
#+end_src我希望TAB键缩进代码,就像它在lisp模式下处于缓冲区一样。
我需要的是:
Org已经可以根据模式高亮显示src块,并且TAB钩子在那里。这个看起来是可行的。
发布于 2014-12-01 20:23:39
由于Emacs24.1,现在可以设置以下选项:
(setq org-src-tab-acts-natively t)应该处理所有src块的...and。
发布于 2013-06-11 06:45:36
只需将点移到代码块中,然后按C-c‘
这将弹出一个缓冲区在elisp模式,语法高度和所有.
发布于 2013-04-04 19:31:49
以下是一个粗略的解决方案:
(defun indent-org-src-block-line ()
"Indent the current line of emacs lisp code."
(interactive)
(let ((info (org-babel-get-src-block-info 'light)))
(when info
(let ((lang (nth 0 info)))
(when (string= lang "emacs-lisp")
(let ((indent-line-function 'lisp-indent-line))
(indent-for-tab-command)))))))
(add-to-list 'org-tab-before-tab-emulation-hook
'indent-org-src-block-line)它只处理emacs块。我只对src块进行了测试,没有缩进(不是org默认值)。
一般来说,让一种模式在另一种模式中工作是很困难的--许多键盘命令将发生冲突。但是,一些更基本的笔画,如缩进选项卡、换行符、注释(org将用#注释lisp代码,这是错误的)似乎可以让它们工作,并且会产生最大的影响。
https://stackoverflow.com/questions/15773354
复制相似问题