Emacs Version 24.4: New disgusting indentation loss on hit RETURN

Starting with Emacs 24.4, when I type a line starting with a space (a typical way to indicate a new paragraph) and at the end of this I press RETURN, the space will disappear. This problem also appears with 'emacs -Q'. The .emacs file uses a fairly simple paragraph text layout, namely

(setq default-major-mode 'text-mode) (add-hook 'text-mode-hook 'paragraph-indent-minor-mode) 

which works without problems for a dozen years. The error appeared when I installed the current version (24.4).

Basically, I type:

  This is a line beginning with four spaces 

and as soon as I type RETURN, my line will immediately become

 This is a line beginning with four spaces 

That is, the indentation disappears. I would really appreciate some advice. Should I post a bug?

+7
indentation emacs
source share
3 answers

In Emacs 24.4, the electric-indent-mode parameter is enabled by default. It seems to be causing this problem when combined with paragraph-indent-minor-mode . You can avoid this by disabling the indent mode everywhere ( Mx electric-indent-mode ) or only in the local buffer ( Mx electric-indent-local-mode ).

+5
source share

The following will try to keep electric-indent-mode from step on toes paragraph-indent-minor-mode . He does not try to be reliable in all situations, but I suspect that he is completely adequate in your situation.

 (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) 

If you are not using at least Emacs 24.3, replace defvar-local with:

 (defvar my-local-electric-indent-status :unknown) (make-variable-buffer-local 'my-local-electric-indent-status) 
+1
source share

;; (global-set-key "\ em" 'newline) ;; for emacs 23

global key set "\ em" 'for electronic printing and, possibly, indentation) ;; for emacs 24

-one
source share

All Articles