Mercurial > emacs
changeset 1804:fe2bebf150c7
* c-mode.el (c-switch-label-regexp): New constant.
(electric-c-terminator, c-indent-line, indent-c-exp): Use it to
correctly recognize default labels in switch statements.
author | Jim Blandy <jimb@redhat.com> |
---|---|
date | Sat, 16 Jan 1993 06:04:16 +0000 |
parents | 5752a95053f2 |
children | 7ba5cfe280eb |
files | lisp/progmodes/c-mode.el |
diffstat | 1 files changed, 8 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/progmodes/c-mode.el Sat Jan 16 05:58:15 1993 +0000 +++ b/lisp/progmodes/c-mode.el Sat Jan 16 06:04:16 1993 +0000 @@ -127,6 +127,11 @@ (defconst c-tab-always-indent t "*Non-nil means TAB in C mode should always reindent the current line, regardless of where in the line point is when the TAB command is used.") + +;;; Regular expression used internally to recognize labels in switch +;;; statements. +(defconst c-switch-label-regexp "case[ \t'/(]\\|default\\(\\S_\\|'\\)") + (defun c-mode () "Major mode for editing C code. @@ -423,7 +428,7 @@ ;; So quickly rule out most other uses of colon ;; and do no indentation for them. (and (eq last-command-char ?:) - (not (looking-at "case[ \t'/(]\\|default\\>")) + (not (looking-at c-switch-label-regexp)) (save-excursion (skip-chars-forward "a-zA-Z0-9_$") (skip-chars-forward " \t") @@ -515,7 +520,7 @@ (t (skip-chars-forward " \t") (if (listp indent) (setq indent (car indent))) - (cond ((or (looking-at "case[ \t'/(]\\|default\\>") + (cond ((or (looking-at c-switch-label-regexp) (and (looking-at "[A-Za-z]") (save-excursion (forward-sexp 1) @@ -1079,7 +1084,7 @@ (setcar indent-stack (setq this-indent val)))) ;; Adjust line indentation according to its contents - (if (or (looking-at "case[ \t'/(]\\|default\\>") + (if (or (looking-at c-switch-label-regexp) (and (looking-at "[A-Za-z]") (save-excursion (forward-sexp 1)