bug#34858: indent-relative called with prefix calls tab-to-tab-stop

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

bug#34858: indent-relative called with prefix calls tab-to-tab-stop

Alex Branham
The docstring of indent-relative says:

If the previous nonblank line has no indent points beyond the
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.

Yet in a buffer like this:

foo

with point at the beginning of line, C-u M-x indent-relative results in:

        test

I'm happy to submit a patch fixing this, but should it update the
documentation to match what happens or should it update the code to
match the documentation?

Thanks,
Alex



Reply | Threaded
Open this post in threaded view
|

bug#34858: indent-relative called with prefix calls tab-to-tab-stop

Eli Zaretskii
> From: Alex Branham <[hidden email]>
> Date: Thu, 14 Mar 2019 10:35:13 -0500
>
> If the previous nonblank line has no indent points beyond the
> 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.
>
> Yet in a buffer like this:
>
> foo
>
> with point at the beginning of line, C-u M-x indent-relative results in:
>
>         test
>
> I'm happy to submit a patch fixing this, but should it update the
> documentation to match what happens or should it update the code to
> match the documentation?

I think this is a documentation bug, as it doesn't describe the
special case of "no previous nonblank line".



Reply | Threaded
Open this post in threaded view
|

bug#34858: indent-relative called with prefix calls tab-to-tab-stop

Alex Branham

On Thu 14 Mar 2019 at 11:00, Eli Zaretskii <[hidden email]> wrote:

> I think this is a documentation bug, as it doesn't describe the
> special case of "no previous nonblank line".

OK, patch attached. While looking over this I noticed the lisp reference
manual also needed to be updated a bit so I did that as well.

Thanks,
Alex

From cefe6581558e45558907996ea39ac44e512f7944 Mon Sep 17 00:00:00 2001
From: Alex Branham <[hidden email]>
Date: Thu, 14 Mar 2019 11:14:18 -0500
Subject: [PATCH] Update documentation for indent-relative functions

* lisp/indent.el (indent-relative): Document what happens when there
  is no previous nonblank line.
* doc/lispref/text.texi (Relative Indent): Document
  indent-relative-first-indent-point instead of obsolete
  indent-relative-maybe. Fix documentation of which argument from
  'indent-relative' is used.

Bug#34858
---
 doc/lispref/text.texi | 4 ++--
 lisp/indent.el        | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi
index 21c5a73f88..abcea17010 100644
--- a/doc/lispref/text.texi
+++ b/doc/lispref/text.texi
@@ -2571,11 +2571,11 @@ The quick brown fox jum  @point{}ped.
 @end example
 @end deffn
 
-@deffn Command indent-relative-maybe
+@deffn Command indent-relative-first-indent-point
 @comment !!SourceFile indent.el
 This command indents the current line like the previous nonblank line,
 by calling @code{indent-relative} with @code{t} as the
-@var{unindented-ok} argument.  The return value is unpredictable.
+@var{first-only} argument.  The return value is unpredictable.
 
 If the previous nonblank line has no indent points beyond the current
 column, this command does nothing.
diff --git a/lisp/indent.el b/lisp/indent.el
index 34757a43d7..25615f4113 100644
--- a/lisp/indent.el
+++ b/lisp/indent.el
@@ -598,8 +598,8 @@ considered.
 
 If the previous nonblank line has no indent points beyond the
 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.
+FIRST-ONLY and UNINDENTED-OK are nil, otherwise nothing is done.
+If there isn't a previous nonblank line, call `tab-to-tab-stop'.
 
 See also `indent-relative-first-indent-point'."
   (interactive "P")
--
2.19.2


From cefe6581558e45558907996ea39ac44e512f7944 Mon Sep 17 00:00:00 2001
From: Alex Branham <[hidden email]>
Date: Thu, 14 Mar 2019 11:14:18 -0500
Subject: [PATCH] Update documentation for indent-relative functions

* lisp/indent.el (indent-relative): Document what happens when there
  is no previous nonblank line.
* doc/lispref/text.texi (Relative Indent): Document
  indent-relative-first-indent-point instead of obsolete
  indent-relative-maybe. Fix documentation of which argument from
  'indent-relative' is used.

Bug#34858
---
 doc/lispref/text.texi | 4 ++--
 lisp/indent.el        | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi
index 21c5a73f88..abcea17010 100644
--- a/doc/lispref/text.texi
+++ b/doc/lispref/text.texi
@@ -2571,11 +2571,11 @@ The quick brown fox jum  @point{}ped.
 @end example
 @end deffn
 
-@deffn Command indent-relative-maybe
+@deffn Command indent-relative-first-indent-point
 @comment !!SourceFile indent.el
 This command indents the current line like the previous nonblank line,
 by calling @code{indent-relative} with @code{t} as the
-@var{unindented-ok} argument.  The return value is unpredictable.
+@var{first-only} argument.  The return value is unpredictable.
 
 If the previous nonblank line has no indent points beyond the current
 column, this command does nothing.
diff --git a/lisp/indent.el b/lisp/indent.el
index 34757a43d7..25615f4113 100644
--- a/lisp/indent.el
+++ b/lisp/indent.el
@@ -598,8 +598,8 @@ considered.
 
 If the previous nonblank line has no indent points beyond the
 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.
+FIRST-ONLY and UNINDENTED-OK are nil, otherwise nothing is done.
+If there isn't a previous nonblank line, call `tab-to-tab-stop'.
 
 See also `indent-relative-first-indent-point'."
   (interactive "P")
--
2.19.2

Reply | Threaded
Open this post in threaded view
|

bug#34858: indent-relative called with prefix calls tab-to-tab-stop

Alex-2
In reply to this post by Eli Zaretskii
Eli Zaretskii <[hidden email]> writes:

>> From: Alex Branham <[hidden email]>
>> Date: Thu, 14 Mar 2019 10:35:13 -0500
>>
>> If the previous nonblank line has no indent points beyond the
>> 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.
>>
>> Yet in a buffer like this:
>>
>> foo
>>
>> with point at the beginning of line, C-u M-x indent-relative results in:
>>
>>         test
>>
>> I'm happy to submit a patch fixing this, but should it update the
>> documentation to match what happens or should it update the code to
>> match the documentation?
>
> I think this is a documentation bug, as it doesn't describe the
> special case of "no previous nonblank line".

I believe that the case of "no previous nonblank line" could be
considered as there being a single indent point at column 0, so if
FIRST-ONLY is non-nil, then `tab-to-tab-stop' shouldn't be called. How
about the following patch instead?

