【发布时间】:2015-01-04 09:11:46
【问题描述】:
我很难让这个 emacs -nw 在终端模式 (emacs -nw) 下有效工作。 一些设置信息: 工作服务器通过 SSH 连接,并且 emacs 正在服务器上运行。通常我使用 SSH 和“emacs -nw”连接来处理我的文件。
emacs 配置取自: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)
是启用鼠标选择文本,以便文本区域突出显示,就像“C-x SPC”标记该区域一样。然后我可以使用 "M-x w" 复制和 "C-x y" 在 emacs 内以及 emacs 和其他应用程序之间粘贴文本。
除了任何与 X 相关的操作都非常慢之外,所有看起来都很完美!我与远程服务器的连接很顺畅——延迟通常低于 100 毫秒。但是要使用“C-x k”删除一行文本,大约需要 5 秒!要粘贴它,还需要 5 秒钟!
当复制/粘贴有时很频繁时,这真的很烦人。我认为这与 X 服务器消息传递有关,但不确定是否有解决此问题的好方法。
有什么想法吗? 谢谢!
【问题讨论】:
-
你试过在本地运行emacs并使用tramp模式吗?
-
这是我的第一次尝试——每次我保存任何编辑时,它都会与远程服务器上的文件同步,这并不顺畅。另外,我不喜欢经常启动 emacs(本地机器是笔记本)。
-
出于好奇,您是否遇到过 (setq interprogram-paste...) 行没有运行的问题?我必须手动运行它们。
标签: emacs copy-paste