Skip to content

Instantly share code, notes, and snippets.

@minimum2scp
Created October 12, 2011 11:41
Show Gist options
  • Save minimum2scp/1281004 to your computer and use it in GitHub Desktop.
Save minimum2scp/1281004 to your computer and use it in GitHub Desktop.
emacsのカレントバッファを標準出力に出すシェル関数
function ecat (){
local ecat_tempfile=`mktemp -t ecat_tempfile.XXXXXXXX`
emacsclient -e "
(with-current-buffer
(if (featurep 'elscreen)
(let* ((frame-confs (elscreen-get-frame-confs (selected-frame)))
(num (nth 1 (assoc 'screen-history frame-confs)))
(cur-window-conf (cadr (assoc num (assoc 'screen-property frame-confs))))
(marker (nth 2 cur-window-conf)))
(marker-buffer marker))
(nth 1
(assoc 'buffer-list
(nth 1 (nth 1 (current-frame-configuration))))))
(if (region-active-p)
(write-region (region-beginning) (region-end) \"$ecat_tempfile\")
(write-region (point-min) (point-max) \"$ecat_tempfile\"))
)
"
cat "$ecat_tempfile"
rm -f "$ecat_tempfile"
}
@minimum2scp
Copy link
Author

Mac(BSD系)でもmktempが動くように引数 -t ecat_tempfile.XXXXXXX をつけてみました

@minimum2scp
Copy link
Author

メモ: e2wm対応は with-current-buffer の第1引数 (if (featurep 'elscreen) ... ) を
https://gist.github.com/1247111 の (e2wm:current-buffer) にするとできそう。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment