Subject: Re: bug#78262: 30.1; comint-delchar-or-maybe-eof doesn't respect delete-active-region

From: Eli Zaretskii <[email-masked]>
Date: Thu, 08 May 2025 13:36:12 +0300

> From: Sebastián Monía
>  <[email-masked]>
> 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?