GNU bug report logs - #78262
30.1; comint-delchar-or-maybe-eof doesn't respect delete-active-region

Previous Next

Package: emacs;

Reported by: Sebastián Monía <sebastian <at> sebasmonia.com>

Date: Mon, 5 May 2025 14:45:02 UTC

Severity: normal

Merged with 73527

Found in versions 30.1, 30.0.90

Fixed in version 31.0.50

Done: Juri Linkov <juri <at> linkov.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 78262 in the body.
You can then email your comments to 78262 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#78262; Package emacs. (Mon, 05 May 2025 14:45:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Sebastián Monía <sebastian <at> sebasmonia.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 05 May 2025 14:45:02 GMT) Full text and rfc822 format available.

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

From: Sebastián Monía <sebastian <at> sebasmonia.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 30.1; comint-delchar-or-maybe-eof doesn't respect delete-active-region
Date: Mon, 05 May 2025 10:43:59 -0400
Hello!

Noticed this in SQL Interactive mode, but just tested in M-x shell and
the same thing happens.
Comint and its derived modes override C-d 'delete-forward-char' with
'comint-delchar-or-maybe-eof'.

The latter internally uses delete-char, which doesn't respect
delete-active-region. The delete-char docstring states:

> The command 'delete-forward-char' is preferable for interactive use,
> e.g. because it respects values of 'delete-active-region' and
> 'overwrite-mode'.

Since comint-delchar-or-maybe-eof is meant for interactive use, maybe we
should change the command:

(defun comint-delchar-or-maybe-eof (arg)
  "Delete ARG characters forward or send an EOF to subprocess.
Sends an EOF only if point is at the end of the buffer and there is no input."
  (interactive "p" comint-mode)
  (let ((proc (get-buffer-process (current-buffer))))
    (if (and (eobp) proc (= (point) (marker-position (process-mark proc))))
	(comint-send-eof)
      ;; delete-char ==> delete-forward-char
      (delete-forward-char arg nil))))

If we are good with the change, I can send a proper patch with changelog
etc. But maybe there's a reason it works like this, and my limited
comint usage misses the point.

Thanks,
Seb

In GNU Emacs 30.1 (build 2, x86_64-w64-mingw32) of 2025-02-23 built on
 AVALON
Windowing system distributor 'Microsoft Corp.', version 10.0.26100
System Description: Microsoft Windows 10 Enterprise (v10.0.2009.26100.3775)

Configured using:
 'configure --with-modules --without-dbus --with-native-compilation=aot
 --without-compress-install --with-tree-sitter CFLAGS=-O2
 prefix=/g/rel/install/emacs-30.1'

Configured features:
ACL GIF GMP GNUTLS HARFBUZZ JPEG LCMS2 LIBXML2 MODULES NATIVE_COMP
NOTIFY W32NOTIFY PDUMPER PNG RSVG SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS TREE_SITTER WEBP XPM ZLIB

Important settings:
  value of $LANG: ENU
  locale-coding-system: cp1252

Major mode: Group

Minor modes in effect:
  gnus-undo-mode: t
  global-hl-line-mode: t
  csv-field-index-mode: t
  server-mode: t
  global-so-long-mode: t
  savehist-mode: t
  repeat-mode: t
  delete-selection-mode: t
  override-global-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  minibuffer-regexp-mode: t
  buffer-read-only: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
~/sourcehut/dotfiles/.config/emacs/custom hides c:/Users/SEBM/home/emacs/share/emacs/30.1/lisp/custom

