Files
RedBear-OS/recipes/shells/zsh/source/Functions/Zle/match-word-context
T
vasilito ff4ff35918 feat: track all source trees in git — full fork offline-first model
Red Bear OS is a full fork. All sources must be available from git clone
with zero network access. Removed gitignore rules that excluded fetched
source trees under recipes/*/source/, local/recipes/kde/*/source/,
local/recipes/qt/*/source/, and vendor source trees.

Build artifacts (target/, build/, source.tar, *.o, *.so) remain excluded.

127291 files added — kernel, relibc, base, bootloader, pkgar, all KDE/Qt
frameworks, mesa, wayland, DRM drivers, and every other recipe source.
2026-05-14 10:55:53 +01:00

51 lines
1.2 KiB
Plaintext

# See if we can extend the word context to something more specific.
# curcontext must be set to the base context by this point; it
# will be appended to directly.
emulate -L zsh
setopt extendedglob
local -a worcon bufwords
local pat tag lastword word backword forword
integer iword between
zstyle -a $curcontext word-context worcon || return 0
if (( ${#worcon} % 2 )); then
zle -M "Bad word-context style in context $curcontext"
return
fi
bufwords=(${(z)LBUFFER})
iword=${#bufwords}
lastword=${bufwords[-1]}
bufwords=(${(z)BUFFER})
if [[ $lastword = ${bufwords[iword]} ]]; then
# If the word immediately left of the cursor is complete,
# we're not on it for forward operations.
forword=${bufwords[iword+1]}
# If, furthermore, we're on whitespace, then we're between words.
# It can't be significant whitespace because the previous word is complete.
[[ $RBUFFER[1] = [[:space:]] ]] && between=1
else
# We're on a word.
forword=${bufwords[iword]}
fi
backword=${bufwords[iword]}
if [[ between -ne 0 && $curcontext = *between* ]]; then
word=' '
elif [[ $curcontext = *back* ]]; then
word=$backword
else
word=$forword
fi
for pat tag in "${worcon[@]}"; do
if [[ $word = ${~pat} ]]; then
curcontext+=":$tag"
return
fi
done