emacs终端模式:如何有效地复制和粘贴 [英] emacs terminal mode: how to copy and paste efficiently
问题描述
我很难使这个emacs -nw在终端模式(emacs -nw)下有效地工作。
一些设置信息:
工作服务器通过SSH连接,并且emacs在服务器上运行。通常,我使用SSH和 emacs -nw进行连接以处理文件。
I'm having a hard time making this emacs -nw work effectively under the terminal mode (emacs -nw). Some setup information: The working server is connected via SSH, and emacs is running on the server. Usually I'm connecting using SSH and "emacs -nw" to work on my files.
从以下位置获取emacs配置: https://hugoheden.wordpress.com/2009/03/08/copypaste-with-emacs-in-terminal/
The emacs config is picked up from: https://hugoheden.wordpress.com/2009/03/08/copypaste-with-emacs-in-terminal/
;; make mouse selection to be emacs region marking
(require 'mouse)
(xterm-mouse-mode t)
(defun track-mouse (e))
(setq mouse-sel-mode t)
;; enable clipboard in emacs
(setq x-select-enable-clipboard t)
;; enable copy/paste between emacs and other apps (terminal version of emacs)
(unless window-system
(when (getenv "DISPLAY")
;; Callback for when user cuts
(defun xsel-cut-function (text &optional push)
;; Insert text to temp-buffer, and "send" content to xsel stdin
(with-temp-buffer
(insert text)
;; I prefer using the "clipboard" selection (the one the
;; typically is used by c-c/c-v) before the primary selection
;; (that uses mouse-select/middle-button-click)
(call-process-region (point-min) (point-max) "xsel" nil 0 nil "--clipboard" "--input")))
;; Call back for when user pastes
(defun xsel-paste-function()
;; Find out what is current selection by xsel. If it is different
;; from the top of the kill-ring (car kill-ring), then return
;; it. Else, nil is returned, so whatever is in the top of the
;; kill-ring will be used.
(let ((xsel-output (shell-command-to-string "xsel --clipboard --output")))
(unless (string= (car kill-ring) xsel-output)
xsel-output )))
;; Attach callbacks to hooks
(setq interprogram-cut-function 'xsel-cut-function)
(setq interprogram-paste-function 'xsel-paste-function)
;; Idea from
;; http://shreevatsa.wordpress.com/2006/10/22/emacs-copypaste-and-x/
;; http://www.mail-archive.com/help-gnu-emacs@gnu.org/msg03577.html
))
拥有的原因:
(require 'mouse)
(xterm-mouse-mode t)
(defun track-mouse (e))
(setq mouse-sel-mode t)
用于在文本上启用鼠标选择,以便突出显示文本区域,就像 Cx SPC标记该区域一样。然后,我可以使用 M-x w进行复制,并使用 C-x y在emacs中以及emacs与其他应用程序之间粘贴文本。
is to enable mouse selection over text such that the text region is highlighted just as "C-x SPC" marking the region. Then I can use "M-x w" to copy and "C-x y" to paste text within emacs and between emacs and other apps.
除了与X相关的任何操作都非常慢之外,其他所有看起来都很完美!我与远程服务器的连接很流畅-延迟通常在100毫秒以下。但是要使用 C-x k杀死一行文本,大约需要5秒钟!要粘贴它,还需要5秒钟!
All look perfect except that any operations related to X are REALLY SLOW! My connection to the remote server is smooth -- the latency is usually under 100ms. But to kill one line of text using "C-x k", it takes ~5 seconds! To paste it, it takes another 5 seconds!
有时候复制/粘贴非常频繁,这确实很烦人。我认为这与X服务器消息相关,但不确定是否有解决此问题的好方法。
When copy/paste is frequent sometimes, this becomes really annoying. I think this is related to the X sever messaging, but not sure if there is good way to fix this.
有什么想法吗?
谢谢!
Any ideas? Thanks!
推荐答案
这本身并不是理想的解决方案,但我想出了一种感觉更好的方法比前一个。
This is not an ideal solution per se, but i figured out a way that I feel better than the previous one.
这个想法是要消除X引起的严重延迟问题,即仅保留以下内容:
The idea is to get rid of X which causes heavy latency issues, i.e. keep only the following:
;; enable clipboard in emacs
(setq x-select-enable-clipboard t)
结果
-
在Emacs中复制/粘贴非常简单快捷。
copy/paste within Emacs is straightforward and fast.
从其他应用复制到Emacs:Ctrl + Shift + v
copy from other apps to Emacs: Ctrl+Shift+v
从Emacs到其他应用程序:鼠标选择现在位于X Selection上,因此右键单击并复制将文本复制到Selection中。注意, Mw现在不会将任何内容复制到Selection或系统剪贴板中。
copy from Emacs to other apps: mouse selection is now on X Selection, so right-click and copy shall copy the text into the Selection. Note that 'M-w" now won't copy anything into Selection or system clipboard.
仍然希望有一个好的解决方案!
Still looking forward to a good solution!
这篇关于emacs终端模式:如何有效地复制和粘贴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!