From c53b078c894106d09ee8c38d5db2d1ff1cbf7dab Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Wed, 25 Jan 2017 19:42:26 +0000 Subject: [PATCH 1/4] driver: Convert to anonymous function. This lets us set WARN_CREATE_GLOBAL, and enables the next two commits. --- zsh-syntax-highlighting.zsh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/zsh-syntax-highlighting.zsh b/zsh-syntax-highlighting.zsh index 0251d1e..31220d7 100644 --- a/zsh-syntax-highlighting.zsh +++ b/zsh-syntax-highlighting.zsh @@ -1,3 +1,4 @@ +() { # that's here to make the line numbers in errors match the file line numbers. # ------------------------------------------------------------------------------------------------- # Copyright (c) 2010-2016 zsh-syntax-highlighting contributors # All rights reserved. @@ -28,13 +29,15 @@ # ------------------------------------------------------------------------------------------------- # First of all, ensure predictable parsing. -zsh_highlight__aliases=`builtin alias -Lm '[^+]*'` +local zsh_highlight__aliases="`builtin alias -Lm '[^+]*'`" # In zsh <= 5.2, `alias -L` emits aliases that begin with a plus sign ('alias -- +foo=42') # them without a '--' guard, so they don't round trip. # # Hence, we exclude them from unaliasing: builtin unalias -m '[^+]*' +setopt localoptions warncreateglobal + # Set $0 to the expected value, regardless of functionargzero. 0=${(%):-%N} if true; then @@ -405,3 +408,6 @@ builtin unset zsh_highlight__aliases # Set $?. true + +# End anonymous function +} From c487ad4649f9e5ab5c5e463d45f280c588e2cb24 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Wed, 25 Jan 2017 19:43:59 +0000 Subject: [PATCH 2/4] driver: use 'emulate -L zsh' like highlighters do. --- zsh-syntax-highlighting.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/zsh-syntax-highlighting.zsh b/zsh-syntax-highlighting.zsh index 31220d7..abdcecf 100644 --- a/zsh-syntax-highlighting.zsh +++ b/zsh-syntax-highlighting.zsh @@ -36,6 +36,7 @@ local zsh_highlight__aliases="`builtin alias -Lm '[^+]*'`" # Hence, we exclude them from unaliasing: builtin unalias -m '[^+]*' +emulate -L zsh setopt localoptions warncreateglobal # Set $0 to the expected value, regardless of functionargzero. From 66a297bbc5a65aba8f12ee4addc1152672aa9676 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Wed, 25 Jan 2017 19:45:18 +0000 Subject: [PATCH 3/4] driver: Set the zsh 5.4-to-be WARN_NESTED_VAR option. This may catch bugs. --- zsh-syntax-highlighting.zsh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/zsh-syntax-highlighting.zsh b/zsh-syntax-highlighting.zsh index abdcecf..8bec78c 100644 --- a/zsh-syntax-highlighting.zsh +++ b/zsh-syntax-highlighting.zsh @@ -36,8 +36,9 @@ local zsh_highlight__aliases="`builtin alias -Lm '[^+]*'`" # Hence, we exclude them from unaliasing: builtin unalias -m '[^+]*' +# Set the 5.4-to-be WARN_NESTED_VAR option if it's available. emulate -L zsh -setopt localoptions warncreateglobal +setopt localoptions warncreateglobal ${(k)options[(I)warnnestedvar]} # Set $0 to the expected value, regardless of functionargzero. 0=${(%):-%N} @@ -49,7 +50,7 @@ if true; then # When running from a source tree without 'make install', $ZSH_HIGHLIGHT_REVISION # would be set to '$Format:%H$' literally. That's an invalid value, and obtaining # the valid value (via `git rev-parse HEAD`, as Makefile does) might be costly, so: - ZSH_HIGHLIGHT_REVISION=HEAD + typeset -g ZSH_HIGHLIGHT_REVISION=HEAD fi fi @@ -401,7 +402,7 @@ zmodload zsh/parameter 2>/dev/null || true autoload -U is-at-least # Initialize the array of active highlighters if needed. -[[ $#ZSH_HIGHLIGHT_HIGHLIGHTERS -eq 0 ]] && ZSH_HIGHLIGHT_HIGHLIGHTERS=(main) +[[ $#ZSH_HIGHLIGHT_HIGHLIGHTERS -eq 0 ]] && ZSH_HIGHLIGHT_HIGHLIGHTERS[1]=main # Restore the aliases we unned eval "$zsh_highlight__aliases" From ca6b31f6e0c3139e8450c58473ef50d8783e40e4 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Mon, 25 Dec 2017 00:40:08 +0000 Subject: [PATCH 4/4] noop: Use an alternative spelling. As requested on #413. --- zsh-syntax-highlighting.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zsh-syntax-highlighting.zsh b/zsh-syntax-highlighting.zsh index 8bec78c..790b7c6 100644 --- a/zsh-syntax-highlighting.zsh +++ b/zsh-syntax-highlighting.zsh @@ -29,7 +29,7 @@ # ------------------------------------------------------------------------------------------------- # First of all, ensure predictable parsing. -local zsh_highlight__aliases="`builtin alias -Lm '[^+]*'`" +local zsh_highlight__aliases="$(builtin alias -Lm '[^+]*')" # In zsh <= 5.2, `alias -L` emits aliases that begin with a plus sign ('alias -- +foo=42') # them without a '--' guard, so they don't round trip. #