diff --git a/lisp/indent.el b/lisp/indent.el
index 34757a43d7..4ee4617de9 100644
--- a/lisp/indent.el
+++ b/lisp/indent.el
@@ -597,7 +597,7 @@ indent-relative
 considered.
 
 If the previous nonblank line has no indent points beyond the
-column point starts at, then `tab-to-tab-stop' is done, if both
+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.
 
@@ -627,7 +627,7 @@ indent-relative
              (if (> opoint (point))
                  (goto-char opoint))
              (move-marker opoint nil)))
-          (unindented-ok nil)
+          ((or unindented-ok first-only) nil)
           (t (tab-to-tab-stop)))))
 
 (defcustom tab-stop-list nil



Reply | Threaded
Open this post in threaded view
|

bug#34858: indent-relative called with prefix calls tab-to-tab-stop

Eli Zaretskii
> From: Alex <[hidden email]>
> Cc: Alex Branham <[hidden email]>,  [hidden email]
> Date: Thu, 14 Mar 2019 10:45:32 -0600
>
> Eli Zaretskii <[hidden email]> writes:
>
> >> From: Alex Branham <[hidden email]>
> >> Date: Thu, 14 Mar 2019 10:35:13 -0500
> >>
> >> If the previous nonblank line has no indent points beyond the
> >> 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.
> >>
> >> Yet in a buffer like this:
> >>
> >> foo
> >>
> >> with point at the beginning of line, C-u M-x indent-relative results in:
> >>
> >>         test
> >>
> >> I'm happy to submit a patch fixing this, but should it update the
> >> documentation to match what happens or should it update the code to
> >> match the documentation?
> >
> > I think this is a documentation bug, as it doesn't describe the
> > special case of "no previous nonblank line".
>
> I believe that the case of "no previous nonblank line" could be
> considered as there being a single indent point at column 0, so if
> FIRST-ONLY is non-nil, then `tab-to-tab-stop' shouldn't be called. How
> about the following patch instead?

I don't understand what you are saying here.  The doc string says "no
indent point _beyond_" the column where point starts, so assuming a
single indent point at column zero doesn't change anything.



Reply | Threaded
Open this post in threaded view
|

bug#34858: indent-relative called with prefix calls tab-to-tab-stop

Alex-2
Eli Zaretskii <[hidden email]> writes:

