从Emacs 24.4开始,当我键入以空格开头的一行(这是表示新段落的典型方式),并在它的末尾按回车键时,空格就消失了。使用'emacs -Q‘时也会出现此问题。我的.emacs文件使用了一个相当简单的文本模式分段方案,即
(setq default-major-mode 'text-mode)
(add-hook 'text-mode-hook 'paragraph-indent-minor-mode)它已经工作了十几年,没有任何问题。当我安装当前的(24.4)版本时,出现了这个bug。
基本上,我输入:
This is a line beginning with four spaces只要我输入RETURN,我的代码行就会立即变成
This is a line beginning with four spaces也就是说,缩进消失了。如果能给我一些建议,我将不胜感激。我应该发布一个bug吗?
发布于 2014-12-31 18:05:10
在Emacs24.4中,默认情况下启用electric-indent-mode。这似乎就是导致这个问题与paragraph-indent-minor-mode结合在一起的原因。您可以通过关闭任何地方的电子缩进模式(M-x electric-indent-mode)或仅在本地缓冲区(M-x electric-indent-local-mode)中关闭它来避免这种情况。
发布于 2014-12-31 21:55:41
下面将尝试防止electric-indent-mode踩到paragraph-indent-minor-mode的脚趾。它并不试图在所有情况下都是健壮的,但我怀疑它在您的情况下完全足够。
(defvar-local my-local-electric-indent-status :unknown)
(defun my-local-electric-indent-disable ()
"Make `electric-indent-mode' ineffective in the current buffer."
(setq my-local-electric-indent-status electric-indent-mode)
(electric-indent-local-mode -1))
(defun my-local-electric-indent-restore ()
"Restore original status of `electric-indent-mode' in the current buffer."
(unless (eq my-local-electric-indent-status :unknown)
(electric-indent-local-mode my-local-electric-indent-status)))
(add-hook 'paragraph-indent-minor-mode-on-hook #'my-local-electric-indent-disable)
(add-hook 'paragraph-indent-minor-mode-off-hook #'my-local-electric-indent-restore)如果您运行的是Emacs24.3或更低版本,请将defvar-local替换为:
(defvar my-local-electric-indent-status :unknown)
(make-variable-buffer-local 'my-local-electric-indent-status)发布于 2015-03-30 18:27:15
;;(global-set-key "\em“‘换行符);;用于emacs 23
global-set-key "\em“‘电子换行符和可能缩进);;对于emacs 24
https://stackoverflow.com/questions/27718310
复制相似问题