2014-10-27 02:20:32 -07:00
|
|
|
alias emacs='cemacs'
|
|
|
|
alias cemacs='_emacs -c -n'
|
|
|
|
alias temacs='_emacs -t'
|
2014-10-27 03:21:33 -07:00
|
|
|
alias ec='_emacs -n '
|
2014-10-27 01:55:02 -07:00
|
|
|
|
|
|
|
function _emacs {
|
2014-10-28 02:48:51 -07:00
|
|
|
local server_name="$(_current_dot_directory)"
|
2014-10-27 13:28:27 +00:00
|
|
|
if ! _emacs_daemon_exists "$server_name"; then
|
|
|
|
echo "Starting emacs with server name '$server_name'"
|
|
|
|
\emacs --daemon="$server_name"
|
|
|
|
fi
|
2014-10-27 21:32:46 -07:00
|
|
|
emacsclient $* --server-file=$server_name
|
2014-10-27 01:55:02 -07:00
|
|
|
}
|
|
|
|
|
2014-10-27 13:28:27 +00:00
|
|
|
function _emacs_daemon_exists {
|
|
|
|
! test -z "$(ps aux | grep -v grep | grep -i "emacs.*--daemon=.*$1$")"
|
|
|
|
}
|
|
|
|
|
2014-10-27 02:20:32 -07:00
|
|
|
function _dot_directory {
|
2014-10-27 03:21:33 -07:00
|
|
|
echo $1 | sed "s:/:.:g"
|
2014-10-27 01:55:02 -07:00
|
|
|
}
|
2014-10-28 02:48:51 -07:00
|
|
|
|
|
|
|
function _current_dot_directory {
|
|
|
|
local directory="$(git rev-parse --show-toplevel 2> /dev/null || pwd)"
|
|
|
|
_dot_directory $directory
|
|
|
|
}
|