diff options
| author | Alan Mackenzie | 2020-06-01 15:21:54 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2020-06-01 15:21:54 +0000 |
| commit | 1b6bd97440349954ee310da0523c436985971ea9 (patch) | |
| tree | 73963ca428b2cc7138f48a9a9113cc8647e85794 | |
| parent | 056200f3ebdf74ef41cc9abdf99ae5bb03b73850 (diff) | |
| download | emacs-1b6bd97440349954ee310da0523c436985971ea9.tar.gz emacs-1b6bd97440349954ee310da0523c436985971ea9.zip | |
Bug #41061 patch: Fix typos and amend code slightly
* lisp/progmodes/cc-align.el (c-lineup-ternary-bodies)
* doc/misc/cc-mode.texi (Operator Line-Up): Fix typos and amend code.
| -rw-r--r-- | doc/misc/cc-mode.texi | 4 | ||||
| -rw-r--r-- | lisp/progmodes/cc-align.el | 22 |
2 files changed, 13 insertions, 13 deletions
diff --git a/doc/misc/cc-mode.texi b/doc/misc/cc-mode.texi index 16eac4828c7..10bbf8ff09f 100644 --- a/doc/misc/cc-mode.texi +++ b/doc/misc/cc-mode.texi | |||
| @@ -6399,8 +6399,8 @@ function is the same as specifying a list @code{(c-lineup-assignments | |||
| 6399 | @findex lineup-ternary-bodies @r{(c-)} | 6399 | @findex lineup-ternary-bodies @r{(c-)} |
| 6400 | Line up true and false branches of a ternary operator | 6400 | Line up true and false branches of a ternary operator |
| 6401 | (i.e. @code{?:}). More precisely, if the line starts with a colon | 6401 | (i.e. @code{?:}). More precisely, if the line starts with a colon |
| 6402 | which is a part of a said operator it with corresponding question | 6402 | which is a part of a said operator, align it with corresponding |
| 6403 | mark. For example: | 6403 | question mark. For example: |
| 6404 | 6404 | ||
| 6405 | @example | 6405 | @example |
| 6406 | @group | 6406 | @group |
diff --git a/lisp/progmodes/cc-align.el b/lisp/progmodes/cc-align.el index c49bdc5c518..6172afecbcf 100644 --- a/lisp/progmodes/cc-align.el +++ b/lisp/progmodes/cc-align.el | |||
| @@ -791,32 +791,32 @@ arglist-cont-nonempty." | |||
| 791 | c-basic-offset)) | 791 | c-basic-offset)) |
| 792 | 792 | ||
| 793 | (defun c-lineup-ternary-bodies (langelem) | 793 | (defun c-lineup-ternary-bodies (langelem) |
| 794 | "Line up true and false branches of a ternary operator (i.e. ‘?:’). | 794 | "Line up true and false branches of a ternary operator (i.e. `?:'). |
| 795 | More precisely, if the line starts with a colon which is a part of | 795 | More precisely, if the line starts with a colon which is a part of |
| 796 | a said operator it with corresponding question mark; otherwise return | 796 | a said operator, align it with corresponding question mark; otherwise |
| 797 | nil. For example: | 797 | return nil. For example: |
| 798 | 798 | ||
| 799 | return arg % 2 == 0 ? arg / 2 | 799 | return arg % 2 == 0 ? arg / 2 |
| 800 | : (3 * arg + 1); <- c-lineup-ternary-bodies | 800 | : (3 * arg + 1); <- c-lineup-ternary-bodies |
| 801 | 801 | ||
| 802 | Works with: arglist-cont, arglist-cont-nonempty and statement-cont. | 802 | Works with: arglist-cont, arglist-cont-nonempty and statement-cont." |
| 803 | " | ||
| 804 | (save-excursion | 803 | (save-excursion |
| 805 | (back-to-indentation) | 804 | (back-to-indentation) |
| 806 | (when (and (eq ?: (char-after)) | 805 | (when (and (eq ?: (char-after)) |
| 807 | (not (eq ?: (char-after (1+ (point)))))) | 806 | (not (eq ?: (char-after (1+ (point)))))) |
| 808 | (let ((limit (c-langelem-pos langelem)) (depth 1)) | 807 | (let ((limit (c-langelem-pos langelem)) (depth 1)) |
| 809 | (catch 'done | 808 | (catch 'done |
| 810 | (while (c-syntactic-skip-backward "^?:" limit t) | 809 | (while (and (c-syntactic-skip-backward "^?:" limit t) |
| 811 | (goto-char (1- (point))) | 810 | (not (bobp))) |
| 811 | (backward-char) | ||
| 812 | (cond ((eq (char-after) ??) | 812 | (cond ((eq (char-after) ??) |
| 813 | ;; If we’ve found a question mark, decrease depth. If we’re | 813 | ;; If we've found a question mark, decrease depth. If we've |
| 814 | ;; reached zero, we’ve found the one we were looking for. | 814 | ;; reached zero, we've found the one we were looking for. |
| 815 | (when (zerop (setq depth (1- depth))) | 815 | (when (zerop (setq depth (1- depth))) |
| 816 | (throw 'done (vector (current-column))))) | 816 | (throw 'done (vector (current-column))))) |
| 817 | ((or (eq ?: (char-before)) (eq ?? (char-before))) | 817 | ((or (eq ?: (char-before)) (eq ?? (char-before))) |
| 818 | ;; Step over ‘::’ and ‘?:’ operators. We don’t have to | 818 | ;; Step over `::' and `?:' operators. We don't have to |
| 819 | ;; handle ‘?:’ here but doing so saves an iteration. | 819 | ;; handle `?:' here but doing so saves an iteration. |
| 820 | (if (eq (point) limit) | 820 | (if (eq (point) limit) |
| 821 | (throw 'done nil) | 821 | (throw 'done nil) |
| 822 | (goto-char (1- (point))))) | 822 | (goto-char (1- (point))))) |