From 2fba4486bfa63cf2a4a11a34c94ce123127ef4c9 Mon Sep 17 00:00:00 2001 From: Tristan Carel Date: Wed, 13 Apr 2011 17:34:51 +0200 Subject: [PATCH] Add new plugin emacs, to take benefit of daemon capabilities of emacs >=23 --- plugins/emacs/emacs.plugin.zsh | 11 +++++++++++ plugins/emacs/emacsclient.sh | 10 ++++++++++ 2 files changed, 21 insertions(+) create mode 100644 plugins/emacs/emacs.plugin.zsh create mode 100755 plugins/emacs/emacsclient.sh diff --git a/plugins/emacs/emacs.plugin.zsh b/plugins/emacs/emacs.plugin.zsh new file mode 100644 index 000000000..bca79e70e --- /dev/null +++ b/plugins/emacs/emacs.plugin.zsh @@ -0,0 +1,11 @@ +# Use daemon capabilities of emacs 23 +if "$ZSH/tools/require_tool.sh" emacs 23 2>/dev/null ; then + export EDITOR="$ZSH/plugins/emacs/emacsclient.sh" + alias emacs="$EDITOR --no-wait" + alias e=emacs + + alias emasc=emacs + alias emcas=emacs + # create a new X frame + alias emacs_frame='emacsclient --alternate-editor "" --create-frame' +fi diff --git a/plugins/emacs/emacsclient.sh b/plugins/emacs/emacsclient.sh new file mode 100755 index 000000000..3475926a6 --- /dev/null +++ b/plugins/emacs/emacsclient.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +# Starts emacs daemon if not already started. + +x=`emacsclient --alternate-editor '' --eval '(x-display-list)' 2>/dev/null` +if [ -z "$x" ] ;then + emacsclient --alternate-editor "" --create-frame $@ +else + emacsclient --alternate-editor "" $@ +fi