我很难让这个 emacs -nw 在终端模式(emacs -nw)下有效工作。
一些设置信息:
工作服务器通过 SSH 连接,emacs 运行在服务器上。通常我使用 SSH 和“emacs -nw”进行连接来处理我的文件。
emacs 配置取自:https://hugoheden.wordpress.com/2009/03/08/copypaste-with-emacs-in-terminal/ 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/[email protected] /cdn-cgi/l/email-protection/msg03577.html
))
拥有的理由:
(require 'mouse)
(xterm-mouse-mode t)
(defun track-mouse (e))
(setq mouse-sel-mode t)
是启用鼠标在文本上进行选择,以便文本区域突出显示,就像标记该区域的“C-x SPC”一样。然后我可以使用“M-x w”在 emacs 内以及 emacs 和其他应用程序之间复制文本,使用“C-x y”粘贴文本。
一切看起来都很完美,除了与 X 相关的任何操作都非常慢!我与远程服务器的连接很顺畅——延迟通常低于 100 毫秒。但要使用“C-x k”删除一行文本,大约需要 5 秒!粘贴起来还需要5秒!
当复制/粘贴有时很频繁时,这真的很烦人。我认为这与 X 服务器消息传递有关,但不确定是否有好的方法来解决这个问题。
有任何想法吗?
谢谢!
这本身并不是一个理想的解决方案,但我找到了一种比前一种感觉更好的方法。
这个想法是摆脱导致严重延迟问题的 X,即仅保留以下内容:
;; enable clipboard in emacs
(setq x-select-enable-clipboard t)
结果是:
Emacs 中的复制/粘贴既简单又快速。
从其他应用程序复制到 Emacs:Ctrl+Shift+v
从 Emacs 复制到其他应用程序:鼠标选择现在位于 X 选择上,因此右键单击并复制会将文本复制到选择中。请注意,“M-w”现在不会将任何内容复制到选择或系统剪贴板中。
这又是一种妥协,而不是解决方案,但考虑到我复制/粘贴比应用程序间操作更频繁的事实,目前这是可以接受的。
还是期待有好的解决方案!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)