Features:
(shadow gnus-cite mail-extr emacsbug nndraft nnmh utf-7 network-stream
nsm nnnil gnus-agent gnus-srvr gnus-score score-mode nnvirtual gnus-msg
gnus-art mm-uu mml2015 mm-view mml-smime smime gnutls dig nntp
gnus-cache gnus-sum gnus-group gnus-undo gnus-start gnus-dbus gnus-cloud
nnimap nnmail mail-source utf7 nnoo gnus-spec gnus-int gnus-range
message rfc822 mml mml-sec mm-decode mm-bodies mm-encode mail-parse
rfc2231 mailabbrev gmm-utils mailheader gnus-win cl-print two-column
tramp-cache time-stamp shortdoc help-fns radix-tree reveal epa-file epa
epg rfc6068 dired-aux gnus-dired tramp-sh find-dired yank-media
markdown-mode color noutline outline eglot external-completion jsonrpc
xref ert debug backtrace find-func filenotify flymake sql-datum sql view
smerge-mode diff python compat misearch multi-isearch sh-script smie
treesit executable conf-mode vc-hg vc-bzr vc-src vc-sccs vc-svn vc-cvs
vc-rcs log-view pcvs-util vc-dir ewoc project appt
display-fill-column-indicator ws-butler comp-run comp-common hl-line
sc-init csv-mode sort tramp trampver tramp-integration files-x
tramp-message tramp-compat shell pcomplete parse-time iso8601
format-spec tramp-loaddefs cus-edit server ispell confluence-reader
derived pyvenv azcli jira-tools rx bookmark pp ghcli site cambalache
vtable mule-util smtpmail sendmail rfc2047 rfc2045 ietf-drums ecomplete
hoagie-theme so-long vundo pcase vc-git diff-mode track-changes vc
vc-dispatcher savehist warnings repeat proced notifications dbus imenu
grep compile cus-load eww xdg url-queue thingatpt shr pixel-fill kinsoku
url-file svg xml dom puny mm-url gnus nnheader gnus-util
text-property-search time-date mail-utils range wid-edit mm-util
mail-prsvr epg-config dired dired-loaddefs diary-lib diary-loaddefs
dabbrev comint ansi-osc ansi-color ring cal-menu calendar cal-loaddefs
advice browse-kill-ring delsel hoagie-notes hoagie-editing edmacro
kmacro cl-extra help-mode use-package use-package-ensure
use-package-delight use-package-diminish use-package-bind-key bind-key
easy-mmode use-package-core browse-kill-ring-autoloads
csv-mode-autoloads debbugs-autoloads markdown-mode-autoloads
package-lint-autoloads restclient-autoloads info sly-autoloads
vundo-autoloads ws-butler-autoloads package browse-url url url-proxy
url-privacy url-expand url-methods url-history url-cookie
generate-lisp-file url-domsuf url-util mailcap url-handlers url-parse
auth-source cl-seq eieio eieio-core cl-macs icons password-cache json
subr-x map byte-opt gv bytecomp byte-compile url-vars cl-loaddefs cl-lib
rmc iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook
vc-hooks lisp-float-type elisp-mode mwheel touch-screen dos-w32 ls-lisp
disp-table term/w32-win w32-win w32-vars term/common-win 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 w32notify w32 lcms2 multi-tty
move-toolbar make-network-process native-compile emacs)

Memory information:
((conses 16 590368 54839) (symbols 48 29342 3)
 (strings 32 116770 7974) (string-bytes 1 3740680) (vectors 16 59811)
 (vector-slots 8 1491221 178508) (floats 8 584 498)
 (intervals 56 13505 1557) (buffers 992 46))

