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)
 ))

Emacs支持外部程序的粘贴

相关文章:

  • 2022-12-23
  • 2021-12-02
  • 2022-12-23
  • 2022-12-23
  • 2021-06-23
  • 2022-12-23
  • 2021-05-16
猜你喜欢
  • 2021-12-27
  • 2022-12-23
  • 2022-03-07
  • 2021-06-10
  • 2021-04-05
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案