summaryrefslogtreecommitdiff
path: root/lisp/progmodes/cc-align.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/progmodes/cc-align.el')
-rw-r--r--lisp/progmodes/cc-align.el54
1 files changed, 21 insertions, 33 deletions
diff --git a/lisp/progmodes/cc-align.el b/lisp/progmodes/cc-align.el
index 2f1625854a1..b51a304c531 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
@@ -1119,35 +1121,20 @@ ACTION associated with `block-close' syntax."
'(before after)))))
(defun c-gnu-impose-minimum ()
- "Imposes a minimum indentation for lines inside a top-level construct.
+ "Imposes a minimum indentation for lines inside code blocks.
The variable `c-label-minimum-indentation' specifies the minimum
indentation amount."
- ;; Don't adjust macro or comment-only lines.
- (unless (or (assq 'cpp-macro c-syntactic-context)
- (assq 'comment-intro c-syntactic-context))
-
- (let ((paren-state (save-excursion
- ;; Get the parenthesis state, but skip past
- ;; an initial closing paren on the line since
- ;; the close brace of a block shouldn't be
- ;; considered to be inside the block.
- (back-to-indentation)
- (when (looking-at "\\s\)")
- (forward-char))
- (c-parse-state))))
-
- ;; Search for an enclosing brace on paren-state.
- (while (and paren-state
- (not (and (integer-or-marker-p (car paren-state))
- (eq (char-after (car paren-state)) ?{))))
- (setq paren-state (cdr paren-state)))
-
- (when paren-state
- (save-excursion
- (back-to-indentation)
- (if (zerop (current-column))
- (insert-char ?\ c-label-minimum-indentation t)))))))
+ (when (and (not
+ ;; Don't adjust macro or comment-only lines.
+ (or (assq 'cpp-macro c-syntactic-context)
+ (assq 'comment-intro c-syntactic-context)))
+ (c-intersect-lists c-inside-block-syms c-syntactic-context)
+ (save-excursion
+ (back-to-indentation)
+ (< (current-column) c-label-minimum-indentation)))
+ (c-shift-line-indentation (- c-label-minimum-indentation
+ (current-indentation)))))
;; Useful for c-hanging-semi&comma-criteria
@@ -1206,4 +1193,5 @@ For other semicolon contexts, no determination is made."
(cc-provide 'cc-align)
+;;; arch-tag: 4d71ed28-bf51-4509-a148-f39669669a2e
;;; cc-align.el ends here