GNU bug report logs - #35647
Documentation and implementation of (move-to-column <n> t) differ.

Previous Next

Package: emacs;

Reported by: Alan Mackenzie <acm <at> muc.de>

Date: Thu, 9 May 2019 10:50:01 UTC

Severity: normal

Done: Alan Mackenzie <acm <at> muc.de>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 35647 in the body.
You can then email your comments to 35647 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#35647; Package emacs. (Thu, 09 May 2019 10:50:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Alan Mackenzie <acm <at> muc.de>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 09 May 2019 10:50:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: bug-gnu-emacs <at> gnu.org
Subject: Documentation and implementation of (move-to-column <n> t) differ.
Date: Thu, 9 May 2019 10:48:50 +0000
Hello, Emacs.

In (move-to-column <n> t), the t argument, FORCE, "replaces the tab with
spaces" if it needs to do so to get exactly to column <n> which is in
the middle of a tab.

At least, that's what the documentation says.

In the implementation, when indent-tabs-mode is non-nil, Emacs _inserts_
spaces before the tab to get to column <n>, rather than replacing the
tab with spaces.

This discrepancy is a bug.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

What the code in Fmove_to_column actually does is to delete the tab,
insert enough spaces to get to column <n>, then calls Findent_to to
finish the indentation to <n>.  Findent_to uses a tab when
indent-tabs-mode is non-nil.

My feeling here is that the documentation rather than the code should be
amended.  To amend the code would make it more difficult for
uncomment-region to restore a tab character which has been earlier
manipulated by comment-region.  (See also bug #35600.)

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#35647; Package emacs. (Thu, 09 May 2019 14:05:02 GMT) Full text and rfc822 format available.

Message #8 received at 35647 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Alan Mackenzie <acm <at> muc.de>
Cc: 35647 <at> debbugs.gnu.org
Subject: Re: bug#35647: Documentation and implementation of (move-to-column
 <n> t) differ.
Date: Thu, 09 May 2019 17:04:19 +0300
> Date: Thu, 9 May 2019 10:48:50 +0000
> From: Alan Mackenzie <acm <at> muc.de>
> 
> What the code in Fmove_to_column actually does is to delete the tab,
> insert enough spaces to get to column <n>, then calls Findent_to to
> finish the indentation to <n>.  Findent_to uses a tab when
> indent-tabs-mode is non-nil.
> 
> My feeling here is that the documentation rather than the code should be
> amended.  To amend the code would make it more difficult for
> uncomment-region to restore a tab character which has been earlier
> manipulated by comment-region.  (See also bug #35600.)

Would you mind preparing a documentation patch for this issue?

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#35647; Package emacs. (Thu, 09 May 2019 15:06:01 GMT) Full text and rfc822 format available.

Message #11 received at 35647 <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 35647 <at> debbugs.gnu.org
Subject: Re: bug#35647: Documentation and implementation of (move-to-column
 <n> t) differ.
Date: Thu, 9 May 2019 15:05:37 +0000
Hello, Eli.

On Thu, May 09, 2019 at 17:04:19 +0300, Eli Zaretskii wrote:
> > Date: Thu, 9 May 2019 10:48:50 +0000
> > From: Alan Mackenzie <acm <at> muc.de>

> > What the code in Fmove_to_column actually does is to delete the tab,
> > insert enough spaces to get to column <n>, then calls Findent_to to
> > finish the indentation to <n>.  Findent_to uses a tab when
> > indent-tabs-mode is non-nil.

> > My feeling here is that the documentation rather than the code should be
> > amended.  To amend the code would make it more difficult for
> > uncomment-region to restore a tab character which has been earlier
> > manipulated by comment-region.  (See also bug #35600.)

> Would you mind preparing a documentation patch for this issue?

How about:


diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi
index 500df1f8f0..278bc3c268 100644
--- a/doc/lispref/text.texi
+++ b/doc/lispref/text.texi
@@ -2252,9 +2252,11 @@ Columns
 the middle of a multicolumn character such as a tab, point moves to the
 end of that character.  However, if @var{force} is non-@code{nil}, and
 @var{column} is in the middle of a tab, then @code{move-to-column}
-converts the tab into spaces so that it can move precisely to column
-@var{column}.  Other multicolumn characters can cause anomalies despite
-@var{force}, since there is no way to split them.
+either converts the tab into spaces (when @code{indent-tabs-mode} is
+@code{nil}), or inserts enough spaces before it (otherwise), so that
+point can move precisely to column @var{column}.  Other multicolumn
+characters can cause anomalies despite @var{force}, since there is no
+way to split them.
 
 The argument @var{force} also has an effect if the line isn't long
 enough to reach column @var{column}; if it is @code{t}, that means to
diff --git a/src/indent.c b/src/indent.c
index c76e6b7b4b..90d8b1ce8e 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -983,9 +983,10 @@ If specified column is within a character, point goes after that character.
 If it's past end of line, point goes to end of line.
 
 Optional second argument FORCE non-nil means if COLUMN is in the
-middle of a tab character, change it to spaces.
-In addition, if FORCE is t, and the line is too short to reach
-COLUMN, add spaces/tabs to get there.
+middle of a tab character, either change it to spaces (when
+`indent-tabs-mode' is nil), or insert enough spaces before it to reach
+COLUMN (otherwise).  In addition, if FORCE is t, and the line is too short
+to reach COLUMN, add spaces/tabs to get there.
 
 The return value is the current column.  */)
   (Lisp_Object column, Lisp_Object force)


?

> Thanks.

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#35647; Package emacs. (Thu, 09 May 2019 15:44:01 GMT) Full text and rfc822 format available.

Message #14 received at 35647 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Alan Mackenzie <acm <at> muc.de>
Cc: 35647 <at> debbugs.gnu.org
Subject: Re: bug#35647: Documentation and implementation of (move-to-column
 <n> t) differ.
Date: Thu, 09 May 2019 18:43:06 +0300
> Date: Thu, 9 May 2019 15:05:37 +0000
> Cc: 35647 <at> debbugs.gnu.org
> From: Alan Mackenzie <acm <at> muc.de>
> 
> > Would you mind preparing a documentation patch for this issue?
> 
> How about:

Fine with me, thanks.

Please push to the emacs-26 branch.




Reply sent to Alan Mackenzie <acm <at> muc.de>:
You have taken responsibility. (Thu, 09 May 2019 16:33:02 GMT) Full text and rfc822 format available.

Notification sent to Alan Mackenzie <acm <at> muc.de>:
bug acknowledged by developer. (Thu, 09 May 2019 16:33:02 GMT) Full text and rfc822 format available.

Message #19 received at 35647-done <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 35647-done <at> debbugs.gnu.org
Subject: Re: bug#35647: Documentation and implementation of (move-to-column
 <n> t) differ.
Date: Thu, 9 May 2019 16:32:57 +0000
Hello, Eli.

On Thu, May 09, 2019 at 18:43:06 +0300, Eli Zaretskii wrote:
> > Date: Thu, 9 May 2019 15:05:37 +0000
> > Cc: 35647 <at> debbugs.gnu.org
> > From: Alan Mackenzie <acm <at> muc.de>

> > > Would you mind preparing a documentation patch for this issue?

> > How about:

> Fine with me, thanks.

:-)

> Please push to the emacs-26 branch.

DONE.

I'm closing the bug.

-- 
Alan Mackenzie (Nuremberg, Germany).




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 07 Jun 2019 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 317 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.