A code base I work on has the macro
#define when break; case
to make switch statements 'cleaner'
However this causes problems with indentation,
Is it possible to set the behavior of 'when' to be the same as 'case'?
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.Sign up to join this community
It is simpler to add
when as a font lock keyword and as a matcher in
You can use the following
(defun my-c-setup () "Run in `c-mode-hook'." (font-lock-add-keywords nil '(("when" . 'font-lock-keyword-face))) (setq c-label-kwds-regexp (replace-regexp-in-string "case" "case\\\\|when" c-label-kwds-regexp))) (add-hook 'c-mode-hook #'my-c-setup)