unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#22917: 24.5; comint-kill-region doesn't work when both cua-mode and comint-prompt-read-only enabled
@ 2016-03-05 15:08 a.c.kalker
  2020-12-03  9:41 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 2+ messages in thread
From: a.c.kalker @ 2016-03-05 15:08 UTC (permalink / raw)
  To: 22917


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)))

2. Run Emacs and start a shell
$ emacs -Q -l repro.el
M-x shell RET

3. In the shell, execute a command, then select a region comprising the
command's output and one or more prompts, like the following (region
shown delimited by '[' and ']'):
[miki@miki-desktop ~]$ date
Sat Mar  5 15:49:31 CET 2016
[miki@miki-desktop ~]$ [uname -a
Linux miki-desktop 4.4.3-1-ARCH #1 SMP PREEMPT Fri Feb 26 15:09:29 CET 2016 x86_64 GNU/Linux
[miki@miki-desktop ~]$ ]

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.



In GNU Emacs 24.5.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.16.6)
 of 2015-09-10 on foutrelis
Windowing system distributor `The X.Org Foundation', version 11.0.11801000
Configured using:
 `configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
 --localstatedir=/var --with-x-toolkit=gtk3 --with-xft
 'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong
 --param=ssp-buffer-size=4' CPPFLAGS=-D_FORTIFY_SOURCE=2
 LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro'

Important settings:
  value of $LC_MESSAGES: en_US.utf8
  value of $LANG: en_US.utf8
  locale-coding-system: utf-8-unix

Major mode: Fundamental

Minor modes in effect:
  yas-global-mode: t
  delete-selection-mode: t
  winner-mode: t
  show-paren-mode: t
  icomplete-mode: t
  global-whitespace-mode: t
  cua-mode: t
  multi-web-global-mode: t
  global-flycheck-mode: t
  global-company-mode: t
  override-global-mode: t
  msb-mode: t
  tooltip-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t
  view-mode: t

Recent messages:
[yas] Loading snippet files from /home/miki/.emacs.d/elpa/yasnippet-20160226.1359/snippets/emacs-lisp-mode
[yas] Loading for `prog-mode', just-in-time: (lambda nil (yas--load-directory-1 (quote /home/miki/.emacs.d/elpa/yasnippet-20160226.1359/snippets/prog-mode) (quote prog-mode)))!
[yas] Loading snippet files from /home/miki/.emacs.d/elpa/yasnippet-20160226.1359/snippets/prog-mode
Loading /home/miki/.emacs.d/elpa/yasnippet-20160226.1359/snippets/prog-mode/.yas-setup...done
For information about GNU Emacs and the GNU system, type C-h C-a.
View mode: type C-h for help, h for commands, q to quit.
Making completion list...
Contacting host: debbugs.gnu.org:80 [3 times]
Opening nndoc server on /tmp/gnus-temp-group-11073W9u-ephemeral...done
Beginning of buffer
gnus-summary-next-unread-article: No buffer named *Group* [2 times]

Load-path shadows:
/home/miki/.emacs.d/elpa/helm-20160304.713/helm-multi-match hides /home/miki/.emacs.d/elpa/helm-core-20160303.1321/helm-multi-match
/usr/share/emacs/site-lisp/SuperCollider/tree-widget hides /usr/share/emacs/24.5/lisp/tree-widget

Features:
(shadow emacsbug sendmail parse-time sort smiley ansi-color gnus-cite
mail-extr qp gnus-async gnus-bcklg gnus-agent gnus-srvr gnus-score
score-mode nnvirtual nntp gnus-ml gnus-msg disp-table nndoc gnus-cache
url-handlers gnus-dup gnus-art mm-uu mml2015 mm-view mml-smime smime dig
gnus-sum nnoo gnus-group gnus-undo nnmail mail-source gnus-start
gnus-spec gnus-int gnus-range gnus-win gnus gnus-ems nnheader wid-edit
async mm-archive message idna format-spec rfc822 mml mml-sec mailabbrev
gmm-utils mailheader mail-utils network-stream starttls url-cache
debbugs-gnu add-log debbugs soap-client warnings xml mule-util view
eldoc hideshow adjust-parens elisp-slime-nav hl-sexp .emacs server
yasnippet cl imenu company-oddmuse company-keywords company-etags etags
company-gtags company-dabbrev-code company-dabbrev company-files
company-capf company-cmake company-xcode company-clang company-semantic
company-eclim company-template company-css company-nxml company-bbdb
company-irony irony-completion irony-snippet irony company-tern s
ucs-normalize dash-functional finder-inf tern url-http tls url-auth
url-gw url url-proxy url-privacy url-expand url-methods url-history
url-cookie url-domsuf url-util mailcap wheatgrass-theme delsel winner
ring paren icomplete whitespace cua-base cus-start cus-load shackle
multi-web-mode flycheck find-func help-mode rx subr-x seq dash company
cl-macs gv pcase quelpa-use-package advice quelpa package-build
mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045
ietf-drums json lisp-mnt use-package diminish bind-key easy-mmode
slime-autoloads info easymenu package epg-config ffap thingatpt
url-parse auth-source eieio byte-opt bytecomp byte-compile cl-extra
cconv eieio-core gnus-util mm-util help-fns mail-prsvr password-cache
url-vars edmacro kmacro cl-loaddefs cl-lib windmove msb time-date
tooltip electric uniquify ediff-hook vc-hooks lisp-float-type mwheel
x-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list
newcomment lisp-mode prog-mode register page menu-bar rfn-eshadow timer
select scroll-bar mouse jit-lock font-lock syntax facemenu font-core
frame cham georgian utf-8-lang misc-lang vietnamese tibetan thai
tai-viet lao korean japanese hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese case-table epa-hook jka-cmpr-hook help
simple abbrev minibuffer nadvice loaddefs button faces cus-face macroexp
files text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote make-network-process
dbusbind gfilenotify dynamic-setting system-font-setting
font-render-setting move-toolbar gtk x-toolkit x multi-tty emacs)

Memory information:
((conses 16 419412 21695)
 (symbols 48 39756 1)
 (miscs 40 290 448)
 (strings 32 82726 13188)
 (string-bytes 1 2585001)
 (vectors 16 54491)
 (vector-slots 8 946354 13153)
 (floats 8 621 453)
 (intervals 56 368 79)
 (buffers 960 23)
 (heap 1024 41393 1828))





^ permalink raw reply	[flat|nested] 2+ messages in thread

* bug#22917: 24.5; comint-kill-region doesn't work when both cua-mode and comint-prompt-read-only enabled
  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
  0 siblings, 0 replies; 2+ messages in thread
From: Lars Ingebrigtsen @ 2020-12-03  9:41 UTC (permalink / raw)
  To: a.c.kalker; +Cc: 22917

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





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-12-03  9:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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

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).