riscy / shx-for-emacs

An Emacs shell-mode (and comint-mode) extension that enables displaying small plots and graphics and lets users write shell commands in Emacs Lisp.
GNU General Public License v3.0
218 stars 10 forks source link

Ctrl-RET doesn't copy the command text; it tries to find a file (likely not a bug in shx) #36

Open epa opened 2 months ago

epa commented 2 months ago

Hi, I am trying out shx (cloned from gitlab today) with emacs 28.2. If I move point to an earlier command and press C-RET, I expected the text of that command to be copied to the current prompt. But instead I get "Find file or URL: ~/" in the minibuffer. To reproduce

% emacs -q In the *scratch* buffer run

(add-to-list 'load-path "~/git_working/shx-for-emacs/")
(require 'shx)

Then M-x shx to start a new shell buffer. Wait for the prompt to appear and enter echo hello followed by RET. The command runs. Then C-p a couple of times to move up to the previous prompt, and C-RET. But instead of copying the echo hello text to the current prompt to run again, it thinks I want to open a file.

The buffer does have shx active, as shown by (Shell:run shx) at the bottom.

I thought maybe it was the prompt printed by the shell that wasn't being recognized, so I tried setting the PS1 environment variable to a plain %, but that didn't help. The shell buffer is fontifying the prompt text differently to the commands I entered and the output of those commands.

You know, I think I may have found the problem. But I'll post this bug report just in case, as a helper for anyone else hitting the same issue. If I do C-h k to describe the key sequence, then press C-RET, it tells me

RET runs the command shx-send-input-or-open-thing

That's RET, not C-RET, so somehow the Ctrl key is not getting through. This connecting to a Linux box from a Windows desktop with PuTTY.

epa commented 2 months ago

I added this to shx.el

(define-key keymap (kbd "M-RET") #'shx-send-input-or-copy-line)

Then I can move up to the earlier line and hit M-RET (on my PC keyboard, Alt-Enter) to copy. But it ends up copying the whole line, including the shell prompt, not just the text that was entered. Would you like me to file a separate issue for that?

riscy commented 2 months ago

Thank you so much - I've had issues with different terminals as well, but hadn't gotten a chance to test with PuTTY.

No need to open a separate issue regarding copying the whole line; I'll use this issue to track that too. I've been having issues with it as well in certain situations (e.g. inferior python mode) so it's definitely itching me too.