unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#51788: cua + ansi-term hangs
@ 2021-11-12 11:22 Samuel Muñoz Hidalgo
  2022-09-20 13:22 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 2+ messages in thread
From: Samuel Muñoz Hidalgo @ 2021-11-12 11:22 UTC (permalink / raw)
  To: 51788

[-- Attachment #1: Type: text/plain, Size: 2365 bytes --]

Hello,

I've tried to implement a small utility function in elisp and I end up with
emacs hanged whenever certain conditions are met.

The utility has to do with sending the selected text to a term buffer and
when in the term buffer if C-c  (or C-x) is pressed, it hangs.

I 've traced the behavior and my guess it that is has to do with cua-mode.


EMACS VERSION:
I've been able to replicate the behaviour in :
- GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.20, cairo
version 1.16.0)
- GNU Emacs 26.3 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.14) of
2020-03-26, modified by Debian


CONTEXT:

1- Open an empty emacs instance:
```
/usr/bin/emacs -q
```

2- Paste this code in a buffer (*scratch*)
```
(cua-mode t)

(defun terminal-send-selection()
  (interactive)
  (call-interactively #'kill-ring-save)
  (ansi-term "/usr/bin/bash" "test")
  (term-paste)
  )

(global-set-key [f2] 'terminal-send-selection)
```

3- Eval the buffer with the code `eval-buffer`


CASE 1 (OK):
1- Select a text in a buffer and 'M-x' `terminal-send-selection`. It opens
a terminal with the selected text pasted in it.
3- Type C-c, then prefix key is activated.
4- Type C-c again and works as expected, the pasted text is executed in
bash.

CASE 2 (PROBLEM):
1- Select a text in a buffer and use the keybind F2 instead of calling the
function manually. It opens a terminal with the selected word pasted in it.
3- Type C-c or (C-x) and emacs freezes with a 100% CPU usage in a single
core.
4- Then on a external shell:
```
kill -USR2 `pidof emacs`
```
And I get in the minibuffer.
```
Error in pre-command-hook (term-set-goto-process-mark): (quit)
```
Emacs is still hanged.
5- Repeat the command in the external shell.
```
kill -USR2 `pidof emacs`
```
And I get in *Backtrace*
```
Debugger entered--Lisp error: (quit)
```
The editor is not hanged anymore. But the behaviour is undesired.


CASE 3 (OK):
1- Don't activate cua-mode. Redo al the process but without copying the
line`(cua-mode t)`.
2- Then case 2 work as expected.


OTHER APPROACHES:
Instead of using the function "term-paste" I have also tried with.

1 - Using the function "comint-send-string".
2 - Pasting directly the test in the ansi-term buffer.

With the same results.


Why does the CASE 2 happens?
As the code is so simple I think this has to be a bug. Any help or insights
are welcome.

[-- Attachment #2: Type: text/html, Size: 2717 bytes --]

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

* bug#51788: cua + ansi-term hangs
  2021-11-12 11:22 bug#51788: cua + ansi-term hangs Samuel Muñoz Hidalgo
@ 2022-09-20 13:22 ` Lars Ingebrigtsen
  0 siblings, 0 replies; 2+ messages in thread
From: Lars Ingebrigtsen @ 2022-09-20 13:22 UTC (permalink / raw)
  To: Samuel Muñoz Hidalgo; +Cc: 51788

Samuel Muñoz Hidalgo <samuel.mh@gmail.com> writes:

> 1- Select a text in a buffer and use the keybind F2 instead of calling the function
> manually. It opens a terminal with the selected word pasted in it.
> 3- Type C-c or (C-x) and emacs freezes with a 100% CPU usage in a single core.

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

I can reproduce this in Emacs 29.  Setting debug-on-quit and hitting
`C-g' give me the following backtrace:

Debugger entered--Lisp error: (quit)
  timer--activate([t 25385 48685 328606 nil cua--prefix-override-timeout nil nil 450000 nil] nil nil nil)
  timer-activate([t 25385 48685 328606 nil cua--prefix-override-timeout nil nil 450000 nil])
  run-at-time(0.2 nil cua--prefix-override-timeout)
  apply(run-at-time 0.2 nil cua--prefix-override-timeout nil)
  run-with-timer(0.2 nil cua--prefix-override-timeout)
  cua--prefix-override-replay(0)
  cua-copy-handler()
  funcall-interactively(cua-copy-handler)
  call-interactively(cua-copy-handler nil nil)

I'm wholly unfamiliar with cua-mode, though.  Does anybody else know
what could be happening here?





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

end of thread, other threads:[~2022-09-20 13:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-12 11:22 bug#51788: cua + ansi-term hangs Samuel Muñoz Hidalgo
2022-09-20 13:22 ` 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).