unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Alex <agrambot@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 24766@debbugs.gnu.org
Subject: bug#24766: 26.0.50: [PATCH] Confusing behaviour for indent-relative-maybe
Date: Tue, 08 Nov 2016 13:09:42 -0600	[thread overview]
Message-ID: <87k2cdn5zd.fsf@gmail.com> (raw)
In-Reply-To: <83h97iggcy.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 08 Nov 2016 17:07:25 +0200")

[-- Attachment #1: Type: text/plain, Size: 707 bytes --]

Eli Zaretskii <eliz@gnu.org> writes:

> Thanks, this is fine, except that the new function's name should be
> better as indent-relative-first-indent-point or somesuch.

That name does better describe how (indent-relative t) works, but I
figured that indent-relative-whitespace is a better name for what people
seem to use it for (indent according to the whitespace on the previous
nonblank line).

Though if you still disagree then `indent-relative-first-indent-point'
seems fine (if not a bit long).

I suppose this diff goes over the accepted limit for non-assigned
submissions? I mailed my copyright forms about a month ago but
unfortunately the FSF hasn't informed me that the process is complete
yet.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 4th time --]
[-- Type: text/x-diff, Size: 2649 bytes --]

diff --git a/lisp/indent.el b/lisp/indent.el
index 0f6c68d..6d04192 100644
--- a/lisp/indent.el
+++ b/lisp/indent.el
@@ -559,26 +559,32 @@ indent-region
   ;; 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 @@ indent-relative
 	    (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	other threads:[~2016-11-08 19:09 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-22 19:01 bug#24766: 26.0.50: [PATCH] Confusing behaviour for indent-relative-maybe Alex
2016-10-22 19:21 ` Eli Zaretskii
2016-10-22 19:40   ` Alex
2016-10-22 19:48     ` Eli Zaretskii
2016-10-22 21:49       ` Alex
2016-10-23  6:23         ` Eli Zaretskii
2016-10-23 20:43           ` Alex
2016-10-24  8:23             ` Eli Zaretskii
2016-10-24 19:27               ` Alex
2016-10-24 19:57                 ` Eli Zaretskii
2016-11-08  1:53                   ` Alex
2016-11-08 15:07                     ` Eli Zaretskii
2016-11-08 19:09                       ` Alex [this message]
2016-11-08 20:26                         ` Eli Zaretskii
2016-11-18  9:04                         ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k2cdn5zd.fsf@gmail.com \
    --to=agrambot@gmail.com \
    --cc=24766@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).