emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master a9973a3: Extend 'indent-relative' when its arg is n


From: Eli Zaretskii
Subject: [Emacs-diffs] master a9973a3: Extend 'indent-relative' when its arg is non-nil
Date: Fri, 18 Nov 2016 09:04:11 +0000 (UTC)

branch: master
commit a9973a3c164060bde08a717b46023a3bf68909c8
Author: Alex <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    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)
---
 lisp/indent.el |   41 ++++++++++++++++++++++++-----------------
 1 file changed, 24 insertions(+), 17 deletions(-)

diff --git a/lisp/indent.el b/lisp/indent.el
index 0f6c68d..952a05a 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."
   ;; by hand.
   (setq deactivate-mark t))
 
-(defun indent-relative-maybe ()
-  "Indent a new line like previous nonblank line.
-If the previous nonblank line has no indent points beyond the
-column point starts at, this command does nothing.
+(define-obsolete-function-alias 'indent-relative-maybe
+  'indent-relative-first-indent-point "26.1")
+
+(defun indent-relative-first-indent-point ()
+  "Indent the current line like the previous nonblank line.
+Indent to the first indentation position in the previous nonblank
+line if that position is greater than the current column.
 
 See also `indent-relative'."
   (interactive)
   (indent-relative t))
 
-(defun indent-relative (&optional unindented-ok)
+(defun indent-relative (&optional first-only unindented-ok)
   "Space out to under next indent point in previous nonblank line.
 An indent point is a non-whitespace character following whitespace.
 The following line shows the indentation points in this line.
     ^         ^    ^     ^   ^           ^      ^  ^    ^
+If FIRST-ONLY is non-nil, then only the first indent point is
+considered.
+
 If the previous nonblank line has no indent points beyond the
-column point starts at, `tab-to-tab-stop' is done instead, unless
-this command is invoked with a numeric argument, in which case it
-does nothing.
+column point starts at, then `tab-to-tab-stop' is done, if both
+FIRST-ONLY and UNINDENTED-OK are nil, otherwise nothing is done
+in this case.
 
-See also `indent-relative-maybe'."
+See also `indent-relative-first-indent-point'."
   (interactive "P")
   (if (and abbrev-mode
           (eq (char-syntax (preceding-char)) ?w))
@@ -594,17 +600,18 @@ See also `indent-relative-maybe'."
            (if (> (current-column) start-column)
                (backward-char 1))
            (or (looking-at "[ \t]")
-               unindented-ok
+               first-only
                (skip-chars-forward "^ \t" end))
            (skip-chars-forward " \t" end)
            (or (= (point) end) (setq indent (current-column))))))
-    (if indent
-       (let ((opoint (point-marker)))
-         (indent-to indent 0)
-         (if (> opoint (point))
-             (goto-char opoint))
-         (move-marker opoint nil))
-      (tab-to-tab-stop))))
+    (cond (indent
+           (let ((opoint (point-marker)))
+             (indent-to indent 0)
+             (if (> opoint (point))
+                 (goto-char opoint))
+             (move-marker opoint nil)))
+          (unindented-ok nil)
+          (t (tab-to-tab-stop)))))
 
 (defcustom tab-stop-list nil
   "List of tab stop positions used by `tab-to-tab-stop'.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]