From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: job-completion with strings
Date: Fri, 19 Nov 1999 11:04:52 +0100 (MET) [thread overview]
Message-ID: <199911191004.LAA02387@beta.informatik.hu-berlin.de> (raw)
This makes _jobs use the `strings' style. If that is true, the job
references generated as matches will use the stuff from the job-texts
instead of the numbers (i.e. `%foo' instead of `%1'). So:
compstyle '*:jobs' strings yes
For those who like that.
I've made this slightly more complicated because I wanted to avoid
that we get unnecessary long matches like `%for\ i\ in\ ...'. It
tries to use only the shorted unambiguous string for each job.
Bye
Sven
diff -u -r oldcompletion/Base/_jobs Completion/Base/_jobs
--- oldcompletion/Base/_jobs Fri Nov 19 09:55:54 1999
+++ Completion/Base/_jobs Fri Nov 19 10:58:28 1999
@@ -22,13 +22,47 @@
_description expl job
fi
-disp=()
-jobs=()
-for job in "$jids[@]"; do
- [[ -n "$desc" ]] &&
- disp=( "$disp[@]" "${pfx}${(r:2:: :)job} -- ${(r:COLUMNS-8:: :)jobtexts[$job]}" )
- jobs=( "$jobs[@]" "$job" )
-done
+if [[ -n "$desc" ]]; then
+ disp=()
+ for job in "$jids[@]"; do
+ [[ -n "$desc" ]] &&
+ disp=( "$disp[@]" "${pfx}${(r:2:: :)job} -- ${(r:COLUMNS-8:: :)jobtexts[$job]}" )
+ done
+fi
+
+if _style jobs strings; then
+ local texts i text str tmp
+
+ # Find shortest unambiguous strings.
+
+ texts=( "$jobtexts[@]" )
+ jobs=()
+ for i in "$jids[@]"; do
+ text="$jobtexts[$i]"
+ str="${text%% *}"
+ if [[ "$text" = *\ * ]]; then
+ text="${text#* }"
+ else
+ text=""
+ fi
+ tmp=( "${(@M)texts:#${str}*}" )
+ while [[ -n "$text" && $#tmp -ge 2 ]]; do
+ str="${str} ${text%% *}"
+ if [[ "$text" = *\ * ]]; then
+ text="${text#* }"
+ else
+ text=""
+ fi
+ tmp=( "${(@M)texts:#${str}*}" )
+ done
+
+ jobs=( "$jobs[@]" "$str" )
+ done
+
+ [[ -n "$pfx" && -n "$desc" ]] && disp=( "${(@)disp#%}" )
+else
+ jobs=( "$jids[@]" )
+fi
if [[ -n "$desc" ]]; then
compadd "$@" "$expl[@]" -ld disp - "%$^jobs[@]"
diff -u olddoc/Zsh/compsys.yo Doc/Zsh/compsys.yo
--- olddoc/Zsh/compsys.yo Thu Nov 18 11:01:38 1999
+++ Doc/Zsh/compsys.yo Fri Nov 19 10:59:55 1999
@@ -1065,6 +1065,11 @@
and it will stop when the last match is inserted. If this style is set
to tt(verbose) a message will be displayed when the last match is reached.
)
+item(tt(strings))(
+This is used with the tt(jobs) tag. If it is `true', the completions
+will use the shortest unambiguous strings of the jobs' command lines
+instead of the job numbers.
+)
item(tt(substitute))(
If this is unset or set to the empty string, the tt(_expand) completer
will first try to expand all substitutions in the string (such as
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
reply other threads:[~1999-11-19 10:05 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=199911191004.LAA02387@beta.informatik.hu-berlin.de \
--to=wischnow@informatik.hu-berlin.de \
--cc=zsh-workers@sunsite.auc.dk \
/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).