diff options
| author | Alex | 2016-11-18 11:02:55 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2016-11-18 11:02:55 +0200 |
| commit | a9973a3c164060bde08a717b46023a3bf68909c8 (patch) | |
| tree | 46b0d11223b840e62d54b6754fc5dc746689c9fd | |
| parent | 67df076793773c6226b8c08c435109aeb2e7a0d3 (diff) | |
| download | emacs-a9973a3c164060bde08a717b46023a3bf68909c8.tar.gz emacs-a9973a3c164060bde08a717b46023a3bf68909c8.zip | |
Extend 'indent-relative' when its arg is non-nil
* lisp/indent.el (indent-relative-maybe): New obsolete alias.
(indent-relative-first-indent-point): Renamed from
'indent-relative-maybe'.
(indent-relative): Now accepts an additional optional argument.
The first argument was renamed to FIRST-ONLY. Doc fix. Support
the additional arg. (Bug#24766)
| -rw-r--r-- | lisp/indent.el | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/lisp/indent.el b/lisp/indent.el index 0f6c68dd626..952a05af274 100644 --- a/lisp/indent.el +++ b/lisp/indent.el | |||
| @@ -559,26 +559,32 @@ column to indent to; if it is nil, use one of the three methods above." | |||
| 559 | ;; by hand. | 559 | ;; by hand. |
| 560 | (setq deactivate-mark t)) | 560 | (setq deactivate-mark t)) |
| 561 | 561 | ||
| 562 | (defun indent-relative-maybe () | 562 | (define-obsolete-function-alias 'indent-relative-maybe |
| 563 | "Indent a new line like previous nonblank line. | 563 | 'indent-relative-first-indent-point "26.1") |
| 564 | If the previous nonblank line has no indent points beyond the | 564 | |
| 565 | column point starts at, this command does nothing. | 565 | (defun indent-relative-first-indent-point () |
| 566 | "Indent the current line like the previous nonblank line. | ||
| 567 | Indent to the first indentation position in the previous nonblank | ||
| 568 | line if that position is greater than the current column. | ||
| 566 | 569 | ||
| 567 | See also `indent-relative'." | 570 | See also `indent-relative'." |
| 568 | (interactive) | 571 | (interactive) |
| 569 | (indent-relative t)) | 572 | (indent-relative t)) |
| 570 | 573 | ||
| 571 | (defun indent-relative (&optional unindented-ok) | 574 | (defun indent-relative (&optional first-only unindented-ok) |
| 572 | "Space out to under next indent point in previous nonblank line. | 575 | "Space out to under next indent point in previous nonblank line. |
| 573 | An indent point is a non-whitespace character following whitespace. | 576 | An indent point is a non-whitespace character following whitespace. |
| 574 | The following line shows the indentation points in this line. | 577 | The following line shows the indentation points in this line. |
| 575 | ^ ^ ^ ^ ^ ^ ^ ^ ^ | 578 | ^ ^ ^ ^ ^ ^ ^ ^ ^ |
| 579 | If FIRST-ONLY is non-nil, then only the first indent point is | ||
| 580 | considered. | ||
| 581 | |||
| 576 | If the previous nonblank line has no indent points beyond the | 582 | If the previous nonblank line has no indent points beyond the |
| 577 | column point starts at, `tab-to-tab-stop' is done instead, unless | 583 | column point starts at, then `tab-to-tab-stop' is done, if both |
| 578 | this command is invoked with a numeric argument, in which case it | 584 | FIRST-ONLY and UNINDENTED-OK are nil, otherwise nothing is done |
| 579 | does nothing. | 585 | in this case. |
| 580 | 586 | ||
| 581 | See also `indent-relative-maybe'." | 587 | See also `indent-relative-first-indent-point'." |
| 582 | (interactive "P") | 588 | (interactive "P") |
| 583 | (if (and abbrev-mode | 589 | (if (and abbrev-mode |
| 584 | (eq (char-syntax (preceding-char)) ?w)) | 590 | (eq (char-syntax (preceding-char)) ?w)) |
| @@ -594,17 +600,18 @@ See also `indent-relative-maybe'." | |||
| 594 | (if (> (current-column) start-column) | 600 | (if (> (current-column) start-column) |
| 595 | (backward-char 1)) | 601 | (backward-char 1)) |
| 596 | (or (looking-at "[ \t]") | 602 | (or (looking-at "[ \t]") |
| 597 | unindented-ok | 603 | first-only |
| 598 | (skip-chars-forward "^ \t" end)) | 604 | (skip-chars-forward "^ \t" end)) |
| 599 | (skip-chars-forward " \t" end) | 605 | (skip-chars-forward " \t" end) |
| 600 | (or (= (point) end) (setq indent (current-column)))))) | 606 | (or (= (point) end) (setq indent (current-column)))))) |
| 601 | (if indent | 607 | (cond (indent |
| 602 | (let ((opoint (point-marker))) | 608 | (let ((opoint (point-marker))) |
| 603 | (indent-to indent 0) | 609 | (indent-to indent 0) |
| 604 | (if (> opoint (point)) | 610 | (if (> opoint (point)) |
| 605 | (goto-char opoint)) | 611 | (goto-char opoint)) |
| 606 | (move-marker opoint nil)) | 612 | (move-marker opoint nil))) |
| 607 | (tab-to-tab-stop)))) | 613 | (unindented-ok nil) |
| 614 | (t (tab-to-tab-stop))))) | ||
| 608 | 615 | ||
| 609 | (defcustom tab-stop-list nil | 616 | (defcustom tab-stop-list nil |
| 610 | "List of tab stop positions used by `tab-to-tab-stop'. | 617 | "List of tab stop positions used by `tab-to-tab-stop'. |