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

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