zsh-workers
 help / color / mirror / code / Atom feed
* pws-12
@ 1999-03-13 15:00 Peter Stephenson
  1999-03-14  5:04 ` BUG: 3.1.5-pws-11 completion coredumps Geoff Wing
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Peter Stephenson @ 1999-03-13 15:00 UTC (permalink / raw)
  To: Zsh hackers list

This week's version is brought to you by the letters p, w and s and the
number 12.
http://www.ifh.de/~pws/computing/
-rw-r--r--   1 pws  quadrics  307861 Mar 13 15:32 zsh-3.1.5-pws-12.doc.tar.bz2
-rw-r--r--   1 pws  quadrics  467481 Mar 13 15:32 zsh-3.1.5-pws-12.doc.tar.gz
-rw-r--r--   1 pws  quadrics  716644 Mar 13 15:32 zsh-3.1.5-pws-12.tar.bz2
-rw-r--r--   1 pws  quadrics  887161 Mar 13 15:32 zsh-3.1.5-pws-12.tar.gz

I have discovered some problems when the build directory is in a different
place from the source directory: notably, some files such as modules-bltin,
signames.c and sigcount.h are created in the source directory instead of
the build directory, so the first cannot be found and all of them conflict
with any other build going on in any other directory.  (And I didn't even
know build was a noun.)

The most noticeably change this week was that some of the old new
completion variables have turned into bits of the associative array
compconfig.  In particular, $COMPDUMP has gone.  You can now specify it as
an argument to compinit:  source ~/..../compinit -d mydumpfile

There is a patch which is supposed to help with systems that clobber
typeahead when the typeahead extends onto lines read with $PS2 (the PS2
wasn't the problem, it just happened that when reading lines after the
first the terminal mode was altered too often).  I don't know if this
works, and I'd like to hear.  There may be some other unnecessary terminal
handling which is still making life difficult.

Here is the list of changees included.


Sven: 5670: parameter completion fix

Sven: 5671: another small parameter fix for multiple braces

Sven: 5675: tidying up for zle_tricky.c

pws: from autoconf 2.13: new config.guess, too.

Sven: 5676: all Completion example functions return a status

Sven: 5677, 5679: Completion/User/_long_options and consequent upgrades for
Completion/User files which use long GNU-style options.

Sven: 5682: bindkey fix

Sven: 5692: remove compstate[matcher] test from _long_options

Sven: 5696, 5697: "${${path}[1]}" indexes on characters again

Sven: 5698: array indexing in _long_options and _multi_parts

Sven: 5699: matching prefixes of various sorts

Sven: 5701: _main_complete, _multi_parts, _path_files, a few cosmetic
changes.

Sven: 5704: _long_options

Sven: 5707: tokenization changes

Sven: 5708: completion manual, -M anchors must be matched explicitly

Sven: 5710: zle_tricky.c, completion inside words

Sven: 5712: _path_files, noglobcomplete fix

Sven: 5713: zle_tricky.c, interesting code specimen made extinct

Sven: 5714: _path_files: failed completions get left alone more often

Sven: 5716: zle.h, zle_misc.c, zle_tricky.c: iremovesuffix() can be told
whether to keep a list of matches

Andrej: 5719: _bindkey can use - as anchor for wildcard matching

Will Day: 5724 (+postprocessing, 5741): signames2.awk: match extra spaces
if produced by CPP.

Sven: 5726: zle_tricky.c: ctokenize() fix and parameter completion

pws: 5729: _bindkey doc

Sven: 5732: _a2ps, _long_options

Sven: 5736: completion before = in assignment

pws: 5737: ${foo#* } is more efficient in ordinary cases

Sven: zsh-users/2211 (+ p -> s): setopt -m handles underscores and case
sensitivity

Lehti Rami: 5754: --disable-restricted-r stops the shell becoming
restricted when its name starts with r

Sven: 5756: compstate[force_list]

Sven: 5757: compconfig

Sven: 5758: _path_files accepts -q, -r and -R options

pws: www archive: updated Etc/FAQ finally, keep forgetting

Sven: 5759: math environment fixes

Sven: 5761: remove unnecessary compiler warnings in compctl.c

Sven: 5766: _path_files closer to compctl/compgen behaviour

Sven: 5770: _path_files again

Sven: 5775: correcting completion will not ignore everything the user has
typed; prefix quote fix

pws: 5776: untested patch for typeahead problems when reading multiple
lines of input

pws: unposted archive changes: .distfiles in Completion hierarchy, dunno
what these do but it looks better; _comp_parts is now _sep_parts; moved
_long_options into Base and mentioned it in Completion/README.

Geoff: 5779: correct mistakes some bozo (guess who) made testing rlim_t for
long long.

-- 
Peter Stephenson <pws@ibmth.df.unipi.it>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy


^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: _tar uses _multi_parts
@ 1999-03-15 11:51 Sven Wischnowsky
  0 siblings, 0 replies; 9+ messages in thread
From: Sven Wischnowsky @ 1999-03-15 11:51 UTC (permalink / raw)
  To: zsh-workers


Bruce Stephens wrote:

> Presumably the fix is:
> !   _multi_parts / _tar_cache_list
> !   _sep_parts / _tar_cache_list

Nay! It was just that `_multi_parts' somehow got omitted from the
distribution.


