将文本拖入 Emacs 中运行的终端

发布于 2024-09-04 06:55:09 字数 348 浏览 1 评论 0原文

我无法将文本拉入 Emacs 中运行的终端。

这是我的过程:

我从一个缓冲区中删除了字符串“date”,并将其拉入另一个缓冲区中的终端,然后按回车键。

终端的行为就像我什么也没输入一样。它只是返回提示。

我使用的是 OS X 10.5.8 和 Emacs 23.1。我已经在 Aquamacs、Carbon Emacs 以及 http://emacsformacosx.com/ 的版本上尝试过此过程。即使在我的 .emacs 文件为空的默认配置中,它们也都表现出这种奇怪的行为。可能是什么原因造成的?

I am unable to yank text into a terminal running in Emacs.

This is my procedure:

I killed the string "date" from one buffer and yanked it into the terminal in another buffer and hit return.

The terminal behaves as if I typed nothing. It just returns the prompt back.

I am using OS X 10.5.8 and Emacs 23.1. I have tried this procedure on Aquamacs, Carbon Emacs, and the release from http://emacsformacosx.com/. They all show this weird behaviour even in their default configurations with my .emacs file empty. What could possibly be causing this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

§对你不离不弃 2024-09-11 06:55:09

我认为“在终端中”是指您正在运行 Emacs 的内置终端模拟器。通常,终端仿真器将大多数键与键入的内容完全相同地传输到 shell 进程。在终端缓冲区中键入 Cc Cj 将其置于普通 Emacs 键绑定可用的状态。您将看到模式行从 (Term: char run) 更改为 (Term: line run)

附录:

在不离开字符模式的情况下提取文本有点棘手;然而,相关的函数是term-paste(不是yank,它只是将文本插入终端缓冲区而不将其发送到下级进程)。 term-paste 会立即将最近的终止发送到下级进程,但不提供您可能习惯的花哨的 yank 功能(例如 My 来循环)先前击杀)。您可以将 term-paste 作为扩展命令运行:Cc Mx term-paste RET

最简单的解决方案可能是在需要粘贴内容时暂时进入行模式 (Cc Cj),然后立即返回字符模式 (Cc Ck)。或者更简单,只需始终保持在线模式即可。当我有一个终端登录到 Oracle SQL*Plus 会话时,我经常这样做。我很少注意到其中的差异,但我获得了各种方便的 Emacs 功能,例如能够输入 Mp 来循环执行先前输入的长 SQL 语句。

我本以为你总是可以像这样以线路模式开始:

(add-hook 'term-mode-hook 'term-line-mode)

...但它对我不起作用。不知道为什么。

By "in a terminal" I assume you mean you're running Emacs's built-in terminal emulator. Ordinarily, the terminal emulator transmits most keys exactly as typed to the shell process. Type C-c C-j in the terminal buffer to put it into a state where ordinary Emacs key bindings are available. You'll see the mode line change from (Term: char run) to (Term: line run).

Addendum:

Yanking text without leaving char mode is a little tricky; the relevant function, however, is term-paste (not yank, which merely inserts the text into the terminal buffer without sending it to the inferior process). term-paste will immediately send the most recent kill to the inferior process, but doesn't provide the fancy yank functionality you're probably used to (like M-y to cycle through prior kills). You could run term-paste as an extended command: C-c M-x term-paste RET.

Probably the easiest solution is just to temporarily go into line mode (C-c C-j) when you have something to paste, and then immediately go back into char mode (C-c C-k). Or even easier, just stay in line mode all the time. I often do this when I have a terminal logged into an Oracle SQL*Plus session. I rarely notice the difference, but I get all sorts of convenient Emacs functionality, like being able to type M-p to cycle through a long, previously-typed SQL statement.

I would have assumed that you could always start off in line mode like this:

(add-hook 'term-mode-hook 'term-line-mode)

...but it doesn't work for me. Don't know why.

肥爪爪 2024-09-11 06:55:09

在终端运行的缓冲区中,使用 Cc Cj 将终端置于行模式。要粘贴文本,请立即按 S-Insert(即 Shift-Insert)。如果您需要终端随后返回到字符模式,请使用Cc Ck

In the buffer with the terminal running, put the terminal into line mode with C-c C-j. To paste in your text, now press S-Insert (that's Shift-Insert). If you need the terminal to go back to char mode afterwards, it's C-c C-k.

只是偏爱你 2024-09-11 06:55:09

当所有其他方法都失败时,我只需突出显示文本并单击“编辑”->“复制”,然后右键单击另一个 emacs 缓冲区并单击“粘贴”。

When all else fails I just highlight the text and click Edit->Copy then right click in the other emacs buffer and click paste.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文