GNU bug report logs - #75042
29.4; `backward-delete-char-untabify': active-region behavior

Previous Next

Package: emacs;

Reported by: Asher Copeland <ashercopeland <at> gmail.com>

Date: Mon, 23 Dec 2024 08:37:01 UTC

Severity: normal

Tags: patch

Found in version 29.4

Done: Eli Zaretskii <eliz <at> gnu.org>

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 75042 in the body.
You can then email your comments to 75042 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#75042; Package emacs. (Mon, 23 Dec 2024 08:37:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Asher Copeland <ashercopeland <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 23 Dec 2024 08:37:02 GMT) Full text and rfc822 format available.

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

From: Asher Copeland <ashercopeland <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 29.4; `backward-delete-char-untabify': active-region behavior
Date: Sun, 22 Dec 2024 17:52:04 -0800
The documentation of `backward-delete-char-untabify' indicates the
following:

 If Transient Mark mode is enabled, the mark is active, and ARG is 1,
 delete the text in the region and deactivate the mark instead.
 To disable this, set option `delete-active-region' to nil.

However, when `backward-delete-char-untabify-method' is set to hungry or
all and point has more than one whitespace character before it
(i.e. that `backward-delete-char-untabify' would delete more than one
character), `backward-delete-char-untabify' ignores the settings of
`transient-mark-mode' and `delete-active-region' and proceeds with its
normal action.

Practically, this means that, in a snippet of text such as the
following (assuming the spacing/newlines don't get messed up):

    line1
    line2
    line3

If point were placed before line2 and the region is active and nonempty,
with `backward-delete-char-untabify-method' set to hungry, the expected
behavior (and the behavior that is currently documented) would be that
the text highlighted by the region would be deleted and that the region
would be deactivated. What the function would instead do is delete the
spaces to the left of point and deactivate the region.

I have found this issue to occur running under `emacs -Q'.

For consistency with the current documentation and other deletion
commands, I believe that the behavior of `backward-delete-char-untabify'
should change to delete the text in the region, under the same
conditions that `backward-delete-char' would do the same.

Here is the last form of the definition of
`backward-delete-char-untabify', from simple.el:6522, for reference:

   (let* ((skip (cond ((eq backward-delete-char-untabify-method 'hungry) " \t")
                      ((eq backward-delete-char-untabify-method 'all)
                       " \t\n\r")))
          (n (if skip
                 (let* ((oldpt (point))
                        (wh (- oldpt (save-excursion
                                       (skip-chars-backward skip)
                                       (constrain-to-field nil oldpt)))))
                   (+ arg (if (zerop wh) 0 (1- wh))))
               arg)))
     ;; Avoid warning about delete-backward-char
     (with-no-warnings (delete-backward-char n killp))))

The issue seems to stem from the last line. In the described conditions,
the symbol `n' would be bound to a value greater than 1. Therefore,
`delete-backward-char' would delete n characters and deactivate the
region, instead of deleting the region.

--
Asher


In GNU Emacs 29.4 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo
 version 1.18.0, Xaw scroll bars) of 2024-10-16 built on asher-v-ubuntu
System Description: Ubuntu 24.04.1 LTS

Configured using:
 'configure --with-x-toolkit=lucid --prefix=/opt/emacs'

Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG
LIBSELINUX LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND
THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11 XDBE XIM XINPUT2
XPM LUCID ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Fundamental

Minor modes in effect:
  gpm-mouse-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: linux
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr help-fns radix-tree help-mode emacsbug message
mailcap yank-media puny dired dired-loaddefs rfc822 mml mml-sec
password-cache epa derived epg rfc6068 epg-config gnus-util
text-property-search time-date subr-x mm-decode mm-bodies mm-encode
mail-parse rfc2231 mailabbrev gmm-utils mailheader cl-loaddefs cl-lib
sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils
t-mouse term/linux rmc iso-transl tooltip cconv eldoc paren electric
uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel
term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu
timer select scroll-bar mouse jit-lock font-lock syntax font-core
term/tty-colors frame minibuffer nadvice seq simple cl-generic
indonesian philippine cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
theme-loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads dbusbind inotify
dynamic-setting system-font-setting font-render-setting cairo x-toolkit
xinput2 x multi-tty make-network-process emacs)

Memory information:
((conses 16 38095 7179)
 (symbols 48 5293 1)
 (strings 32 13493 2007)
 (string-bytes 1 379725)
 (vectors 16 7691)
 (vector-slots 8 105658 7932)
 (floats 8 19 318)
 (intervals 56 201 9)
 (buffers 984 11))




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

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

From: Asher Copeland <ashercopeland <at> gmail.com>
To: 75042 <at> debbugs.gnu.org
Subject: `backward-delete-char-untabify': active-region behavior
Date: Wed, 02 Apr 2025 10:59:04 -0700
[Message part 1 (text/plain, inline)]
Tags: patch

I have attached to this e-mail a patch that I believe fixes the bug, by
adding a condition that checks for the same conditions that
`delete-backward-char' uses for the same behavior, and delegates to
`delete-backward-char' if the conditions are met.

I have also found that the bug has another aspect, also fixed by the
patch. I will describe the steps for reproducing it below:

 1) emacs -Q
 2) C-q TAB w o r d
 3) C-SPC M-b
 4) Execute `backward-delete-char-untabify' (bound to DEL)

Notice that "word" was deleted, which is expected, but that the literal
TAB character was untabified, even though it was not necessary to do so.

The expected behavior is to delete "word" without untabifying.

I've looked at my previous e-mail and realized that I didn't leave clear
steps for reproduction for that aspect of the bug, so I will do so here:

 1) emacs -Q
 2) M-: (setq backward-delete-char-untabify-method 'hungry)
 3) SPC SPC w o r d
 4) C-SPC M-b
 5) Execute `backward-delete-char-untabify' (bound to DEL)