>> From: Alex <[hidden email]>
>> Cc: Alex Branham <[hidden email]>,  [hidden email]
>> Date: Thu, 14 Mar 2019 10:45:32 -0600
>> >
>> > I think this is a documentation bug, as it doesn't describe the
>> > special case of "no previous nonblank line".
>>
>> I believe that the case of "no previous nonblank line" could be
>> considered as there being a single indent point at column 0, so if
>> FIRST-ONLY is non-nil, then `tab-to-tab-stop' shouldn't be called. How
>> about the following patch instead?
>
> I don't understand what you are saying here.  The doc string says "no
> indent point _beyond_" the column where point starts, so assuming a
> single indent point at column zero doesn't change anything.

Sorry, I wasn't clear. I meant that the special case here could be
considered (trivially) equivalent to the case where the previous
non-blank line has a single indent point at column zero, and therefore
should be treated equivalently when FIRST-ONLY is non-nil
(`tab-to-tab-stop` should not be called if on or past the first indent
point, i.e., column 0).

The usage of `beyond' does not change the behaviour when the starting
column is on the first indent point, which outside of this special case
is doing nothing. Specifically, the `indent' branch of the cond is
normally executed when FIRST-ONLY is non-nil because `indent' is set
within the `re-search-backward' conditional to be equal to the starting
column; however, in this special case, `re-search-backward' returns nil
and so `indent' remains nil. My patch covers this case by also checking
for FIRST-ONLY in the cond.



Reply | Threaded
Open this post in threaded view
|

bug#34858: indent-relative called with prefix calls tab-to-tab-stop

Eli Zaretskii
> From: Alex <[hidden email]>
> Cc: [hidden email],  [hidden email]
> Date: Thu, 14 Mar 2019 12:57:08 -0600
>
> Sorry, I wasn't clear. I meant that the special case here could be
> considered (trivially) equivalent to the case where the previous
> non-blank line has a single indent point at column zero, and therefore
> should be treated equivalently when FIRST-ONLY is non-nil
> (`tab-to-tab-stop` should not be called if on or past the first indent
> point, i.e., column 0).

But then we'd do nothing in that situation.  How does it make sense?

> The usage of `beyond' does not change the behaviour when the starting
> column is on the first indent point, which outside of this special case
> is doing nothing.

When there are previous lines to align with, yes.  But here there's
nothing before, so what is the justification for doing nothing?



Reply | Threaded
Open this post in threaded view
|

bug#34858: indent-relative called with prefix calls tab-to-tab-stop

Alex-2
Eli Zaretskii <[hidden email]> writes:

>> From: Alex <[hidden email]>
>> Cc: [hidden email],  [hidden email]
>> Date: Thu, 14 Mar 2019 12:57:08 -0600
>>
>> Sorry, I wasn't clear. I meant that the special case here could be
>> considered (trivially) equivalent to the case where the previous
>> non-blank line has a single indent point at column zero, and therefore
>> should be treated equivalently when FIRST-ONLY is non-nil
>> (`tab-to-tab-stop` should not be called if on or past the first indent
>> point, i.e., column 0).
>
> But then we'd do nothing in that situation.  How does it make sense?
>
>> The usage of `beyond' does not change the behaviour when the starting
>> column is on the first indent point, which outside of this special case
>> is doing nothing.
>
> When there are previous lines to align with, yes.  But here there's
> nothing before, so what is the justification for doing nothing?

I don't see the justification for calling `tab-to-tab-stop' since that
behaviour would be surprising given that `tab-to-tab-stop' is otherwise
called only if FIRST-ONLY is nil. I view FIRST-ONLY as meaning "this
procedure will not indent past the first indent point"; in the case of
no such point, I believe that doing nothing is the more reasonable
action. Also,` indent-relative-first-indent-point' expects this
behaviour.

If one wants `indent-relative' to call `tab-to-tab-stop' in the case of
no previous non-blank line, then one could call it without the
FIRST-ONLY/prefix argument.



Reply | Threaded
Open this post in threaded view
|

bug#34858: indent-relative called with prefix calls tab-to-tab-stop

Eli Zaretskii
> From: Alex <[hidden email]>
> Cc: [hidden email],  [hidden email]
> Date: Thu, 14 Mar 2019 15:27:54 -0600
>
> >> The usage of `beyond' does not change the behaviour when the starting
> >> column is on the first indent point, which outside of this special case
> >> is doing nothing.
> >
> > When there are previous lines to align with, yes.  But here there's
> > nothing before, so what is the justification for doing nothing?
>
> I don't see the justification for calling `tab-to-tab-stop' since that
> behaviour would be surprising given that `tab-to-tab-stop' is otherwise
> called only if FIRST-ONLY is nil. I view FIRST-ONLY as meaning "this
> procedure will not indent past the first indent point"; in the case of
> no such point, I believe that doing nothing is the more reasonable
> action. Also,` indent-relative-first-indent-point' expects this
> behaviour.
>
> If one wants `indent-relative' to call `tab-to-tab-stop' in the case of
> no previous non-blank line, then one could call it without the
> FIRST-ONLY/prefix argument.

I guess we will have to disagree, then.

Alex, feel free to start a discussion on emacs-devel regarding what to
do in this special case, it seems like there's a certain controversy.

Thanks.



Reply | Threaded
Open this post in threaded view
|

bug#34858: indent-relative called with prefix calls tab-to-tab-stop

Filipp Gunbin
In reply to this post by Alex Branham
Alex, a minor comment:

On 14/03/2019 11:17 -0500, Alex Branham wrote:

> diff --git a/lisp/indent.el b/lisp/indent.el
> index 34757a43d7..25615f4113 100644
> --- a/lisp/indent.el
> +++ b/lisp/indent.el
> @@ -598,8 +598,8 @@ considered.
>
>  If the previous nonblank line has no indent points beyond the
>  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.
> +FIRST-ONLY and UNINDENTED-OK are nil, otherwise nothing is done.
> +If there isn't a previous nonblank line, call `tab-to-tab-stop'.
                                          ^
                                 and UNINDENTED-OK is nil
                                 
Filipp