您的位置:首页 > 其它

Emacs支持外部程序的粘贴

2017-05-03 16:17 197 查看
1、Linux图形化版本
在.emacs加入:
(setq x-select-enable-clipboard t)

这种方法仅对图形化emacs有效,如果用 emacs -nw 命令打开emacs的话,在命令行中是无效
2、Mac图形化与命令行版本
在.emacs加入:
(defun copy-from-osx () 
(shell-command-to-string "pbpaste")) 
(defun paste-to-osx (text &optional push) 
(let ((process-connection-type nil)) 
(let ((proc (start-process"pbcopy" "*Messages*" "pbcopy"))) 
(process-send-string proc text) 
(process-send-eof proc)))) 
(setq interprogram-cut-function 'paste-to-osx) 
(setq interprogram-paste-function 'copy-from-osx) 
3、Linux命令行版本
在.emacs加入:

适用于linux下的配置(http://hugoheden.wordpress.com/2009/03/08/copypaste-with-emacs-in-terminal/
(setq x-select-enable-clipboard t)
(unless window-system
(when (getenv "DISPLAY")
(defun xsel-cut-function (text &optional push)
(with-temp-buffer
(insert text)
(call-process-region (point-min) (point-max) "xsel" nil 0 nil "--clipboard" "--input")))
(defun xsel-paste-function()
(let ((xsel-output (shell-command-to-string "xsel --clipboard --output")))
(unless (string= (car kill-ring) xsel-output)
xsel-output )))
(setq interprogram-cut-function 'xsel-cut-function)
(setq interprogram-paste-function 'xsel-paste-function)
))


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: