GNU bug report logs - #78909
[PATCH] Add 'forward-delete-char-hungry' command

Previous Next

Package: emacs;

Reported by: Elijah Gabe Pérez <eg642616 <at> gmail.com>

Date: Thu, 26 Jun 2025 23:59:05 UTC

Severity: normal

Tags: patch

Done: Elijah Gabe Pérez <eg642616 <at> gmail.com>

To reply to this bug, email your comments to 78909 AT debbugs.gnu.org.
There is no need to reopen the bug first.

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#78909; Package emacs. (Thu, 26 Jun 2025 23:59:07 GMT) Full text and rfc822 format available.

Acknowledgement sent to Elijah Gabe Pérez <eg642616 <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 26 Jun 2025 23:59:09 GMT) Full text and rfc822 format available.

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

From: Elijah Gabe Pérez <eg642616 <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Add 'forward-delete-char-hungry' command
Date: Thu, 26 Jun 2025 17:58:27 -0600
[Message part 1 (text/plain, inline)]
Tags: patch

Hello,

This patch adds a new command similar to
`backward-delete-char-untabify`, but intended to be used forward.

I had originally planned to add the `untabify` method like
`backward-delete-char-untabify`, but I found a few bugs while testing it
(the reason is annotated in the patch), so I decided to keep the hungry
methods.

[0001-Add-forward-delete-char-hungry-command-Bug.patch (text/patch, attachment)]
[Message part 3 (text/plain, inline)]
-- 
                                          - E.G via GNU Emacs and Org.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78909; Package emacs. (Fri, 27 Jun 2025 06:38:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Elijah Gabe Pérez <eg642616 <at> gmail.com>
Cc: 78909 <at> debbugs.gnu.org
Subject: Re: bug#78909: [PATCH] Add 'forward-delete-char-hungry' command
Date: Fri, 27 Jun 2025 09:37:26 +0300
> From: Elijah Gabe Pérez <eg642616 <at> gmail.com>
> Date: Thu, 26 Jun 2025 17:58:27 -0600
> 
> This patch adds a new command similar to
> `backward-delete-char-untabify`, but intended to be used forward.

Thanks, but can you describe the rationale?

backward-delete-char-untabify exists because when the indentation is
done with TABs or a mix of TABs and SPCes, decrementing the
indentation by one column might involve replacing a TAB with the
equivalent number of SPC characters.  But this new command doesn't
have a comparable feature, whereby it "outdents" the line by one
column?  Instead, it seems it deletes the first character following
point, which means if that character is a TAB, the indentation will be
decreased by more than one column.

So what is the purpose of having this command, and what are the use
cases where it would be useful?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78909; Package emacs. (Fri, 27 Jun 2025 07:58:01 GMT) Full text and rfc822 format available.

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

From: Robert Pluim <rpluim <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 78909 <at> debbugs.gnu.org,
 Elijah Gabe Pérez <eg642616 <at> gmail.com>
Subject: Re: bug#78909: [PATCH] Add 'forward-delete-char-hungry' command
Date: Fri, 27 Jun 2025 09:56:58 +0200
>>>>> On Fri, 27 Jun 2025 09:37:26 +0300, Eli Zaretskii <eliz <at> gnu.org> said:

    >> From: Elijah Gabe Pérez <eg642616 <at> gmail.com>
    >> Date: Thu, 26 Jun 2025 17:58:27 -0600
    >> 
    >> This patch adds a new command similar to
    >> `backward-delete-char-untabify`, but intended to be used forward.

    Eli> Thanks, but can you describe the rationale?

    Eli> backward-delete-char-untabify exists because when the indentation is
    Eli> done with TABs or a mix of TABs and SPCes, decrementing the
    Eli> indentation by one column might involve replacing a TAB with the
    Eli> equivalent number of SPC characters.  But this new command doesn't
    Eli> have a comparable feature, whereby it "outdents" the line by one
    Eli> column?  Instead, it seems it deletes the first character following
    Eli> point, which means if that character is a TAB, the indentation will be
    Eli> decreased by more than one column.

    Eli> So what is the purpose of having this command, and what are the use
    Eli> cases where it would be useful?

cc-mode already provides hungry versions of forwards and backwards
whitespace deletion which can be used in other modes, I donʼt see why
we need different commands. See (info "(emacs) Hungry Delete")

Although there might be a case for having a minor mode to make
enabling use of those commands easier.

Robert
-- 




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78909; Package emacs. (Sat, 28 Jun 2025 01:03:02 GMT) Full text and rfc822 format available.

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

From: Elijah Gabe Pérez <eg642616 <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 78909 <at> debbugs.gnu.org
Subject: Re: bug#78909: [PATCH] Add 'forward-delete-char-hungry' command
Date: Fri, 27 Jun 2025 19:02:36 -0600
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Elijah Gabe Pérez <eg642616 <at> gmail.com>
>> Date: Thu, 26 Jun 2025 17:58:27 -0600
>> 
>> This patch adds a new command similar to
>> `backward-delete-char-untabify`, but intended to be used forward.
>
> Thanks, but can you describe the rationale?
>
> backward-delete-char-untabify exists because when the indentation is
> done with TABs or a mix of TABs and SPCes, decrementing the
> indentation by one column might involve replacing a TAB with the
> equivalent number of SPC characters.  But this new command doesn't
> have a comparable feature, whereby it "outdents" the line by one
> column?  Instead, it seems it deletes the first character following
> point, which means if that character is a TAB, the indentation will be
> decreased by more than one column.
>
> So what is the purpose of having this command, and what are the use
> cases where it would be useful?

I had originally intended to add a kind of `hungry-delete-mode`, because
sometimes this type of deletion is useful (e.g. for some programming
modes).

While `cc-mode` already have it, it's only "exclusive" for `cc-mode`
modes.

This new command was more of a kind of `c-hungry-delete-forward` than a
`backward-delete-char-untabify`.

I wasn't sure if it would be worth moving those cc-mode commands for
general use, or make/move the `hungry` feature from
`backward-delete-char-untabify` to be used generally.

-- 
                                          - E.G via GNU Emacs and Org.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78909; Package emacs. (Sat, 28 Jun 2025 07:18:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Elijah Gabe Pérez <eg642616 <at> gmail.com>
Cc: 78909 <at> debbugs.gnu.org
Subject: Re: bug#78909: [PATCH] Add 'forward-delete-char-hungry' command
Date: Sat, 28 Jun 2025 10:17:33 +0300
> From: Elijah Gabe Pérez <eg642616 <at> gmail.com>
> Cc: 78909 <at> debbugs.gnu.org
> Date: Fri, 27 Jun 2025 19:02:36 -0600
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> >> From: Elijah Gabe Pérez <eg642616 <at> gmail.com>
> >> Date: Thu, 26 Jun 2025 17:58:27 -0600
> >> 
> >> This patch adds a new command similar to
> >> `backward-delete-char-untabify`, but intended to be used forward.
> >
> > Thanks, but can you describe the rationale?
> >
> > backward-delete-char-untabify exists because when the indentation is
> > done with TABs or a mix of TABs and SPCes, decrementing the
> > indentation by one column might involve replacing a TAB with the
> > equivalent number of SPC characters.  But this new command doesn't
> > have a comparable feature, whereby it "outdents" the line by one
> > column?  Instead, it seems it deletes the first character following
> > point, which means if that character is a TAB, the indentation will be
> > decreased by more than one column.
> >
> > So what is the purpose of having this command, and what are the use
> > cases where it would be useful?
> 
> I had originally intended to add a kind of `hungry-delete-mode`, because
> sometimes this type of deletion is useful (e.g. for some programming
> modes).
> 
> While `cc-mode` already have it, it's only "exclusive" for `cc-mode`
> modes.
> 
> This new command was more of a kind of `c-hungry-delete-forward` than a
> `backward-delete-char-untabify`.
> 
> I wasn't sure if it would be worth moving those cc-mode commands for
> general use, or make/move the `hungry` feature from
> `backward-delete-char-untabify` to be used generally.

In addition to C Mode's hungry-delete, we also have M-\ and M-SPC,
which are available globally.  Are they not enough?  if not, can you
explain what's missing in those commands?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78909; Package emacs. (Sun, 29 Jun 2025 17:07:03 GMT) Full text and rfc822 format available.

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

From: Robert Pluim <rpluim <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 78909 <at> debbugs.gnu.org,
 Elijah Gabe Pérez <eg642616 <at> gmail.com>
Subject: Re: bug#78909: [PATCH] Add 'forward-delete-char-hungry' command
Date: Sun, 29 Jun 2025 19:06:22 +0200
>>>>> On Sat, 28 Jun 2025 10:17:33 +0300, Eli Zaretskii <eliz <at> gnu.org> said:
    >> I had originally intended to add a kind of `hungry-delete-mode`, because
    >> sometimes this type of deletion is useful (e.g. for some programming
    >> modes).
    >> 
    >> While `cc-mode` already have it, it's only "exclusive" for `cc-mode`
    >> modes.
    >>

Itʼs very easy to turn on in cc-mode, but nothing stops you doing

  (define-key my-favourite-language-mode-map "C-d" #'c-hungry-delete-forward)

    >> This new command was more of a kind of `c-hungry-delete-forward` than a
    >> `backward-delete-char-untabify`.
    >> 
    >> I wasn't sure if it would be worth moving those cc-mode commands for
    >> general use, or make/move the `hungry` feature from
    >> `backward-delete-char-untabify` to be used generally.

They donʼt need moving. They might need a minor mode command to turn
them on, along with some bindings.

    Eli> In addition to C Mode's hungry-delete, we also have M-\ and M-SPC,
    Eli> which are available globally.  Are they not enough?  if not, can you
    Eli> explain what's missing in those commands?

Iʼm not missing anything. M-SPC in particular is very handy.

Robert
-- 




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78909; Package emacs. (Wed, 02 Jul 2025 03:39:04 GMT) Full text and rfc822 format available.

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

From: Elijah Gabe Pérez <eg642616 <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 78909 <at> debbugs.gnu.org
Subject: Re: bug#78909: [PATCH] Add 'forward-delete-char-hungry' command
Date: Tue, 01 Jul 2025 21:37:53 -0600
Eli Zaretskii <eliz <at> gnu.org> writes:

>> I had originally intended to add a kind of `hungry-delete-mode`, because
>> sometimes this type of deletion is useful (e.g. for some programming
>> modes).
>> 
>> While `cc-mode` already have it, it's only "exclusive" for `cc-mode`
>> modes.
>> 
>> This new command was more of a kind of `c-hungry-delete-forward` than a
>> `backward-delete-char-untabify`.
>> 
>> I wasn't sure if it would be worth moving those cc-mode commands for
>> general use, or make/move the `hungry` feature from
>> `backward-delete-char-untabify` to be used generally.
>
> In addition to C Mode's hungry-delete, we also have M-\ and M-SPC,
> which are available globally.  Are they not enough?

M-\ and M-SPC are fine, of course, but I think it would be fine to have
other commands that combine both behaviors: delete whitespaces if there
are, otherwise delete the character forward/backward, a DWIM style.

> if not, can you explain what's missing in those commands?

Actually nothing, I'm proposing 2 DWIM-type commands (or a minor mode)
for this hungry-like deletion, similar to c-hungry commands.

`backward-delete-char-untabify` has 2 interesting hungry-like deletions,
one that only deletes both tabs and spaces, and other that deletes _all_
whitespaces.

-- 
                                          - E.G via GNU Emacs and Org.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78909; Package emacs. (Wed, 02 Jul 2025 03:55:03 GMT) Full text and rfc822 format available.

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

From: Elijah Gabe Pérez <eg642616 <at> gmail.com>
To: Robert Pluim <rpluim <at> gmail.com>
Cc: 78909 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#78909: [PATCH] Add 'forward-delete-char-hungry' command
Date: Tue, 01 Jul 2025 21:54:27 -0600
Robert Pluim <rpluim <at> gmail.com> writes:

>>>>>> On Sat, 28 Jun 2025 10:17:33 +0300, Eli Zaretskii <eliz <at> gnu.org> said:
>     >> I had originally intended to add a kind of `hungry-delete-mode`, because
>     >> sometimes this type of deletion is useful (e.g. for some programming
>     >> modes).
>     >> 
>     >> While `cc-mode` already have it, it's only "exclusive" for `cc-mode`
>     >> modes.
>     >>
>
> Itʼs very easy to turn on in cc-mode, but nothing stops you doing
>
>   (define-key my-favourite-language-mode-map "C-d" #'c-hungry-delete-forward)

Yes, but it feels weird that i need to load cc-mode package for use
those commands outside cc modes.

>     >> This new command was more of a kind of `c-hungry-delete-forward` than a
>     >> `backward-delete-char-untabify`.
>     >> 
>     >> I wasn't sure if it would be worth moving those cc-mode commands for
>     >> general use, or make/move the `hungry` feature from
>     >> `backward-delete-char-untabify` to be used generally.
>
> They donʼt need moving. They might need a minor mode command to turn
> them on, along with some bindings.

I didn't mean to move them at all (that would create incompatibility), i
meant to make them an alias for the new commands or use new commands for
the behavior, or definitely not modify them and run away.

-- 
                                          - E.G via GNU Emacs and Org.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78909; Package emacs. (Sat, 05 Jul 2025 09:04:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Elijah Gabe Pérez <eg642616 <at> gmail.com>
Cc: 78909 <at> debbugs.gnu.org
Subject: Re: bug#78909: [PATCH] Add 'forward-delete-char-hungry' command
Date: Sat, 05 Jul 2025 12:03:46 +0300
> From: Elijah Gabe Pérez <eg642616 <at> gmail.com>
> Cc: 78909 <at> debbugs.gnu.org
> Date: Tue, 01 Jul 2025 21:37:53 -0600
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> >> I had originally intended to add a kind of `hungry-delete-mode`, because
> >> sometimes this type of deletion is useful (e.g. for some programming
> >> modes).
> >> 
> >> While `cc-mode` already have it, it's only "exclusive" for `cc-mode`
> >> modes.
> >> 
> >> This new command was more of a kind of `c-hungry-delete-forward` than a
> >> `backward-delete-char-untabify`.
> >> 
> >> I wasn't sure if it would be worth moving those cc-mode commands for
> >> general use, or make/move the `hungry` feature from
> >> `backward-delete-char-untabify` to be used generally.
> >
> > In addition to C Mode's hungry-delete, we also have M-\ and M-SPC,
> > which are available globally.  Are they not enough?
> 
> M-\ and M-SPC are fine, of course, but I think it would be fine to have
> other commands that combine both behaviors: delete whitespaces if there
> are, otherwise delete the character forward/backward, a DWIM style.
> 
> > if not, can you explain what's missing in those commands?
> 
> Actually nothing, I'm proposing 2 DWIM-type commands (or a minor mode)
> for this hungry-like deletion, similar to c-hungry commands.

But that's my point: M-\ and M-SPC do the hungry-delete thing already.
So why do we need a new command?




Reply sent to Elijah Gabe Pérez <eg642616 <at> gmail.com>:
You have taken responsibility. (Wed, 09 Jul 2025 01:16:02 GMT) Full text and rfc822 format available.

Notification sent to Elijah Gabe Pérez <eg642616 <at> gmail.com>:
bug acknowledged by developer. (Wed, 09 Jul 2025 01:16:02 GMT) Full text and rfc822 format available.

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

From: Elijah Gabe Pérez <eg642616 <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 78909-done <at> debbugs.gnu.org
Subject: Re: bug#78909: [PATCH] Add 'forward-delete-char-hungry' command
Date: Tue, 08 Jul 2025 19:15:40 -0600
Eli Zaretskii <eliz <at> gnu.org> writes:

> But that's my point: M-\ and M-SPC do the hungry-delete thing already.
> So why do we need a new command?

Well honestly i saw it useful since there are already 2 packages in
MELPA that provides this, i thought that Emacs can provide this
built-in, but given the low interest, I'm closing this.

-- 
                                          - E.G via GNU Emacs and Org.




This bug report was last modified 10 days ago.

Previous Next


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