GNU bug report logs - #22917
24.5; comint-kill-region doesn't work when both cua-mode and comint-prompt-read-only enabled

Previous Next

Package: emacs;

Reported by: a.c.kalker <at> gmail.com

Date: Sat, 5 Mar 2016 15:10:02 UTC

Severity: normal

Tags: wontfix

Found in version 24.5

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: a.c.kalker <at> gmail.com
Cc: 22917 <at> debbugs.gnu.org
Subject: Re: 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
a.c.kalker <at> 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




This bug report was last modified 4 years and 167 days ago.

Previous Next


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