unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Lars Ingebrigtsen <larsi@gnus.org>
To: a.c.kalker@gmail.com
Cc: 22917@debbugs.gnu.org
Subject: bug#22917: 24.5; comint-kill-region doesn't work when both cua-mode and comint-prompt-read-only enabled
Date: Thu, 03 Dec 2020 10:41:50 +0100	[thread overview]
Message-ID: <87r1o7w7j5.fsf@gnus.org> (raw)
In-Reply-To: <87si05j72a.fsf@gmail.com> (a. c. kalker's message of "Sat, 05 Mar 2016 16:08:45 +0100")

a.c.kalker@gmail.com writes:

> Steps to reproduce:
>
> 1. Create file 'repro.el' with contents:
>
> ;; Test deleting region with read-only prompts while cua-mode is active
> (setq comint-prompt-read-only t)
> (cua-mode 1)
> ;; Copied verbatim from 'comint-prompt-read-only' docstring
> (add-hook 'comint-mode-hook
> 	  (lambda ()
> 	    (define-key comint-mode-map [remap kill-region] 'comint-kill-region)
> 	    (define-key comint-mode-map [remap kill-whole-line]
> 	      'comint-kill-whole-line)))

[...]

> 4. Hit C-x or <delete> (only when cua-mode is active) or <S-delete> or C-w
>
> 5. Retry steps 3 and 4 after disabling cua-mode with M-x cua-mode RET
>
> Expected results:
> All these keystrokes (where applicable) should delete the region,
> including any interspersed prompts.
>
> Actual results:
> With cua-mode enabled:
> 4. C-x produces the error: "Text is read-only: #<buffer *shell*>" and
> nothing is deleted.
>    <delete> produces the error: "Text is read-only" and nothing is
>    deleted.
>    <S-delete> produces the error: "Text is read-only: #<buffer *shell*>" and
> nothing is deleted.
>    C-w  produces the error: "Text is read-only: #<buffer *shell*>" and
> nothing is deleted.
> With cua-mode disabled:
> 4. <S-delete> deletes the region, without error.
>    C-w deletes the region, without error.

(This bug report unfortunately got no response at the time.)

I can reproduce the behaviour, but I'm not sure it's a bug.

By default, all these killing commands refuse to kill read-only text.
However, comint provides a variation (`comint-kill-region') that ignores
whether there's read-only text or not, because that's sometimes
convenient, and has instructions on how to rebind kill-region.

However, cua-mode binds `C-w' to `cua-cut-region', so to get that
working, you'd also have to say

(define-key comint-mode-map [remap cua-cut-region] 'comint-kill-region)

or something of the kind.  Of course, cua-cut-region doesn't work quite
the same as `kill-region', so it's not quite the same, but if you want
this to work for the kill function you're using, then rebind the command
to something that does

(defun my-cut ()
  (interactive)
  (let ((inhibit-read-only t))
    (cua-cut-region)))

or something like that.

I don't think this is something that would be natural for either comint
or cua by themselves to work around -- if you have read-only text in the
buffer, then that's supposed to bug out if you kill it, and if you want
something else to happen, then it's more natural for the user that wants
that to do something like the above, I think?

So I'm closing this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





      reply	other threads:[~2020-12-03  9:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-05 15:08 bug#22917: 24.5; comint-kill-region doesn't work when both cua-mode and comint-prompt-read-only enabled a.c.kalker
2020-12-03  9:41 ` Lars Ingebrigtsen [this message]

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=87r1o7w7j5.fsf@gnus.org \
    --to=larsi@gnus.org \
    --cc=22917@debbugs.gnu.org \
    --cc=a.c.kalker@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).