From: Ray Andrews <rayandrews@eastlink.ca>
To: zsh-users@zsh.org
Subject: Re: associative array questions
Date: Tue, 13 Dec 2022 17:08:17 -0800 [thread overview]
Message-ID: <92757e3a-f9eb-56f5-86c4-c18cda02ec44@eastlink.ca> (raw)
In-Reply-To: <CAH+w=7bdsqAj5CATcSJaJ3rud0oteQA1qe+Ri+sd76EecGXJGA@mail.gmail.com>
On 2022-12-13 15:06, Bart Schaefer wrote:
> It would work for the case where the array you want to rewrite is
> Either you're not actually showing us what you're doing, or you're not
> doing what you're telling us you are.
At the risk of making an ass of myself ... I'm quite at a loss, it
damned well did work. Tested 50 times, saved. Restored the backup and
... it doesn't work. Dunno, one of those glitches in the matrix. In
the wrong directory? Somehow created a real 'list'? It damned well
worked. But somehow ... I've been known to make edits in the wrong file
so what I'm editing and what I'm running ain't the same. I'm quite at a
loss. Anyway the good news is that you are not mistaken -- which would
be a serious difficulty. I consume enough of you guy's time, I can't
stand it when I'm totally wasting it barking up the wrong tree. My
apologies. Anyway it is working again ... this time with 'set -A' which
seems preferable besides it's expected to work. God knows. Here's the
whole function:
n_search ()
{
local list=$1 # Name of file buffer, no dollar sign idiot!!
# Begin a search.
if [[ ! "$SEARCHBUF" && ! "$prev_buffer" ]]; then
msg="Begin case insensitive search ... "
# There is no search, but there was in previous loop. i.e. we are
searching, but we have backspaced the search to 'all' so re-enter search
mode with virgin list:
elif [[ ! "$SEARCHBUF" && "$prev_buffer" ]]; then
prev_buffer=
msg="No search, keep trying or UP to return to the list ... "
# We are actively searching. Compute new list as each keystroke
filters more narrowly. ENTER or up/dn arrows end search. Note, buffer
can be preloaded when '$1' is given to nn_init(). But see 'c()' as an
example of the argument to the function NOT being wanted as an initial
search since that removes various heading lines.
elif [[ "$SEARCHBUF" && "$SEARCHBUF" != "$prev_buffer" ]]; then
prev_buffer="$SEARCHBUF"
# Lines below:
# 1) First remove lines starting with colon, they are messages.
# 2) Next do the filtering: Note that the search is not
incremental even tho it looks like it is -- the search is always in the
virgin list, else backspacing would require each previous search result
to be saved separately:
# 3) Now colorize the search string green. '#b': backreferences
active, '#i': case-insensitive.
###
# WORKS: (Tx Roman and Bart)
set -A $list "${(@MP)list:#^:*}"
set -A $list "${(@MP)list:#(#i)*$SEARCHBUF*}"
set -A $list
"${(@MP)list//(#bi)($SEARCHBUF)/$Color${match[1]}$nrm}"
msg="Filtering with: $SEARCHBUF"
fi
}
next prev parent reply other threads:[~2022-12-14 1:09 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-11 17:39 Ray Andrews
2022-12-11 19:53 ` Bart Schaefer
2022-12-11 20:51 ` Ray Andrews
2022-12-11 21:41 ` Bart Schaefer
2022-12-11 22:37 ` Ray Andrews
2022-12-12 1:52 ` Bart Schaefer
2022-12-12 3:09 ` Ray Andrews
2022-12-13 3:31 ` Ray Andrews
2022-12-13 4:39 ` Bart Schaefer
2022-12-13 16:11 ` Ray Andrews
2022-12-13 16:22 ` Roman Perepelitsa
2022-12-13 20:00 ` Ray Andrews
2022-12-13 20:06 ` Roman Perepelitsa
2022-12-13 22:47 ` Ray Andrews
2022-12-13 23:06 ` Bart Schaefer
2022-12-14 1:08 ` Ray Andrews [this message]
2022-12-13 21:18 ` 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=92757e3a-f9eb-56f5-86c4-c18cda02ec44@eastlink.ca \
--to=rayandrews@eastlink.ca \
--cc=zsh-users@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).