summaryrefslogtreecommitdiff
path: root/bin/emacsclient
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2023-01-06 10:17:31 -0700
committerSean Whitton <spwhitton@spwhitton.name>2023-01-06 11:28:32 -0700
commit8b937a923471460273ae7f658f49c4000bf775c0 (patch)
tree184b5604548f082a6f3bc5dbc5ee4a8d6142cdd9 /bin/emacsclient
parent4ebafe7b76fab02e15c1509272ba6fc4fd61bc59 (diff)
downloaddotfiles-8b937a923471460273ae7f658f49c4000bf775c0.tar.gz
emacsclient wrapper: factor out fail(), notify-send on unknown Emacs
Diffstat (limited to 'bin/emacsclient')
-rwxr-xr-xbin/emacsclient13
1 files changed, 8 insertions, 5 deletions
diff --git a/bin/emacsclient b/bin/emacsclient
index 4bbf097c..16aca4ae 100755
--- a/bin/emacsclient
+++ b/bin/emacsclient
@@ -66,13 +66,16 @@ maybe_notify () {
&& notify-send --urgency=low --expire-time=10000 "$1"
}
+fail () {
+ # emacsclient(1) exits with this exit code on all failures.
+ maybe_notify "$1"; exit 1
+}
+
spw_flock () {
( umask 077; mkdir -p "$locks_dir" )
eval "exec $1<>${locks_dir}$2"
- if ! flock --wait 15 "$1"; then
- maybe_notify "couldn't lock starting Emacs daemon named $2"
- exit 1
- fi
+ flock --wait 15 "$1" \
+ || fail "couldn't lock starting Emacs daemon named $2"
}
pass_to_gdbmacs () {
@@ -130,7 +133,7 @@ if [ -n "$listener" ]; then
case "$(ps h -o exe $listener | sed -e 's/ (deleted)$//')" in
"$devel_emacs") devel_running=true ;;
"$(realpath $installed_emacs)") installed_running=true ;;
- *) echo >&2 "Unknown Emacs listening on $socket"; exit 1 ;;
+ *) fail "Unknown Emacs listening on $socket" ;;
esac
fi