-- 
Sebastián Monía
https://site.sebasmonia.com/




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78262; Package emacs. (Thu, 08 May 2025 10:37:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Sebastián Monía <sebastian <at> sebasmonia.com>
Cc: 78262 <at> debbugs.gnu.org
Subject: Re: bug#78262: 30.1;
 comint-delchar-or-maybe-eof doesn't respect delete-active-region
Date: Thu, 08 May 2025 13:36:12 +0300
> From: Sebastián Monía
>  <sebastian <at> sebasmonia.com>
> Date: Mon, 05 May 2025 10:43:59 -0400
> 
> Noticed this in SQL Interactive mode, but just tested in M-x shell and
> the same thing happens.
> Comint and its derived modes override C-d 'delete-forward-char' with
> 'comint-delchar-or-maybe-eof'.
> 
> The latter internally uses delete-char, which doesn't respect
> delete-active-region. The delete-char docstring states:
> 
> > The command 'delete-forward-char' is preferable for interactive use,
> > e.g. because it respects values of 'delete-active-region' and
> > 'overwrite-mode'.
> 
> Since comint-delchar-or-maybe-eof is meant for interactive use, maybe we
> should change the command:
> 
> (defun comint-delchar-or-maybe-eof (arg)
>   "Delete ARG characters forward or send an EOF to subprocess.
> Sends an EOF only if point is at the end of the buffer and there is no input."
>   (interactive "p" comint-mode)
>   (let ((proc (get-buffer-process (current-buffer))))
>     (if (and (eobp) proc (= (point) (marker-position (process-mark proc))))
> 	(comint-send-eof)
>       ;; delete-char ==> delete-forward-char
>       (delete-forward-char arg nil))))
> 
> If we are good with the change, I can send a proper patch with changelog
> etc. But maybe there's a reason it works like this, and my limited
> comint usage misses the point.

I'm not a frequent user of comint-derived modes, but is this indeed
consistent with what users expect from interactive shells?  AFAIK,
shells don't support the notion of "active region" or
"delete-selection" or anything similar.  Wouldn't this change in
behavior surprise people?  Should we perhaps have it as an opt-in
behavior?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78262; Package emacs. (Thu, 08 May 2025 13:25:02 GMT) Full text and rfc822 format available.

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

From: Sebastián Monía <sebastian <at> sebasmonia.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 78262 <at> debbugs.gnu.org
Subject: Re: bug#78262: 30.1; comint-delchar-or-maybe-eof doesn't respect
 delete-active-region
Date: Thu, 08 May 2025 09:24:31 -0400
Eli Zaretskii <eliz <at> gnu.org> writes:
>> But maybe there's a reason it works like this, and my limited comint
>> usage misses the point.
>
> I'm not a frequent user of comint-derived modes, but is this indeed
> consistent with what users expect from interactive shells?  AFAIK,
> shells don't support the notion of "active region" or
> "delete-selection" or anything similar.  Wouldn't this change in
> behavior surprise people?  Should we perhaps have it as an opt-in
> behavior?

Well, that is a good point.
The counterargument (emmm from blogs and reddit :) so take it with a
grain of salt) is that the point of running shells inside Emacs is to
have all the same editing capabilities, combined with the shell.

And another data point: I was suprised/annoyed that it didn't behave the
same as any buffer.

But there's no harm in putting the new behavior behing a new defcustom
comint-delete-active-region? 


-- 
Sebastián Monía
https://site.sebasmonia.com/




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78262; Package emacs. (Thu, 08 May 2025 13:37:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Sebastián Monía <sebastian <at> sebasmonia.com>
Cc: 78262 <at> debbugs.gnu.org
Subject: Re: bug#78262: 30.1; comint-delchar-or-maybe-eof doesn't respect
 delete-active-region
Date: Thu, 08 May 2025 16:36:02 +0300
> From: Sebastián Monía <sebastian <at> sebasmonia.com>
> Cc: 78262 <at> debbugs.gnu.org
> Date: Thu, 08 May 2025 09:24:31 -0400
> 
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> >> But maybe there's a reason it works like this, and my limited comint
> >> usage misses the point.
> >
> > I'm not a frequent user of comint-derived modes, but is this indeed
> > consistent with what users expect from interactive shells?  AFAIK,
> > shells don't support the notion of "active region" or
> > "delete-selection" or anything similar.  Wouldn't this change in
> > behavior surprise people?  Should we perhaps have it as an opt-in
> > behavior?
> 
> Well, that is a good point.
> The counterargument (emmm from blogs and reddit :) so take it with a
> grain of salt) is that the point of running shells inside Emacs is to
> have all the same editing capabilities, combined with the shell.
> 
> And another data point: I was suprised/annoyed that it didn't behave the
> same as any buffer.
> 
> But there's no harm in putting the new behavior behing a new defcustom
> comint-delete-active-region? 

Yes, that's what I meant by making it an opt-in behavior.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78262; Package emacs. (Thu, 08 May 2025 17:03:01 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Sebastián Monía <sebastian <at> sebasmonia.com>
Cc: 78262 <at> debbugs.gnu.org
Subject: Re: bug#78262: 30.1; comint-delchar-or-maybe-eof doesn't respect
 delete-active-region
