Emacs Don';两个换行符后的缩进
我已将RET绑定到新行和缩进。无论何时我跳过一行,它都会留下一行没有缩进,并缩进当前行,这就是它应该做的。在某些情况下,我希望它不会在跳过后缩进当前行。一些例子:Emacs Don';两个换行符后的缩进,emacs,elisp,Emacs,Elisp,我已将RET绑定到新行和缩进。无论何时我跳过一行,它都会留下一行没有缩进,并缩进当前行,这就是它应该做的。在某些情况下,我希望它不会在跳过后缩进当前行。一些例子: Default behavior This is a test. Line two. How I'd like it: This is a test. Line two. 我不太确定实现这一点的最佳方式。一个散发着不雅观气息的解决方案是,尝试检测连续两次按压,然后超出当前线路。有什么想法吗?此解决方案假
Default behavior
This is a test.
Line two.
How I'd like it:
This is a test.
Line two.
我不太确定实现这一点的最佳方式。一个散发着不雅观气息的解决方案是,尝试检测连续两次按压,然后超出当前线路。有什么想法吗?此解决方案假定您希望在
文本模式中进行更改
,如果是不同的模式,请适当调整代码
(add-hook 'text-mode-hook
(lambda () (setq indent-line-function 'indent-relative-only-when-previous-has-non-whitespace)))
(defun indent-relative-only-when-previous-has-non-whitespace ()
"Only call indent-relative when previous line has non whitespace"
(interactive)
(when (save-excursion
(beginning-of-line 0)
(looking-at "^\\s *\\S "))
(indent-relative)))