让 emacs 在命令行下支持剪切板共享
来源:互联网 发布:ubuntu压缩文件命令 编辑:程序博客网 时间:2024/06/17 08:01
1、在网上广为流传的一种让emacs和系统剪切板共享的方法是在.emacs文件中加入
(setq x-select-enable-clipboard t)
这种方法仅对图形化emacs有效,如果用 emacs -nw 命令打开emacs的话,在命令行中是无效的,因为在命令行下没有权限访问 X 的剪切板(http://unix.stackexchange.com/questions/72605/emacs-copy-and-paste)。
2、正因为第1点,所以网上同时流传着另一种方法:
;;start 设置剪切板共享
(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)
;;end 设置剪切板共享
这种方法确实可用,但是里面的pbpaste和pbcopy命令根本不是linux下的,而是mac下的。所以在linux下应该找到等效的命令替换它们。
3、linux下的剪切板操作命令
找到了两种:xclip和xsel
这两个命令linux不自带,需要安装。两种命令的具体使用方法不做介绍,总之nicek在网上找到了一个适用于linux下的配置(http://hugoheden.wordpress.com/2009/03/08/copypaste-with-emacs-in-terminal/):
;; http://hugoheden.wordpress.com/2009/03/08/copypaste-with-emacs-in-terminal/;; 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)(setq x-select-enable-clipboard t);; If emacs is run in a terminal, the clipboard- functions have no;; effect. Instead, we use of xsel, see;; http://www.vergenet.net/~conrad/software/xsel/ -- "a command-line;; program for getting and setting the contents of the X selection"(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 ))
下面是对ubuntu下剪贴板结构的猜想:
- 让 emacs 在命令行下支持剪切板共享
- ubuntu suse下让vim支持+y剪切板
- 让Vagrant在Windwos下支持使用NFS/SMB共享文件夹从而解决目录共享IO缓慢的问题
- 解决cua mode下emacs与系统剪切板不同步问题
- 在WINXP下,让IIS支持PHP
- 让Libevent 在window下 支持 IOCP
- 让Emacs支持C#语法的显示
- 让MFC支持命令行参数
- 让基于DirectFB的GTK+ 支持全局剪切板
- zeroclipboard --- 让浏览器支持复制黏贴到剪切板
- 在shell命令行下让mplayer循环播放和播放列表
- windows下为Emacs添加右键支持
- 在ubuntu Linux下让Eclipse支持GBK编码
- 转载 在ubuntu Linux下让Eclipse支持GBK编码
- 如何在windows下让apache支持asp,通过iasp
- 在windows7下让zend studio支持aptana.
- 在linux系统下让sqlplus支持历史命令调用
- 让Flex在全屏模式下支持键盘输入
- VMware安装mac os 10.9
- CentOS PPTP配置FreeRADIUS+DaloRADIUS实现高级用户控制+流量控制
- 黑马程序员------KVC,KVO
- MsSqlServer 错误
- 细说概率
- 让 emacs 在命令行下支持剪切板共享
- 成佩涛——一个很久前的视频【Dir 溢出的红客大侠 - 百变红客 SharpWinner】
- kerberos安装配置
- 科技力量
- 士大夫撒地方反倒是副食店
- 科技技术
- ip地址后边加个/8(16,24,32)
- 塞维尔所发生的方式的
- 博客最牛的撒旦的十一国庆