#!/bin/bash function do_local() { . ~/.settings wmctrl -s 2 if emacsclient -e '(version)' &>/dev/null then emacsclient -n "$@" # for FILE in "$@" # do # case $FILE in # +*) # GOTO=$FILE # ;; # *) # FILE=`abspath.py "$FILE"` # emacsclient -e "(switch-to-buffer (car (buffer-list)))" >/dev/null # emacsclient -e "(setq file-name-history (cons \"$FILE\" file-name-history))" >/dev/null # emacsclient -e "(find-file \"$FILE\")" >/dev/null # if [ -n "$GOTO" ] # then # emacsclient -e "(goto-line $GOTO (car (buffer-list)))" >/dev/null # GOTO= # fi # ;; # esac # done else emacs -geometry $EMACS_GEOMETRY2 "$@" & fi } function do_remote() { for FILE in "$@" do case $FILE in +*) GOTO=$FILE ;; *) FILE=`abspath.py "$FILE"` FILE="/`hostname`:/$FILE" local_exec.py e $GOTO "$FILE" ;; esac done } if [ -n "$SSH_CONNECTION" ] then do_remote "$@" else do_local "$@" fi