aboutsummaryrefslogtreecommitdiffstats
path: root/_zsh/80-emacs.zsh
diff options
context:
space:
mode:
authorAaron LI <aaronly.me@gmail.com>2016-05-15 10:08:07 +0800
committerAaron LI <aaronly.me@gmail.com>2016-05-15 10:08:07 +0800
commit7cb84718c6179a65b67948ebfec66edddf1a3d50 (patch)
tree3de9fb09ba129437a286808929936e403595ae9f /_zsh/80-emacs.zsh
parentd11be71f0c5b7c7ecb5e62ee26a5d760822f680b (diff)
downloaddotfiles-7cb84718c6179a65b67948ebfec66edddf1a3d50.tar.bz2
80-emacs.zsh: check existence of emacsclient first
Diffstat (limited to '_zsh/80-emacs.zsh')
-rw-r--r--_zsh/80-emacs.zsh48
1 files changed, 25 insertions, 23 deletions
diff --git a/_zsh/80-emacs.zsh b/_zsh/80-emacs.zsh
index 8ccd100..27966b9 100644
--- a/_zsh/80-emacs.zsh
+++ b/_zsh/80-emacs.zsh
@@ -7,33 +7,35 @@
# 2016-02-21
#
-function _emacsclient() {
- # Get list of available X windows.
- X=`emacsclient --alternate-editor '' --eval '(x-display-list)' 2>/dev/null`
+if exists emacsclient; then
+ function _emacsclient() {
+ # Get list of available X windows.
+ X=`emacsclient --alternate-editor '' --eval '(x-display-list)' 2>/dev/null`
- if [ -z "$X" ] || [ "$X" = "nil" ]; then
- # Create one if there is no X window yet.
- command emacsclient --alternate-editor "" --create-frame "$@"
- else
- # Prevent creating another X frame if there is at least one present.
- command emacsclient --alternate-editor "" "$@"
- fi
-}
+ if [ -z "$X" ] || [ "$X" = "nil" ]; then
+ # Create one if there is no X window yet.
+ command emacsclient --alternate-editor "" --create-frame "$@"
+ else
+ # Prevent creating another X frame if there is at least one present.
+ command emacsclient --alternate-editor "" "$@"
+ fi
+ }
-# Write to stdout the path to the file opened in the current buffer
-function efile() {
- local cmd="(buffer-file-name (window-buffer))"
- _emacsclient --eval "$cmd" | tr -d '"'
-}
+ # Write to stdout the path to the file opened in the current buffer
+ function efile() {
+ local cmd="(buffer-file-name (window-buffer))"
+ _emacsclient --eval "$cmd" | tr -d '"'
+ }
-# Same as 'M-x eval' but outside of Emacs
-alias eeval='_emacsclient --eval'
-# Create a new X frame
-alias eframe='_emacsclient --create-frame --no-wait'
+ # Same as 'M-x eval' but outside of Emacs
+ alias eeval='_emacsclient --eval'
+ # Create a new X frame
+ alias eframe='_emacsclient --create-frame --no-wait'
-alias emacs='_emacsclient -t'
-alias e=emacs
-alias ef=eframe
+ alias emacs='_emacsclient -t'
+ alias e=emacs
+ alias ef=eframe
+fi # end "exists emacsclient"
# vim: set ts=8 sw=4 tw=0 fenc=utf-8 ft=zsh: #