Closed Nicholas-Autio-Mitchell closed 1 month ago
Hello @Nicholas-Autio-Mitchell,
While in a tmux pane, can you execute this command?
$ tmux lsk | grep -E 'prefix\s+e\s+'
Can you also try to set EDITOR
to only emacs
?
Hi @gpakosz , here is the unedited output
π ▶ tmux lsk | grep -E 'prefix\s+e\s+'
bind-key -T prefix e new-window -e "EDITOR=emacs -nw --no-splash" -n "#{TMUX_CONF_LOCAL}" sh -c "case \"\\${EDITOR:-vim}\" in *vim) \\${EDITOR:-vim} -c \":set syntax=tmux\" \"\\$TMUX_CONF_LOCAL\";; *) \"\\$EDITOR\" \"\\$TMUX_CONF_LOCAL\";; esac && \"\\$TMUX_PROGRAM\" \\${TMUX_SOCKET:+-S \"\\$TMUX_SOCKET\"} source \"\\$TMUX_CONF\" \\; display \"\\$TMUX_CONF_LOCAL sourced\""
Here is me trying EDITOR=emacs
:
π ▶ echo $EDITOR
emacs -nw --no-splash
π ▶ EDITOR="emacs"
π ▶ echo $EDITOR
emacs
π ▶ tmux lsk | grep -E 'prefix\s+e\s+'
bind-key -T prefix e new-window -e "EDITOR=emacs -nw --no-splash" -n "#{TMUX_CONF_LOCAL}" sh -c "case \"\\${EDITOR:-vim}\" in *vim) \\${EDITOR:-vim} -c \":set syntax=tmux\" \"\\$TMUX_CONF_LOCAL\";; *) \"\\$EDITOR\" \"\\$TMUX_CONF_LOCAL\";; esac && \"\\$TMUX_PROGRAM\" \\${TMUX_SOCKET:+-S \"\\$TMUX_SOCKET\"} source \"\\$TMUX_CONF\" \\; display \"\\$TMUX_CONF_LOCAL sourced\""
Executing <prefix> e
still has no effect.
~I notice in the output of tmux lsk | grep -E 'prefix\s+e\s+'
above, after changing to EDITOR=emacs
, the command still uses emacs -nw --no-splash
. I have killed/restarted the tmux server, and also edited by ~/.bashrc
to ensure the change to EDITOR is already there in the new session, but it still records the original EDITOR value.~
Ok, realised tmux takes the value of EDITOR
from the parent shell, before tmux itself starts up. 🤦 Made the correct change, and it seems to have fixed the issue! 🎉
Just trying a few more things to make sure it is the case...
It seems adding any argument at all the emacs
command in EDITOR
causes the issue. Could it be a problem with escaping the command when tmux reads it?
I tried wrapping emacs -nw --no-splash
inside a function emacs_fn
and set EDITOR=emacs_fn
. It still doesn't work, so not likely an issue with escaping the command etc.
Additionally, I have had EDITOR=emacs -nw --no-splash
set for years... I also didn't pull any updates from oh my tmux recently, so perhaps it is coming from elsewhere. My only guess is an emacs or emacs dependency update, but couldn't find a possible reason after a quick search now. Unless you have more ideas, I will assume it isn't an issue to resolve here.
As always, thanks for your help @gpakosz !
Can you please try setting EDITOR='emacs -nw --no-splash'
again with the gh-744
branch?
This implies quitting tmux etc like you noticed above
The changes to quotes when reading the $EDITOR env var (made in gh-744) do fix the issue.
I had an older config on a different machine, where I still used EDITOR='emacs -nw --no-splash'
, so could compare three versions. Here is a summary:
# Works: an old tmux.conf (unknown commit)
bind e new-window -n "#{TMUX_CONF_LOCAL}" sh -c '${EDITOR:-vim} "$TMUX_CONF_LOCAL" && "$TMUX_PROGRAM" ${TMUX_SOCKET:+-S "$TMUX_SOCKET"} source "$TMUX_CONF" \; display "$TMUX_CONF_LOCAL sourced"'
# Fails: current master
bind e new-window -n "#{TMUX_CONF_LOCAL}" -e "EDITOR=$EDITOR" sh -c 'case "${EDITOR:-vim}" in *vim) ${EDITOR:-vim} -c ":set syntax=tmux" "$TMUX_CONF_LOCAL";; *) "$EDITOR" "$TMUX_CONF_LOCAL";; esac && "$TMUX_PROGRAM" ${TMUX_SOCKET:+-S "$TMUX_SOCKET"} source "$TMUX_CONF" \; display "$TMUX_CONF_LOCAL sourced"'
# Works: gh-744
bind e new-window -n "#{TMUX_CONF_LOCAL}" -e EDITOR="$EDITOR" sh -c 'case "${EDITOR:-vim}" in *vim) ${EDITOR:-vim} -c ":set syntax=tmux" "$TMUX_CONF_LOCAL";; *) $EDITOR "$TMUX_CONF_LOCAL";; esac && "$TMUX_PROGRAM" ${TMUX_SOCKET:+-S "$TMUX_SOCKET"} source "$TMUX_CONF" \; display "$TMUX_CONF_LOCAL sourced"'
Using
<prefix> e
is not opening~/.tmux.conf.local
as usual. The prefix key is working, and all other bindings that I use are working fine. I have the latest commit, and the line in.tmux.conf
the creates thebind e
is there.I found this issue reporting the same problem, and followed similar debug steps there, all info below.
I cannot think of anything else I may've changed to break this. MY bash configs were last touched long before this occured.
Debugging info
EDITOR='emacs -nw --no-splash'
(nw means no window). I can open the file using emacs with this command. `~/.tmux.conf.localRunning
sh -cx '${EDITOR:-vim} ~/.tmux.conf.local && tmux source ~/.tmux.conf && tmux display "~/.tmux.conf sourced"'
works without any issues:In
~/.tmux.conf
replacecfg=$(mktemp) && trap 'rm -f $cfg*' EXIT
withcfg=/tmp/tmux.conf
-- then runcut -c3- ~/.tmux.conf | sh -sx _apply_bindings
.Output of that command:
Contents of
/tmp/tmux.conf.in
:I ran
tmux -vvv
-- looking through the (huge) log files, but could not find anything related to this failure. The only failure was the client failing to connect to the server while it was getting itself set up.Versions