Date: Thu, 08 May 2025 19:58:07 +0300
> Since comint-delchar-or-maybe-eof is meant for interactive use, maybe we
> should change the command:
>
> (defun comint-delchar-or-maybe-eof (arg)
>   "Delete ARG characters forward or send an EOF to subprocess.
> Sends an EOF only if point is at the end of the buffer and there is no input."
>   (interactive "p" comint-mode)
>   (let ((proc (get-buffer-process (current-buffer))))
>     (if (and (eobp) proc (= (point) (marker-position (process-mark proc))))
> 	(comint-send-eof)
>       ;; delete-char ==> delete-forward-char
>       (delete-forward-char arg nil))))

bug#73527 stumbled over this.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78262; Package emacs. (Fri, 09 May 2025 06:54:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Sebastián Monía <sebastian <at> sebasmonia.com>
Cc: 78262 <at> debbugs.gnu.org
Subject: Re: bug#78262: 30.1; comint-delchar-or-maybe-eof doesn't respect
 delete-active-region
Date: Fri, 09 May 2025 09:52:02 +0300
> Comint and its derived modes override C-d 'delete-forward-char' with
> 'comint-delchar-or-maybe-eof'.

Does the solution proposed by Augusto in bug#73527 fix your use case?

diff --git a/lisp/comint.el b/lisp/comint.el
index 188989ff8a4..2189b10e826 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -2796,7 +2796,7 @@ comint-delchar-or-maybe-eof
   (let ((proc (get-buffer-process (current-buffer))))
     (if (and (eobp) proc (= (point) (marker-position (process-mark proc))))
 	(comint-send-eof)
-      (delete-char arg))))
+      (funcall-interactively (keymap-lookup global-map "C-d") arg))))
 
 (defun comint-send-eof ()
   "Send an EOF to the current buffer's process."




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78262; Package emacs. (Sat, 10 May 2025 11:16:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Juri Linkov <juri <at> linkov.net>,
 Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: sebastian <at> sebasmonia.com, 78262 <at> debbugs.gnu.org
Subject: Re: bug#78262: 30.1;
 comint-delchar-or-maybe-eof doesn't respect delete-active-region
Date: Sat, 10 May 2025 14:15:30 +0300
> Cc: 78262 <at> debbugs.gnu.org
> From: Juri Linkov <juri <at> linkov.net>
> Date: Fri, 09 May 2025 09:52:02 +0300
> 
> > Comint and its derived modes override C-d 'delete-forward-char' with
> > 'comint-delchar-or-maybe-eof'.
> 
> Does the solution proposed by Augusto in bug#73527 fix your use case?
> 
> diff --git a/lisp/comint.el b/lisp/comint.el
> index 188989ff8a4..2189b10e826 100644
> --- a/lisp/comint.el
> +++ b/lisp/comint.el
> @@ -2796,7 +2796,7 @@ comint-delchar-or-maybe-eof
>    (let ((proc (get-buffer-process (current-buffer))))
>      (if (and (eobp) proc (= (point) (marker-position (process-mark proc))))
>  	(comint-send-eof)
> -      (delete-char arg))))
> +      (funcall-interactively (keymap-lookup global-map "C-d") arg))))
>  
>  (defun comint-send-eof ()
>    "Send an EOF to the current buffer's process."

This assumes that everyone will want the same command bound to C-d
globally to be invoked by C-d in comint-mode.  But is that assumption
necessarily true?

Stefan, WDYT?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78262; Package emacs. (Sun, 11 May 2025 04:15:01 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: sebastian <at> sebasmonia.com, 78262 <at> debbugs.gnu.org,
 Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#78262: 30.1; comint-delchar-or-maybe-eof doesn't respect
 delete-active-region
Date: Sun, 11 May 2025 00:14:16 -0400
>> Does the solution proposed by Augusto in bug#73527 fix your use case?
>> 
>> diff --git a/lisp/comint.el b/lisp/comint.el
>> index 188989ff8a4..2189b10e826 100644
>> --- a/lisp/comint.el
>> +++ b/lisp/comint.el
>> @@ -2796,7 +2796,7 @@ comint-delchar-or-maybe-eof
>>    (let ((proc (get-buffer-process (current-buffer))))
>>      (if (and (eobp) proc (= (point) (marker-position (process-mark proc))))
>>  	(comint-send-eof)
>> -      (delete-char arg))))
>> +      (funcall-interactively (keymap-lookup global-map "C-d") arg))))

I'd rather not make assumptions about what arguments that command takes
(i.e. use `call-interactively`, as in the code below).

