diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2021-12-31 15:24:00 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2021-12-31 15:42:01 -0700 |
commit | e20bca43b9505bb05593e61fa9397f154afb6da1 (patch) | |
tree | 2ef4af2ee601f92e7b20e0abaaa4deab3e5f3dc3 /scripts | |
parent | 019c4492d15dca5d458fe1bcff17e8ce72bf32fc (diff) | |
download | dotfiles-e20bca43b9505bb05593e61fa9397f154afb6da1.tar.gz |
scripts/desktop/emacsclient: add --installed argument
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/desktop/emacsclient | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/scripts/desktop/emacsclient b/scripts/desktop/emacsclient index e76ea6da..4342fa3c 100755 --- a/scripts/desktop/emacsclient +++ b/scripts/desktop/emacsclient @@ -7,14 +7,24 @@ # # The idea is that I can always hit C-i RET without worrying about builds. -if [ -e "$HOME/src/emacs/admin/README.melete" \ - -a -x "$HOME/src/emacs/lib-src/emacsclient" \ - -a -d "/usr/share/emacs-snapshot/site-lisp/elpa" ] \ +socket="/run/user/$(id -u)/emacs/server" +ps -o exe -u "$USER" -U "$USER" | grep -q "$HOME/src/emacs/src/emacs" \ + && devel_running=true + +if [ "$devel_running" = true -a "$1" = --installed ]; then + pgrep --full "$HOME/src/emacs/src/emacs" | while read pid; do + kill $pid + done + [ -e $socket ] && inotifywait -qqt 2 -e delete $socket +fi + +if [ "$1" != --installed \ + -a -e "$HOME/src/emacs/admin/README.melete" \ + -a -x "$HOME/src/emacs/lib-src/emacsclient" \ + -a -d "/usr/share/emacs-snapshot/site-lisp/elpa" ] \ && ! ps -o exe -u "$USER" -U "$USER" | grep -q $(command -v emacs) \ - && ! ( ! ps -o exe -u "$USER" -U "$USER" \ - | grep -q "$HOME/src/emacs/src/emacs" \ - && ps h -o pid -C make | xargs pwdx \ - | grep -q "$HOME/src/emacs" ); then + && ! ( [ "$devel_running" != true ] && ps h -o pid -C make \ + | xargs pwdx | grep -q "$HOME/src/emacs" ); then EMACSCLIENT="$HOME/src/emacs/lib-src/emacsclient" else EMACSCLIENT=$(command -v emacsclient) |