Extending Customizing c-mode indentation behavior in emacs-24.4
How can electric indentation be disabled for other specific keys without disabling the entire mode?
Specifically, how can electric indentation be turned off for /* */
comments? Apparently disabling it for *
does not do the job.
The following works only under some conditions.
(add-hook 'c-mode-hook
(lambda ()
(set-key (kbd "*") 'self-insert-command)))
Similarly, the following works only under some conditions
(add-hook 'c-mode-hook
(lambda ()
(setq electric-indent-chars
(remq "*" electric-indent-chars))))
(add-hook 'c-mode-hook
(lambda ()
(setq electric-indent-chars
(remq "*" electric-indent-chars))))
(?*
and ?/
also do not work)
"some conditions": comment lines following another commented line keep their non-electric indentation after typing *
, but a comment line immediately following a closing brace has its indentation reset upon typing the *
in /*
?\n
with?*
) – npostavs Mar 25 '15 at 19:16electric-indent-chars
was supposed to cover other things, but actually it's only newline (maybe it's only planned to control other chars). – npostavs Mar 25 '15 at 21:14