From: Juri Linkov <juri@linkov.net>
To: Augusto Stoffel <arstoffel@gmail.com>
Cc: 73527@debbugs.gnu.org
Subject: bug#73527: 30.0.90; Comint rebinds C-d
Date: Sun, 29 Sep 2024 19:08:03 +0300 [thread overview]
Message-ID: <86cykmla4s.fsf@mail.linkov.net> (raw)
In-Reply-To: <87y13cf3zu.fsf@gmail.com> (Augusto Stoffel's message of "Sat, 28 Sep 2024 12:48:37 +0200")
> comint-mode rebinds C-d (to `comint-delchar-or-maybe-eof') in a way that
> is supposed to fall back to the default C-d behavior unless point is on
> a blank input line.
>
> If the user rebinds C-d in the global map, e.g. to something sensible
> such as `delete-forward-char', this preference is overridden.
>
> Should a menu-item with :filter property be used instead in
> comint-mode-map?
It would be nice to make such filter customizable.
For example, currently I have to use:
(define-key shell-mode-map "\C-d" 'my-shell-c-d)
(defun my-shell-c-d (&optional arg)
(interactive "p")
(cond ((and (eobp)
(save-excursion
(let ((inhibit-field-text-motion t))
(goto-char (line-beginning-position))
(looking-at-p "^iex.*>\s*$"))))
(let ((process (get-buffer-process (current-buffer))))
(process-send-string process ":init.stop()\n")))
((and (eobp)
(save-excursion
(let ((inhibit-field-text-motion t))
(goto-char (line-beginning-position))
(looking-at-p "^[a-z:]*cljs\\..*=>\s*$"))))
(let ((process (get-buffer-process (current-buffer))))
(process-send-string process ":cljs/quit\n")))
(t
(comint-delchar-or-maybe-eof arg))))
But with a filter all these cases could be moved to the filter predicate,
along with its default value extracted from 'comint-delchar-or-maybe-eof':
(if (and (eobp) proc (= (point) (marker-position (process-mark proc))))
(comint-send-eof)
(delete-char arg))
Then rebinding `C-d' from `delete-char' to `delete-forward-char'
will be handled automatically.
Also for the users of `delete-selection-mode' this will remove
the need to add more settings:
(put 'comint-delchar-or-maybe-eof 'delete-selection 'supersede)
(put 'my-shell-c-d 'delete-selection 'supersede)
according to this part of 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)
next prev parent reply other threads:[~2024-09-29 16:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-28 10:48 bug#73527: 30.0.90; Comint rebinds C-d Augusto Stoffel
2024-09-29 16:08 ` Juri Linkov [this message]
2024-10-05 14:32 ` Augusto Stoffel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86cykmla4s.fsf@mail.linkov.net \
--to=juri@linkov.net \
--cc=73527@debbugs.gnu.org \
--cc=arstoffel@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).