The expected behavior for it to delete "word", but instead it deletes
the two spaces to the left of point.

This patch fixes both issues with a single branch that makes it act like
`delete-backward-char' when it is appropriate to kill the region.

[0001-backward-delete-char-untabify-active-region-behavior.patch (text/patch, attachment)]

Added tag(s) patch. Request was from Asher Copeland <ashercopeland <at> gmail.com> to control <at> debbugs.gnu.org. (Thu, 03 Apr 2025 05:25:02 GMT) Full text and rfc822 format available.

Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Sun, 13 Apr 2025 08:28:07 GMT) Full text and rfc822 format available.

Notification sent to Asher Copeland <ashercopeland <at> gmail.com>:
bug acknowledged by developer. (Sun, 13 Apr 2025 08:28:07 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Asher Copeland <ashercopeland <at> gmail.com>
Cc: 75042-done <at> debbugs.gnu.org
Subject: Re: bug#75042: `backward-delete-char-untabify': active-region behavior
Date: Sun, 13 Apr 2025 11:27:12 +0300
> From: Asher Copeland <ashercopeland <at> gmail.com>
> Date: Wed, 02 Apr 2025 10:59:04 -0700
> 
> I have attached to this e-mail a patch that I believe fixes the bug, by
> adding a condition that checks for the same conditions that
> `delete-backward-char' uses for the same behavior, and delegates to
> `delete-backward-char' if the conditions are met.
> 
> I have also found that the bug has another aspect, also fixed by the
> patch. I will describe the steps for reproducing it below:
> 
>  1) emacs -Q
>  2) C-q TAB w o r d
>  3) C-SPC M-b
>  4) Execute `backward-delete-char-untabify' (bound to DEL)
> 
> Notice that "word" was deleted, which is expected, but that the literal
> TAB character was untabified, even though it was not necessary to do so.
> 
> The expected behavior is to delete "word" without untabifying.
> 
> I've looked at my previous e-mail and realized that I didn't leave clear
> steps for reproduction for that aspect of the bug, so I will do so here:
> 
>  1) emacs -Q
>  2) M-: (setq backward-delete-char-untabify-method 'hungry)
>  3) SPC SPC w o r d
>  4) C-SPC M-b
>  5) Execute `backward-delete-char-untabify' (bound to DEL)
> 
> The expected behavior for it to delete "word", but instead it deletes
> the two spaces to the left of point.
> 
> This patch fixes both issues with a single branch that makes it act like
> `delete-backward-char' when it is appropriate to kill the region.

Thanks, installed on the master branch, and closing the bug.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 11 May 2025 11:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 37 days ago.

Previous Next


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