all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Samuel Muñoz Hidalgo" <samuel.mh@gmail.com>
To: 51788@debbugs.gnu.org
Subject: bug#51788: cua + ansi-term hangs
Date: Fri, 12 Nov 2021 12:22:18 +0100	[thread overview]
Message-ID: <CA+kUYON-PNyQ1aTxR1=gRU_WTcPf41-eWHS-Cd3FXtK6SLtVpA@mail.gmail.com> (raw)

[-- 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 --]

             reply	other threads:[~2021-11-12 11:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-12 11:22 Samuel Muñoz Hidalgo [this message]
2022-09-20 13:22 ` bug#51788: cua + ansi-term hangs Lars Ingebrigtsen

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CA+kUYON-PNyQ1aTxR1=gRU_WTcPf41-eWHS-Cd3FXtK6SLtVpA@mail.gmail.com' \
    --to=samuel.mh@gmail.com \
    --cc=51788@debbugs.gnu.org \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.