unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Alex <agrambot@gmail.com>
To: 24766@debbugs.gnu.org
Subject: bug#24766: 26.0.50: [PATCH] Confusing behaviour for indent-relative-maybe
Date: Sat, 22 Oct 2016 13:01:15 -0600	[thread overview]
Message-ID: <8760ok8ays.fsf@gmail.com> (raw)

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

In emacs -Q's scratch buffer, try the following:

M-: (indent-relative) RET

Repeating this will move to the next appropriate indentation point as
indicated in indent-relative's docstring.

Now try:

M-: (indent-relative-maybe) RET

The point does not move even when there are appropriate indentation
points to move to. This contradicts the intention of the docstring for
indent-relative-maybe:

       If the previous nonblank line has no indent points beyond the
       column point starts at, this command does nothing.


I would have expected, in indent-relative, that the calculation of a
suitable indentation position is done independent of the argument
UNINDENTED-OK. The following diff fixes this:


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

diff --git a/lisp/indent.el b/lisp/indent.el
index 0f6c68d..02ec210 100644
--- a/lisp/indent.el
+++ b/lisp/indent.el
@@ -593,18 +593,18 @@ indent-relative
 	    ;; Is start-column inside a tab on this line?
 	    (if (> (current-column) start-column)
 		(backward-char 1))
-	    (or (looking-at "[ \t]")
-		unindented-ok
-		(skip-chars-forward "^ \t" end))
+	    (unless (looking-at "[ \t]")
+              (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'.

[-- Attachment #3: Type: text/plain, Size: 153 bytes --]



Apparently this stems from the initial revision of indent.el. Am I just
misinterpreting this function's purpose, or has it been wrong this whole
time?

             reply	other threads:[~2016-10-22 19:01 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-22 19:01 Alex [this message]
2016-10-22 19:21 ` bug#24766: 26.0.50: [PATCH] Confusing behaviour for indent-relative-maybe 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
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=8760ok8ays.fsf@gmail.com \
    --to=agrambot@gmail.com \
    --cc=24766@debbugs.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).