From: Joey Pabalinas <joeypabalinas@gmail.com>
To: zsh-workers@zsh.org
Subject: [PATCH] select-bracketed: set nocprecedences to force native precedence ordering
Date: Tue, 6 Nov 2018 13:34:10 -1000 [thread overview]
Message-ID: <389ebb53e6d5b8cfe9985af3d41574679e5ce4b8.1541547033.git.joeypabalinas@gmail.com> (raw)
With cprecedences set, expressions like `1 + (idx-1) & ~1` are evaluated as
`(1 + (idx-1)) & ~1` instead of the intended `1 + ((idx-1) & ~1)`. Set the
nocprecedences option and add clarifying parenthesis to the ambiguous
expressions.
Signed-off-by: Joey Pabalinas <joeypabalinas@gmail.com>
---
Functions/Zle/select-bracketed | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/Functions/Zle/select-bracketed b/Functions/Zle/select-bracketed
index d467bb8047466faa32..add5b70f0c9fd72215 100644
--- a/Functions/Zle/select-bracketed
+++ b/Functions/Zle/select-bracketed
@@ -10,17 +10,17 @@
# for c in {a,i}${(s..)^:-'()[]{}<>bB'}; do
# bindkey -M $m $c select-bracketed
# done
# done
-setopt localoptions noksharrays
+setopt localoptions nocprecedences noksharrays
local style=${${1:-$KEYS}[1]} matching="(){}[]<>bbBB"
local -i find=${NUMERIC:-1} idx=${matching[(I)[${${1:-$KEYS}[2]}]]}%9
(( idx )) || return 1 # no corresponding closing bracket
-local lmatch=${matching[1 + (idx-1) & ~1]}
-local rmatch=${matching[1 + (idx-1) | 1]}
+local lmatch=${matching[1 + ((idx-1) & ~1)]}
+local rmatch=${matching[1 + ((idx-1) | 1)]}
local -i start=CURSOR+1 end=CURSOR+1 rfind=find
[[ $BUFFER[start] = "$rmatch" ]] && (( start--, end-- ))
if (( REGION_ACTIVE && MARK != CURSOR)); then
(( MARK < CURSOR && (start=end=MARK+1) ))
--
Cheers,
Joey Pabalinas
next reply other threads:[~2018-11-06 23:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-06 23:34 Joey Pabalinas [this message]
2018-11-06 23:40 ` Bart Schaefer
2018-11-06 23:47 ` Joey Pabalinas
2018-11-07 6:28 ` Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=389ebb53e6d5b8cfe9985af3d41574679e5ce4b8.1541547033.git.joeypabalinas@gmail.com \
--to=joeypabalinas@gmail.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).