summaryrefslogtreecommitdiff
path: root/lisp/progmodes
diff options
context:
space:
mode:
authorMartin Stjernholm <mast@lysator.liu.se>2003-08-26 11:52:40 +0000
committerMartin Stjernholm <mast@lysator.liu.se>2003-08-26 11:52:40 +0000
commitde657c192cd16638cda923ce0f330915e90e296b (patch)
tree6464087679adbc7b978658729a5a6400523f670b /lisp/progmodes
parent34100a51751e2eb415f1038fdf94e8ac76a06ac2 (diff)
downloademacs-de657c192cd16638cda923ce0f330915e90e296b.tar.gz
(c-lineup-math): Don't align the operators "!=", "<=" and ">=" as assignment
operators. (c-assignment-operators): New language constant that only contains the assignment operators. (c-assignment-op-regexp): New language variable used by c-lineup-math'.
Diffstat (limited to 'lisp/progmodes')
-rw-r--r--lisp/progmodes/cc-align.el16
-rw-r--r--lisp/progmodes/cc-langs.el34
2 files changed, 37 insertions, 13 deletions
diff --git a/lisp/progmodes/cc-align.el b/lisp/progmodes/cc-align.el
index 2f1625854a1..d3d07c724c1 100644
--- a/lisp/progmodes/cc-align.el
+++ b/lisp/progmodes/cc-align.el
@@ -708,18 +708,20 @@ arglist-cont-nonempty."
(save-excursion
(beginning-of-line)
(when (c-syntactic-re-search-forward
- ;; This regexp avoids matches on ==.
- "\\(\\=\\|[^=]\\)=\\([^=]\\|$\\)"
- (c-point 'eol) t t)
- (setq equalp (- (match-beginning 2) (c-point 'boi))))))
+ c-assignment-op-regexp
+ (c-point 'eol) t t t)
+ (setq equalp (- (or (match-beginning 1)
+ (match-end 0))
+ (c-point 'boi))))))
(save-excursion
(goto-char startpos)
(if (or (if (c-syntactic-re-search-forward
- "\\(\\=\\|[^=]\\)=\\([^=]\\|$\\)"
- (min endpos (c-point 'eol)) t t)
+ c-assignment-op-regexp
+ (min endpos (c-point 'eol)) t t t)
(progn
- (goto-char (match-beginning 2))
+ (goto-char (or (match-beginning 1)
+ (match-end 0)))
nil)
t)
(save-excursion
diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el
index 0a55be956bb..bee72dde46c 100644
--- a/lisp/progmodes/cc-langs.el
+++ b/lisp/progmodes/cc-langs.el
@@ -544,6 +544,15 @@ submatch surrounds the directive name."
'("defined"))
pike '("defined" "efun" "constant"))
+(c-lang-defconst c-assignment-operators
+ "List of all assignment operators."
+ t '("=" "*=" "/=" "%=" "+=" "-=" ">>=" "<<=" "&=" "^=" "|=")
+ java (append (c-lang-const c-assignment-operators)
+ '(">>>="))
+ c++ (append (c-lang-const c-assignment-operators)
+ '("and_eq" "or_eq" "xor_eq"))
+ idl nil)
+
(c-lang-defconst c-operators
"List describing all operators, along with their precedence and
associativity. The order in the list corresponds to the precedence of
@@ -686,11 +695,7 @@ since CC Mode treats every identifier as an expression."
(right-assoc-sequence "?" ":")
;; Assignment.
- (right-assoc "=" "*=" "/=" "%=" "+=" "-=" ">>=" "<<=" "&=" "^=" "|="
- ,@(when (c-major-mode-is 'java-mode)
- '(">>>="))
- ,@(when (c-major-mode-is 'c++-mode)
- '("and_eq" "or_eq" "xor_eq")))
+ (right-assoc ,@(c-lang-const c-assignment-operators))
;; Exception.
,@(when (c-major-mode-is 'c++-mode)
@@ -788,6 +793,23 @@ operators."
(c-lang-defvar c-nonsymbol-token-regexp
(c-lang-const c-nonsymbol-token-regexp))
+(c-lang-defconst c-assignment-op-regexp
+ ;; Regexp matching all assignment operators and only them. The
+ ;; beginning of the first submatch is used to detect the end of the
+ ;; token, along with the end of the whole match.
+ t (if (c-lang-const c-assignment-operators)
+ (concat
+ ;; Need special case for "=" since it's a prefix of "==".
+ "=\\([^=]\\|$\\)"
+ "\\|"
+ (c-make-keywords-re nil
+ (set-difference (c-lang-const c-assignment-operators)
+ '("=")
+ :test 'string-equal)))
+ "\\<\\>"))
+(c-lang-defvar c-assignment-op-regexp
+ (c-lang-const c-assignment-op-regexp))
+
(c-lang-defconst c-<-op-cont-regexp
;; Regexp matching the second and subsequent characters of all
;; multicharacter tokens that begin with "<".
@@ -1441,7 +1463,7 @@ assumed to be set if this isn't nil."
(c-lang-defconst c-opt-<>-sexp-key
;; Adorned regexp matching keywords that can be followed by an angle
- ;; bracket sexp.
+ ;; bracket sexp. Always set when `c-recognize-<>-arglists' is.
t (if (c-lang-const c-recognize-<>-arglists)
(c-make-keywords-re t (c-lang-const c-<>-sexp-kwds))))
(c-lang-defvar c-opt-<>-sexp-key (c-lang-const c-opt-<>-sexp-key))