summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2021-12-31 15:24:00 -0700
committerSean Whitton <spwhitton@spwhitton.name>2021-12-31 15:42:01 -0700
commite20bca43b9505bb05593e61fa9397f154afb6da1 (patch)
tree2ef4af2ee601f92e7b20e0abaaa4deab3e5f3dc3 /scripts
parent019c4492d15dca5d458fe1bcff17e8ce72bf32fc (diff)
downloaddotfiles-e20bca43b9505bb05593e61fa9397f154afb6da1.tar.gz
scripts/desktop/emacsclient: add --installed argument
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/desktop/emacsclient24
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)