Bye
 Sven

diff -u Completion/Core/_multi_parts Completion/Core/_multi_parts
--- Completion/Core/_multi_parts	Mon Mar 15 12:49:22 1999
+++ Completion/Core/_multi_parts	Mon Mar 15 12:49:41 1999
@@ -0,0 +1,226 @@
+#autoload
+
+# This gets two arguments, a separator (which should be only one
+# character) and an array. As usual, the array may be given by it's
+# name or literal as in `(foo bar baz)' (words separated by spaces in
+# parentheses).
+# The parts of words from the array that are separated by the
+# separator character are then completed independently.
+
+local sep matches patstr orig matchflags pref i tmp1 tmp2 nm
+local group expl menu origflags mflags
+
+_match_test _multi_parts || return 1
+
+# Save the current number of matches to be able to return if we added
+# matches or not.
+
+nm=$compstate[nmatches]
+
+# Get the options.
+
+group=()
+expl=()
+while getopts "J:V:X:" opt; do
+  case "$opt" in
+  [JV]) group=("-$opt" "$OPTARG");;
+  X)    expl=(-X "$OPTARG");;
+  esac
+done
+shift OPTIND-1
+
+# Get the arguments, first the separator, then the array. The array is 
+# stored in `matches'. Further on this array will always contain those 
+# words from the original array that still match everything we have
+# tried to match while we walk through the string from the line.
+
+sep="$1"
+if [[ "${2[1]}" = '(' ]]; then
+  matches=( ${2[2,-2]} )
+else
+  matches=( "${(@P)2}" )
+fi
+
+# Now build the pattern from what we have on the line. We also save
+# the original string in `orig'.
+
+if [[ $#compstate[pattern_match] -ne 0 ]]; then
+  patstr="${PREFIX}*${SUFFIX}*"
+else
+  patstr="${PREFIX:q}*${SUFFIX:q}*"
+fi
+orig="${PREFIX}${SUFFIX}"
+
+[[ $compstate[insert] = *menu || -n "$_comp_correct" ||
+   ( $#compstate[pattern_match] -ne 0 &&
+     "$orig" != "${orig:q}" ) ]] && menu=yes
+
+matchflags=""
+_match_pattern _path_files patstr matchflags
+origflags="$matchflags"
+[[ -n "$_comp_correct" ]] && matchflags="$matchflags(#a$_comp_correct)"
+
+patstr="${${patstr//$sep/*$sep}//\*##/*}"
+
+# First we will skip over those parts of the matches for which we have 
+# exact substrings on the line. In `pref' we will build the
+# unambiguous prefix string.
+
+pref=''
+while [[ "$orig" = *${sep}* ]] do
+
+  # First build the pattern to use, then collect all strings from
+  # `matches' that match the prefix we have and the exact substring in 
+  # the array `tmp1'.
+
+  if [[ -n "$_comp_correct" && "${#orig%%${sep}*}" -le _comp_correct ]]; then
+    mflags="$origflags"
+  else
+    mflags="$matchflags"
+  fi
+
+  pat="${${${patstr#*${sep}}%${sep}*}//\*/[^${sep}]#}"
+  tmp1=( "${(@M)matches:#${~mflags}${orig%%${sep}*}${sep}${~pat}}" )
+
+  # If there are no words matching the exact substring, stop.
+
+  (( $#tmp1 )) || break
+
+  # Otherwise add the part to the prefix, remove it from the matches
+  # (and also remove all words not matching the string at all), and
+  # set `patstr' and `orig' to the next component.
+
+  tmp1="${orig%%${sep}*}${sep}"
+  pref="$pref$tmp1"
+  matches=("${(@)${(@)${(@M)matches:#${tmp1}*}#$tmp1}:#}")
+  orig="${orig#*${sep}}"
+  patstr="${patstr#*${sep}}"
+done
+
+# Now we get all the words that still match in `tmp1'.
+
+if [[ "$patstr" = *${sep}* ]]; then
+  tmp1="${patstr%${sep}*}${sep}"
+  pat="${tmp1//\*/[^${sep}]#}${patstr##*${sep}}"
+else
+  pat="$patstr"
+fi
+if [[ -n "$_comp_correct" && "${#orig%%${sep}*}" -le _comp_correct ]]; then
+  mflags="$origflags"
+else
+  mflags="$matchflags"
+fi
+tmp1=( "${(@M)matches:#${~mflags}${~pat}}" )
+
+if (( $#tmp1 )); then
+
+  # There are words that are matched, put them into `matches' and then
+  # move all unambiguous components from the beginning into `pref'.
+
+  matches=( "$tmp1[@]" )
+  while [[ "$matches[1]" = *${sep}* ]]; do
+
+    # We just take the first component of the first match and see if
+    # there are other matches with a different prefix (these are
+    # collected in `tmp2'). If there are any, we give up.
+
+    tmp1="${matches[1]%%${sep}*}${sep}"
+    tmp2=( "${(@)matches:#${tmp1}*}" )
+    (( $#tmp2 )) && break
+
+    # All matches have the same prefix, put it into `pref' and remove
+    # it from the matches.
+
+    pref="$pref$tmp1"
+    matches=( "${(@)${(@)matches#$tmp1}:#}" )
+
+    if [[ "$orig" = *${sep}* ]]; then
+      orig="${orig#*${sep}}"
+    else
+      orig=''
+    fi
+  done
+
+  # Now we can tell the completion code about the things we
+  # found. Strings that have a separator will be added with a suffix.
+
+  if [[ -z "$orig" && "$PREFIX$SUFFIX" != "$pref$orig" ]]; then
+    compadd -QU  "$group[@]" "$expl[@]" -i "$IPREFIX" -S '' - "${pref}${orig}"
+  elif [[ -n "$menu" ]]; then
+    if [[ "$orig" = *${sep}* ]]; then
+      orig="${sep}${orig#*${sep}}"
+    else
+      orig=''
+    fi
+    for i in "$matches[@]" ; do
+      if [[ "$i" = *${sep}* ]]; then
+        compadd -U "$group[@]" "$expl[@]" -i "$IPREFIX" \
+	        -p "$pref" -s "$orig" - "${i%%${sep}*}${sep}"
+      else
+        compadd -U "$group[@]" "$expl[@]" -i "$IPREFIX" \
+	        -p "$pref" -s "$orig" - "${i%%${sep}*}"
+      fi
+    done
+  else
+    for i in "$matches[@]" ; do
+      if [[ "$i" = *${sep}* ]]; then
+        compadd -U -i "$IPREFIX" -p "$pref" -s "${i#*${sep}}" \
+	        "$group[@]" "$expl[@]" -M "r:|${sep:q}=*" - "${i%%${sep}*}${sep}"
+      else
+        compadd -U "$group[@]" "$expl[@]" -i "$IPREFIX" -p "$pref" - "$i"
+      fi
+    done
+  fi
+elif [[ "$patstr" = *${sep}* ]]; then
+
+  # We had no words matching the string from the line. But we want to
+  # be friendly and at least expand the prefix as far as we can. So we 
+  # will loop through the rest of the string from the line and test
+  # the components one by one.
+
+  while [[ "$patstr" = *${sep}* ]]; do
+
+    # First we get all words matching at least this component in
+    # `tmp1'. If there are none, we give up.
+
+    if [[ -n "$_comp_correct" && "${#orig%%${sep}*}" -le _comp_correct ]]; then
+      mflags="$origflags"
+    else
+      mflags="$matchflags"
+    fi
+    tmp1=( "${(@M)matches:#${~mflags}${~patstr%%${sep}*}${sep}*}" )
+    (( $#tmp1 )) || break
+
+    # Then we check if there are words that have a different prefix.
+
+    tmp2=( "${(@)tmp1:#${tmp1[1]%%${sep}*}${sep}*}" )
+    if (( $#tmp2 )); then
+
+      # There are words with another prefix, so we have found an
+      # ambiguous component. So we just give all possible prefixes to
+      # the completion code together with our prefix and the rest of
+      # the string from the line as the suffix.
+
+      compadd -U "$group[@]" "$expl[@]" -S '' -i "$IPREFIX" -p "$pref" \
+              -s "${sep}${orig#*${sep}}" - "${(@)matches%%${sep}*}"
+      return 0
+    fi
+
+    # All words have the same prefix, so add it to `pref' again and
+    # try the next component.
+
+    pref="$pref${tmp1[1]%%${sep}*}${sep}"
+    matches=( "${(@)matches#${tmp1[1]%%${sep}*}${sep}}" )
+    orig="${orig#*${sep}}"
+    patstr="${patstr#*${sep}}"
+  done
+
+  # Finally, add the unambiguous prefix and the rest of the string
+  # from the line.
+
+  compadd -U "$group[@]" "$expl[@]" -S '' -i "$IPREFIX" -p "$pref" - "$orig"
+fi
+
+# This sets the return value to indicate that we added matches (or not).
+
+[[ nm -ne compstate[nmatches] ]]

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~1999-03-15 11:51 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-03-13 15:00 pws-12 Peter Stephenson
1999-03-14  5:04 ` BUG: 3.1.5-pws-11 completion coredumps Geoff Wing
1999-03-14  6:14   ` Bart Schaefer
1999-03-14  7:15     ` Geoff Wing
1999-03-15  7:39 ` pws-12 Andrej Borsenkow
1999-03-15 10:52 ` _pdf needs updating Bruce Stephens
1999-03-15 11:24 ` pws-12 Peter Stephenson
1999-03-15 11:42 ` _tar uses _multi_parts Bruce Stephens
1999-03-15 11:51 Sven Wischnowsky

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).