GNU bug report logs - #43068
28.0.50; RET in todo-edit-mode indents too much

Previous Next

Package: emacs;

Reported by: Stephen Berman <stephen.berman <at> gmx.net>

Date: Thu, 27 Aug 2020 11:41:02 UTC

Severity: normal

Found in version 28.0.50

Done: Stephen Berman <stephen.berman <at> gmx.net>

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 43068 in the body.
You can then email your comments to 43068 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#43068; Package emacs. (Thu, 27 Aug 2020 11:41:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stephen Berman <stephen.berman <at> gmx.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 27 Aug 2020 11:41:02 GMT) Full text and rfc822 format available.

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

From: Stephen Berman <stephen.berman <at> gmx.net>
To: bug-gnu-emacs <at> gnu.org
Subject: 28.0.50; RET in todo-edit-mode indents too much
Date: Thu, 27 Aug 2020 13:39:51 +0200
0. emacs -Q
1. M-x todo-show RET
   (This will either visit an existing todo file or, if there isn't one,
   prompt to create it, along with its first category and item.  Point
   will then be on the item.)
2. Type `em' to edit the item at point in todo-edit-mode.
3. Type RET to add a new line to the item.
   => This should insert a single tab 3 columns wide (the default value
   of todo-indent-to-here) at the start of the new line to satisfy the
   todo-mode file format, but instead two tabs are inserted (which also
   satisfies the format but is superfluous and here unexpected -- that
   is the bug).

In todo-edit-mode `newline' (bound to RET) is remapped to
`newline-and-indent' and indent-line-function is set to todo-indent,
which calles `indent-to' with `todo-indent-to-here' as args.  So typing
RET inserts a tab 3 columns wide (by default).  But by default
electric-indent-mode is enabled and that calls indent-according-to-mode,
which on typing RET again inserts a tab.  Hence, two tabs.

When the rewrite of todo-mode.el was added to Emacs (2013-06-19)
electric-indent-mode was still disabled by default, and I hadn't been
using it and it didn't occur to me that it could interact badly with
todo-mode (and there haven't been bug reports about that till now).
After the default was changed to enable electric-indent-mode
(2013-11-29), I added the line `(electric-indent-mode -1)' to my init
file, so I never saw the two tabs in my use of todo-mode.  But recently
I removed that line from my init file and then ran into this issue.

Setting electric-indent-inhibit to t in todo-edit-mode does not fix the
issue: it prevents reindentation but still calls
indent-according-to-mode from electric-indent-post-self-insert-function,
so two tabs are still inserted.  But adding the line
`(electric-indent-local-mode -1)' to todo-edit-mode does do the job.
However, I think a different approach is better.

Currently, `newline' is remapped to `newline-and-indent' not only in
todo-edit-mode but also in todo-mode, and `indent-line-function' is set
to `todo-indent' in both of these modes and well as in todo-archive-mode
and todo-filtered-items-mode.  But all of these modes except for
todo-edit-mode are read-only modes, so inserting a newline by typing RET
isn't even possible in them, therefore those settings are useless in
those modes and it was a mistake to have them there at all.  Moreover,
todo-edit-quit, which is called to exit todo-edit-mode, runs a format
check that inserts a tab at the beginning of each non-initial line of
the edited item if they don't begin with whitespace; this makes using
`newline-and-indent' unnecessary to ensure a proper format.  (The doc
string of todo-edit-quit doesn't explicitly say a tab is inserted, only
"make sure the following lines are indented", but that seems sufficient.
When editing an entire todo file instead of a single item, the format
check simply signals a user error if there are non-initial item lines
lacking initial whitespace, because editing an entire file risks
corrupting the file format in various ways.)

So my preference is to clean up and simplify todo-mode.el by removing
the remapping of `newline' and only setting `indent-line-function' to
`todo-indent' in todo-edit-mode.  Then, typing RET in todo-edit-mode
inserts a single tab if electric-indent-mode is enabled, and if it is
disabled, no tab is inserted on typing RET, but one is then inserted by
todo-edit-quit, thus preserving the required todo-mode file format.

I will commit a patch for this to master, as well as three tests of
indentation in todo mode, referencing the number of this bug report.
(Ironically, till now the todo mode data file in the Emacs test
directory contained a multiline item whose non-initial lines begin with
two tabs: I wrote this file in a clean environment in which
electric-indent-mode was enabled (as it is by default), but didn't
notice the extra tabs until I wrote the tests accompanying the fix for
this bug report.  I've removed those extra tabs as part of the commit.)


In GNU Emacs 28.0.50 (build 19, x86_64-pc-linux-gnu, GTK+ Version 3.24.17, cairo version 1.17.3)
 of 2020-08-27 built on strobe-jhalfs
Repository revision: 4cf5d2ebee5ac45a435c991e4c0ad12be619d26b
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12008000
System Description: Linux From Scratch SVN-20200401

Configured using:
 'configure 'CFLAGS=-Og -g3' PKG_CONFIG_PATH=/opt/qt5/lib/pkgconfig'

Configured features:
XPM JPEG TIFF GIF PNG RSVG CAIRO SOUND DBUS GSETTINGS GLIB NOTIFY
INOTIFY ACL GNUTLS LIBXML2 FREETYPE HARFBUZZ ZLIB TOOLKIT_SCROLL_BARS
GTK3 X11 XDBE XIM MODULES THREADS LIBSYSTEMD PDUMPER LCMS2




Reply sent to Stephen Berman <stephen.berman <at> gmx.net>:
You have taken responsibility. (Thu, 27 Aug 2020 12:04:02 GMT) Full text and rfc822 format available.

Notification sent to Stephen Berman <stephen.berman <at> gmx.net>:
bug acknowledged by developer. (Thu, 27 Aug 2020 12:04:02 GMT) Full text and rfc822 format available.

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

From: Stephen Berman <stephen.berman <at> gmx.net>
To: 43068-done <at> debbugs.gnu.org
Subject: Re: bug#43068: 28.0.50; RET in todo-edit-mode indents too much
Date: Thu, 27 Aug 2020 14:03:39 +0200
On Thu, 27 Aug 2020 13:39:51 +0200 Stephen Berman <stephen.berman <at> gmx.net> wrote:

> 0. emacs -Q
> 1. M-x todo-show RET
>    (This will either visit an existing todo file or, if there isn't one,
>    prompt to create it, along with its first category and item.  Point
>    will then be on the item.)
> 2. Type `em' to edit the item at point in todo-edit-mode.
> 3. Type RET to add a new line to the item.
>    => This should insert a single tab 3 columns wide (the default value
>    of todo-indent-to-here) at the start of the new line to satisfy the
>    todo-mode file format, but instead two tabs are inserted (which also
>    satisfies the format but is superfluous and here unexpected -- that
>    is the bug).
[...]
> I will commit a patch for this to master, as well as three tests of
> indentation in todo mode, referencing the number of this bug report.

Done in commit ed3c971534 and closing.

Steve Berman




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

This bug report was last modified 3 years and 211 days ago.

Previous Next


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