Subject: bug#24766: 26.0.50: [PATCH] Confusing behaviour for indent-relative-maybe

From: Alex <[email-masked]>
Date: Sat, 22 Oct 2016 13:01:15 -0600

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:

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'.

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?