> This assumes that everyone will want the same command bound to C-d
> globally to be invoked by C-d in comint-mode.  But is that assumption
> necessarily true?

It's hard to handle all possible worlds at the same time, so I think
we have to presume the answer is "yes".  If they want something
different, they'll have to rebind it explicitly in `comint-mode-map`.

Similarly, we could worry about the case where `C-d` is globally bound
to something that's completely different from some kind of "delete
char" command, in which case turning it into an "EOF" signal may make
very little sense, but there's not much we can do about that: the usual
way to accommodate that is to rely on `remap` instead but here we can't
do that because we specifically want to handle `C-d` bindings
differently from other bindings (e.g. `delete`) to the same command.


        Stefan


diff --git a/lisp/comint.el b/lisp/comint.el
index 188989ff8a4..35765c8427e 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -2789,14 +2789,14 @@ comint-kill-input
     (if (> (point) (marker-position pmark))
 	(kill-region pmark (point)))))
 
-(defun comint-delchar-or-maybe-eof (arg)
-  "Delete ARG characters forward or send an EOF to subprocess.
+(defun comint-delchar-or-maybe-eof ()
+  "Do like the global binding or send an EOF to subprocess.
 Sends an EOF only if point is at the end of the buffer and there is no input."
-  (interactive "p" comint-mode)
+  (interactive nil comint-mode)
   (let ((proc (get-buffer-process (current-buffer))))
     (if (and (eobp) proc (= (point) (marker-position (process-mark proc))))
 	(comint-send-eof)
-      (delete-char arg))))
+      (call-interactively (lookup-key global-map (this-command-keys))))))
 
 (defun comint-send-eof ()
   "Send an EOF to the current buffer's process."





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78262; Package emacs. (Sun, 11 May 2025 05:56:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: sebastian <at> sebasmonia.com, 78262 <at> debbugs.gnu.org, juri <at> linkov.net
Subject: Re: bug#78262: 30.1; comint-delchar-or-maybe-eof doesn't respect
 delete-active-region
Date: Sun, 11 May 2025 08:55:38 +0300
> From: Stefan Monnier <monnier <at> iro.umontreal.ca>
> Cc: Juri Linkov <juri <at> linkov.net>,  sebastian <at> sebasmonia.com,
>   78262 <at> debbugs.gnu.org
> Date: Sun, 11 May 2025 00:14:16 -0400
> 
> > This assumes that everyone will want the same command bound to C-d
> > globally to be invoked by C-d in comint-mode.  But is that assumption
> > necessarily true?
> 
> It's hard to handle all possible worlds at the same time, so I think
> we have to presume the answer is "yes".  If they want something
> different, they'll have to rebind it explicitly in `comint-mode-map`.

The issue here is whether to support active region (which C-d does).
Are we sure users of comint want that in respective modes?

> -(defun comint-delchar-or-maybe-eof (arg)
> -  "Delete ARG characters forward or send an EOF to subprocess.
> +(defun comint-delchar-or-maybe-eof ()
> +  "Do like the global binding or send an EOF to subprocess.

I think we need to leave ARG in place, at least as an optional
argument, since otherwise this would be a breaking change.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78262; Package emacs. (Sun, 11 May 2025 06:02:02 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: sebastian <at> sebasmonia.com, 78262 <at> debbugs.gnu.org, juri <at> linkov.net
Subject: Re: bug#78262: 30.1; comint-delchar-or-maybe-eof doesn't respect
 delete-active-region
Date: Sun, 11 May 2025 02:01:16 -0400
>> > This assumes that everyone will want the same command bound to C-d
>> > globally to be invoked by C-d in comint-mode.  But is that assumption
>> > necessarily true?
>> 
>> It's hard to handle all possible worlds at the same time, so I think
>> we have to presume the answer is "yes".  If they want something
>> different, they'll have to rebind it explicitly in `comint-mode-map`.
>
> The issue here is whether to support active region (which C-d does).
> Are we sure users of comint want that in respective modes?

The default global binding of `C-d` does not obey `delete-active-region`.

>> -(defun comint-delchar-or-maybe-eof (arg)
>> -  "Delete ARG characters forward or send an EOF to subprocess.
>> +(defun comint-delchar-or-maybe-eof ()
>> +  "Do like the global binding or send an EOF to subprocess.
>
> I think we need to leave ARG in place, at least as an optional
> argument, since otherwise this would be a breaking change.

Fair enough,


        Stefan


diff --git a/lisp/comint.el b/lisp/comint.el
index 188989ff8a4..56e18ac829b 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -2789,14 +2789,14 @@ comint-kill-input
     (if (> (point) (marker-position pmark))
 	(kill-region pmark (point)))))
 
-(defun comint-delchar-or-maybe-eof (arg)
-  "Delete ARG characters forward or send an EOF to subprocess.
+(defun comint-delchar-or-maybe-eof (&optional _arg)
+  "Do like the global binding or send an EOF to subprocess.
 Sends an EOF only if point is at the end of the buffer and there is no input."
-  (interactive "p" comint-mode)
+  (interactive nil comint-mode)
   (let ((proc (get-buffer-process (current-buffer))))
     (if (and (eobp) proc (= (point) (marker-position (process-mark proc))))
 	(comint-send-eof)
-      (delete-char arg))))
+      (call-interactively (lookup-key global-map (this-command-keys))))))
 
 (defun comint-send-eof ()
   "Send an EOF to the current buffer's process."





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78262; Package emacs. (Sun, 11 May 2025 06:54:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: sebastian <at> sebasmonia.com, Eli Zaretskii <eliz <at> gnu.org>,
 78262 <at> debbugs.gnu.org
Subject: Re: bug#78262: 30.1; comint-delchar-or-maybe-eof doesn't respect
 delete-active-region
Date: Sun, 11 May 2025 09:40:30 +0300
forcemerge 78262 73527
thanks

> -(defun comint-delchar-or-maybe-eof (arg)
> -  "Delete ARG characters forward or send an EOF to subprocess.
> +(defun comint-delchar-or-maybe-eof ()
> +  "Do like the global binding or send an EOF to subprocess.
>  Sends an EOF only if point is at the end of the buffer and there is no input."
> -  (interactive "p" comint-mode)
> +  (interactive nil comint-mode)
>    (let ((proc (get-buffer-process (current-buffer))))
>      (if (and (eobp) proc (= (point) (marker-position (process-mark proc))))
>  	(comint-send-eof)
> -      (delete-char arg))))
> +      (call-interactively (lookup-key global-map (this-command-keys))))))

Since this also will fix bug#73527, merging with it.

PS: this still requires

  (put 'comint-delchar-or-maybe-eof 'delete-selection 'supersede)

that could be added later.




Forcibly Merged 73527 78262. Request was from Juri Linkov <juri <at> linkov.net> to control <at> debbugs.gnu.org. (Sun, 11 May 2025 06:54:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78262; Package emacs. (Sun, 11 May 2025 16:35:02 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Juri Linkov <juri <at> linkov.net>
Cc: sebastian <at> sebasmonia.com, Eli Zaretskii <eliz <at> gnu.org>,
 78262 <at> debbugs.gnu.org
Subject: Re: bug#78262: 30.1; comint-delchar-or-maybe-eof doesn't respect
 delete-active-region
Date: Sun, 11 May 2025 12:34:06 -0400
> Since this also will fix bug#73527, merging with it.

Thanks.

> PS: this still requires
>
>   (put 'comint-delchar-or-maybe-eof 'delete-selection 'supersede)
>
> that could be added later.

Hmm... sorry my `delete-selection`-fu is rusty, what would this
do/fix, again?


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78262; Package emacs. (Sun, 11 May 2025 18:15:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: sebastian <at> sebasmonia.com, Eli Zaretskii <eliz <at> gnu.org>,
 78262 <at> debbugs.gnu.org
Subject: Re: bug#78262: 30.1; comint-delchar-or-maybe-eof doesn't respect
 delete-active-region
Date: Sun, 11 May 2025 20:53:17 +0300
>> PS: this still requires
>>
>>   (put 'comint-delchar-or-maybe-eof 'delete-selection 'supersede)
>>
>> that could be added later.
>
> Hmm... sorry my `delete-selection`-fu is rusty, what would this
> do/fix, again?

This is a copy from delsel.el

  ;; delete-backward-char and delete-forward-char already delete the selection by
  ;; default, but not delete-char.
  (put 'delete-char 'delete-selection 'supersede)

that will do the same for 'comint-delchar-or-maybe-eof'
that uses 'delete-char' by default.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78262; Package emacs. (Sun, 11 May 2025 19:41:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: sebastian <at> sebasmonia.com, monnier <at> iro.umontreal.ca, 78262 <at> debbugs.gnu.org
Subject: Re: bug#78262: 30.1; comint-delchar-or-maybe-eof doesn't respect
 delete-active-region
Date: Sun, 11 May 2025 22:40:33 +0300
> From: Juri Linkov <juri <at> linkov.net>
> Cc: Eli Zaretskii <eliz <at> gnu.org>,  sebastian <at> sebasmonia.com,
>   78262 <at> debbugs.gnu.org
> Date: Sun, 11 May 2025 20:53:17 +0300
> 
> >> PS: this still requires
> >>
> >>   (put 'comint-delchar-or-maybe-eof 'delete-selection 'supersede)
> >>
> >> that could be added later.
> >
> > Hmm... sorry my `delete-selection`-fu is rusty, what would this
> > do/fix, again?
> 
> This is a copy from delsel.el
> 
>   ;; delete-backward-char and delete-forward-char already delete the selection by
>   ;; default, but not delete-char.
>   (put 'delete-char 'delete-selection 'supersede)
> 
> that will do the same for 'comint-delchar-or-maybe-eof'
> that uses 'delete-char' by default.

And that's why I questioned the wisdom of doing this.  Deleting the
entire active region is a dangerous operation, and users who don't
expect that will be extremely annoyed, I'm afraid.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78262; Package emacs. (Mon, 12 May 2025 04:29:02 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Juri Linkov <juri <at> linkov.net>
Cc: sebastian <at> sebasmonia.com, Eli Zaretskii <eliz <at> gnu.org>,
 78262 <at> debbugs.gnu.org
Subject: Re: bug#78262: 30.1; comint-delchar-or-maybe-eof doesn't respect
 delete-active-region
Date: Mon, 12 May 2025 00:28:00 -0400
>>> PS: this still requires
>>>
>>>   (put 'comint-delchar-or-maybe-eof 'delete-selection 'supersede)
>>>
>>> that could be added later.
>>
>> Hmm... sorry my `delete-selection`-fu is rusty, what would this
>> do/fix, again?
>
> This is a copy from delsel.el
>
>   ;; delete-backward-char and delete-forward-char already delete the selection by
>   ;; default, but not delete-char.
>   (put 'delete-char 'delete-selection 'supersede)
>
> that will do the same for 'comint-delchar-or-maybe-eof'
> that uses 'delete-char' by default.

Ah.  I consider this part of delsel.el to be obsolete (made obsolete
back in Emacs-24 by the `delete-active-region` variable).
If `delsel.el` wants to make `C-d` delete the active region, it should
preferably do it by remapping `delete-char` to `delete-forward-char`, IMO.


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78262; Package emacs. (Mon, 12 May 2025 17:54:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: sebastian <at> sebasmonia.com, Eli Zaretskii <eliz <at> gnu.org>,
 78262 <at> debbugs.gnu.org
Subject: Re: bug#78262: 30.1; comint-delchar-or-maybe-eof doesn't respect
 delete-active-region
Date: Mon, 12 May 2025 20:46:35 +0300
>>>> PS: this still requires
>>>>
>>>>   (put 'comint-delchar-or-maybe-eof 'delete-selection 'supersede)
>>>>
>>>> that could be added later.
>>>
>>> Hmm... sorry my `delete-selection`-fu is rusty, what would this
>>> do/fix, again?
>>
>> This is a copy from delsel.el
>>
>>   ;; delete-backward-char and delete-forward-char already delete the selection by
>>   ;; default, but not delete-char.
>>   (put 'delete-char 'delete-selection 'supersede)
>>
>> that will do the same for 'comint-delchar-or-maybe-eof'
>> that uses 'delete-char' by default.
>
> Ah.  I consider this part of delsel.el to be obsolete (made obsolete
> back in Emacs-24 by the `delete-active-region` variable).

It seems the primary reason people are rebinding `C-d` from `delete-char`
to `delete-forward-char` is to be able to delete the region with it.

> If `delsel.el` wants to make `C-d` delete the active region, it should
> preferably do it by remapping `delete-char` to `delete-forward-char`, IMO.

Not sure if `delsel.el` should rebind the global keybindings.

Anyway, your latest patch is sufficient for closing this bug report.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78262; Package emacs. (Mon, 12 May 2025 19:35:02 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Juri Linkov <juri <at> linkov.net>
Cc: sebastian <at> sebasmonia.com, Eli Zaretskii <eliz <at> gnu.org>,
 78262 <at> debbugs.gnu.org
Subject: Re: bug#78262: 30.1; comint-delchar-or-maybe-eof doesn't respect
 delete-active-region
Date: Mon, 12 May 2025 15:34:47 -0400
>> Ah.  I consider this part of delsel.el to be obsolete (made obsolete
>> back in Emacs-24 by the `delete-active-region` variable).
> It seems the primary reason people are rebinding `C-d` from `delete-char`
> to `delete-forward-char` is to be able to delete the region with it.

Yeah, I can't see what other reason there would be.

>> If `delsel.el` wants to make `C-d` delete the active region, it should
>> preferably do it by remapping `delete-char` to `delete-forward-char`, IMO.
> Not sure if `delsel.el` should rebind the global keybindings.

That would be to preserve its historical behavior w.r.t `C-d` while
making use of the "new" infrastructure.
I'm also not sure if that's important to do.
[ Also, I really meant "remap", not "rebind": it can be done easily and
  non-destructively in a minor mode map, contrary to rebinding.  ]

The way I see it, the only reason why we still want/need `delsel.el` is
to implement the "delete active region upon insertion", i.e. things
like:

    (put 'self-insert-command 'delete-selection #'delete-selection-uses-region-p)
    (put 'yank 'delete-selection 'yank)

> Anyway, your latest patch is sufficient for closing this bug report.

Indeed, the delsel part is orthogonal.  I pushed it (fixed to obey
command remapping), thanks.


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78262; Package emacs. (Tue, 13 May 2025 11:58:06 GMT) Full text and rfc822 format available.

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

From: Sebastián Monía <sebastian <at> sebasmonia.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 78262 <at> debbugs.gnu.org,
 Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#78262: 30.1; comint-delchar-or-maybe-eof doesn't respect
 delete-active-region
Date: Tue, 13 May 2025 07:57:37 -0400
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
>> Anyway, your latest patch is sufficient for closing this bug report.
>
> Indeed, the delsel part is orthogonal.  I pushed it (fixed to obey
> command remapping), thanks.

Thanks everyone!
I happened to be AFK for a few days and now I see this was fixed.

-- 
Sebastián Monía
https://site.sebasmonia.com/




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78262; Package emacs. (Wed, 14 May 2025 06:12:01 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Sebastián Monía <sebastian <at> sebasmonia.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, Stefan Monnier <monnier <at> iro.umontreal.ca>,
 78262 <at> debbugs.gnu.org
Subject: Re: bug#78262: 30.1; comint-delchar-or-maybe-eof doesn't respect
 delete-active-region
Date: Wed, 14 May 2025 09:06:41 +0300
fixed 78262 31.0.50
close 78262 31.0.50
thanks

>>> Anyway, your latest patch is sufficient for closing this bug report.
>>
>> Indeed, the delsel part is orthogonal.  I pushed it (fixed to obey
>> command remapping), thanks.
>
> Thanks everyone!
> I happened to be AFK for a few days and now I see this was fixed.

So now closing as fixed.




bug Marked as fixed in versions 31.0.50. Request was from Juri Linkov <juri <at> linkov.net> to control <at> debbugs.gnu.org. (Wed, 14 May 2025 06:12:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 31.0.50, send any further explanations to 78262 <at> debbugs.gnu.org and Sebastián Monía <sebastian <at> sebasmonia.com> Request was from Juri Linkov <juri <at> linkov.net> to control <at> debbugs.gnu.org. (Wed, 14 May 2025 06:12:02 GMT) Full text and rfc822 format available.

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

This bug report was last modified 6 days ago.

Previous Next


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