Skip to content

Instantly share code, notes, and snippets.

@river24
Last active December 14, 2015 19:09
Show Gist options
  • Select an option

  • Save river24/5134316 to your computer and use it in GitHub Desktop.

Select an option

Save river24/5134316 to your computer and use it in GitHub Desktop.
utf-8-hfs な Emacs から日本語を pbcopy した際の NFD / NFC 問題対策
;; clipboardの共有
;; Original : http://hakurei-shain.blogspot.jp/2010/05/mac.html
(when darwin-p
(defun copy-from-osx ()
(shell-command-to-string "pbpaste"))
(defun paste-to-osx (text &optional push)
(let ((process-connection-type nil))
(start-process "pbcopy-from-emacs" "*Messages*" "pbcopy-from-emacs" text)))
(setq interprogram-cut-function 'paste-to-osx)
(setq interprogram-paste-function 'copy-from-osx))
#!/bin/sh
ECHO="/bin/echo"
ICONV="/usr/bin/iconv"
PBCOPY="/usr/bin/pbcopy"
if [ $# -lt 1 ]
then
exit
else
TEXT=$1
${ECHO} -n "${TEXT}" | ${ICONV} -f UTF-8-MAC -t UTF-8 | ${PBCOPY}
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment