summaryrefslogtreecommitdiff
path: root/bin/emacsclient
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2023-01-12 13:09:23 -0700
committerSean Whitton <spwhitton@spwhitton.name>2023-01-13 17:36:32 -0700
commita4c3b8b53f2799ba78ae24016b2deafaa03b2ded (patch)
tree52f01a5ecb2956fbcde88e9021a38bcead0e1038 /bin/emacsclient
parent25de3ae596535fd46b6f745420cd1cdc2e72f09e (diff)
downloaddotfiles-a4c3b8b53f2799ba78ae24016b2deafaa03b2ded.tar.gz
emacsclient wrapper: use getopt(1) to break up clustered short opts
Diffstat (limited to 'bin/emacsclient')
-rwxr-xr-xbin/emacsclient23
1 files changed, 15 insertions, 8 deletions
diff --git a/bin/emacsclient b/bin/emacsclient
index c30b341a..12630575 100755
--- a/bin/emacsclient
+++ b/bin/emacsclient
@@ -20,7 +20,7 @@
# emacsclient(1) wrapper to handle updating the environment of existing
# daemons and choosing between installed and in-tree builds of Emacs.
-min_arg=0
+min_arg=1
may_start=true
want_update=false
want_installed=false
@@ -63,6 +63,17 @@ for cmd in bash flock inotifywait perl pwdx ss; do
done
[ -n "$BASH_VERSION" ] || exec bash "$0" "$@"
+# We have to do this to break up clustered short options. An unfortunate
+# consequence is maintaining a copy of all of emacsclient(1)'s long opts here.
+# To mitigate that somewhat, don't hard fail if we hit an unrecognised option.
+getopt=$(getopt -qas bash -n emacsclient -o "nqueHVtca:F:w:s:f:d:T:" \
+ -l "spw/installed,spw/no-start,spw/update-environment \
+no-wait,quiet,suppress-output,eval,help,version,tty,nw,\
+create-frame,reuse-frame,alternate-editor:,frame-parameters:,socket-name:,\
+server-file:,display:,parent-id:,timeout:,tramp:" -- "$@")
+[ $? -eq 0 ] || defer "$@"
+eval set -- "$getopt"
+
get_listener () {
local socket="$1"
local listener=$(ss -Hplx src "$socket" \
@@ -126,6 +137,7 @@ for arg do
'--spw/update-environment') want_update=true ;;
'-V'|'--version') want_version=true ;;&
'-e'|'--eval') want_eval=true ;;&
+ '-s'|'--socket-name') min_arg=3; daemon_name="$1" ;;&
# We'll use the same timeout for some things we do in this script,
# if the user has supplied a value.
@@ -137,14 +149,9 @@ for arg do
# locks on starting up daemons, else no other invocation of this
# script will be able to do anything without manual intervention.
'-w'|'--timeout') timeout="$1" ;;&
- '-w'?*) timeout="${arg:2}" ;;&
- '--timeout='?*) timeout="${arg:10}" ;;&
-
- '-s'|'--socket-name') min_arg=2; daemon_name="$1" ;;&
- '-s'?*) min_arg=1; daemon_name="${arg:2}" ;;&
- '--socket-name='?*) min_arg=1; daemon_name="${arg:14}" ;;&
- *) set -- "$@" "$arg" ;;
+ '--nw') set -- "$@" -nw ;;
+ *) set -- "$@" "$arg" ;;
esac
done