3

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 /*

user2127595
  • 81
  • 1
  • 3

0 Answers0