help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

copy and paste


From: 锁住子
Subject: copy and paste
Date: Tue, 6 Jan 2009 21:35:34 -0800 (PST)
User-agent: G2/1.0

I found the functions below online somewhere, for easing the process
of copying and pasting between emacs and Mac OSX's clipboard. It
works, but doesn't seem to be encoding aware -- if I kill from a
unicode-encoded buffer and paste into a different osx application (eg
Mail), non-ASCII characters come out garbled. My language environment
is set to UTF-8, is there something I can add in the functions below
that will specify string encoding? I'm trying to achieve all Unicode,
all the time.

Thanks!

Eric


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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]