zsh-users / zsh-syntax-highlighting

Fish shell like syntax highlighting for Zsh.
github.com/zsh-users/zsh-syntax-highlighting
BSD 3-Clause "New" or "Revised" License
19.55k stars 1.32k forks source link

Question: have the driver sourced in zsh emulation? #688

Open danielshahaf opened 4 years ago

danielshahaf commented 4 years ago

In INSTALL.md, shall we change source ./zsh-syntax-highlighting/zsh-syntax-highlighting.zsh to emulate zsh -c "source ./zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"?

Compare the documentation of autoload: https://github.com/zsh-users/zsh/blob/fd627a504fd2a84833b7edcf92dd1595fcf11df9/Doc/Zsh/builtins.yo#L217-L224

In particular, I think this might have negated #622.

danielshahaf commented 4 years ago

The test harness' callsite should be updated too — either to use this construct, or to test invocation with unusual options (e.g., KSH_ARRAYS) in effect.

danielshahaf commented 4 years ago

How can we set "sticky" emulation for all our functions?

danielshahaf commented 4 years ago

In INSTALL.md, shall we change source ./zsh-syntax-highlighting/zsh-syntax-highlighting.zsh to emulate zsh -c "source ./zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"?

Actually, it might be easier to add a layer of indirection:

% git rename zsh-syntax-highlighting.zsh driver.zsh
% print -r -- $'0=${(%):-%N}; emulate zsh -c \'source "${0:h}/driver.zsh" "$@"\'' > zsh-syntax-highlighting.zsh
% git add $_

This way, we won't spend the next 10 years telling people to add the emulate to their dotfiles…

We'd still need to check whether emulate zsh -c 'source $foo' DTRTs for us, though.

(The ${(%):-%N} is taken from zsh-syntax-highlighting.zsh:39.)

danielshahaf commented 4 years ago

Triage: Deferring until after redrawhook is merged to prevent annoying merge conflicts upon that merge.

danielshahaf commented 3 years ago

Triage: Deferring until after redrawhook is merged to prevent annoying merge conflicts upon that merge.

Triage: Unblocked; milestoning 0.8.0, but will defer it if that release is ready before this is merged.