zsh-workers
 help / color / mirror / code / Atom feed
* Size of select listing?
@ 1999-09-09 15:19 Andrej Borsenkow
  1999-09-10 15:23 ` Oliver Kiddle
  0 siblings, 1 reply; 9+ messages in thread
From: Andrej Borsenkow @ 1999-09-09 15:19 UTC (permalink / raw)
  To: ZSH workers mailing list

Running under dtterm with 24x80 size and doing

patch TAB

creates a select listing longer than screen size. At least, if I do it in a
directory with ~ 15 files.

bor@itsrm2:~%> patch
--backup                  --reverse                 -i
--backup-if-mismatch      --set-time                -l
--basename-prefix         --set-utc                 -n
--batch                   --strip                   -o
--binary                  --suffix                  -p
--context                 --unified                 -r
--directory               --use-index-line          -s
--dry-run                 --verbose                 -t
--ed                      --version                 -u
--force                   --version-control         -v
--forward                 -B                        -z
--fuzz                    -D                        Brodsky/
--get                     -E                        FM2000
--help                    -F                        ICONS/
--ifdef                   -N                        addrbook.d/
--ignore-whitespace       -R                        bin/
--input                   -S                        dead.letter
--no-backup-if-mismatch   -T                        dikz/
--normal                  -V                        fnt/
--output                  -Y                        mail/
--patch-root              -Z                        observe/
--posix                   -b                        save/
--prefix                  -c                        src/
--quiet                   -d                        test/
--quoting-style           -e                        tmp/
--reject-file             -f                        xxxx/
--remove-empty-files      -g

/andrej


^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: Completion listing of command options ( Re: Size of select listing?)
@ 1999-09-13  8:34 Sven Wischnowsky
  0 siblings, 0 replies; 9+ messages in thread
From: Sven Wischnowsky @ 1999-09-13  8:34 UTC (permalink / raw)
  To: zsh-workers


Andrej Borsenkow wrote:

> You can set option_prefix configuration key. In this case,  options will be
> generated only if anything else fails. This reduces list to "normal arguments"
> completion.
> 
> Still, I'd like to add handling of `--' as option terminator as well. We need
> some way (option?) to tell _arguments, that `--' ends option list for this
> command, so, that after `--' it won't try to complete command options any more.

  _arguments '--:*:all arguments after this one:<action>'

will make everything after a `--' be completed by `<action>'. RTM.

> You can make options and arguments be displayed in separate groups. It adds to
> readability but does not make list size smaller.

How should it.

> About `-' display - it is currently needed to distinguish between option(s) and
> argument(s). If you can make sure, that only options or only arguments are
> displayed - it could be omitted.

Why would you want it, I wonder. It's only a couple of characters
after all and only very seldom will the omission of the `-'s make the
list small enough to fit on the terminal if it didn't fit with the `-'s.

> But, if you make a patch, do make it to use a configuration key  :-)

*Definitely*, yes.

> Still,  _arguments, even with option_prefix set, behaves funnily:
> 
> patch TAB -> completes files. It's O.K.
> patch foo TAB -> again files. Still O.K.
> patch foo bar TAB - lists all options! But, patch can have only two arguments -
> so, I'd expected some message about it.

The fact that you only get options as possible matches even though you 
normally don't see them could be taken as a (strong) hint for that,
couldn't it? However, it wouldn't be hard to add either `:no more arguments:'
descriptions to the calls of `_arguments' or build this into
`_arguments'.

Bye
 Sven

P.S.: Btw, _long_options is dead.

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


^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: Completion listing of command options ( Re: Size of select listing?)
@ 1999-09-13 13:45 Sven Wischnowsky
  0 siblings, 0 replies; 9+ messages in thread
From: Sven Wischnowsky @ 1999-09-13 13:45 UTC (permalink / raw)
  To: zsh-workers


I wrote:

> Andrej Borsenkow wrote:
>
> ...
> 
> > Still,  _arguments, even with option_prefix set, behaves funnily:
> > 
> > patch TAB -> completes files. It's O.K.
> > patch foo TAB -> again files. Still O.K.
> > patch foo bar TAB - lists all options! But, patch can have only two arguments -
> > so, I'd expected some message about it.
> 
> The fact that you only get options as possible matches even though you 
> normally don't see them could be taken as a (strong) hint for that,
> couldn't it? However, it wouldn't be hard to add either `:no more arguments:'
> descriptions to the calls of `_arguments' or build this into
> `_arguments'.

This makes `_arguments' spit out a message saying `no more arguments'
in such command line positions. Is that OK for everyone?

Bye
 Sven

P.S.:   I haven't tested it with all completion function (you may have
        guessed that already ;-), but this message can also be used as a 
        measure for the quality of the uses of `_arguments' -- if it
        doesn't print the message in places where no more normal
        argument is understood by the program, the descriptions to
        `_arguments' are probably wrong.
P.P.S.: Not so long ago we were happy if TAB would complete the right
        files and things like that. Nowadays...


diff -u oldcompletion/Base/_arguments Completion/Base/_arguments
--- oldcompletion/Base/_arguments	Mon Sep 13 13:58:09 1999
+++ Completion/Base/_arguments	Mon Sep 13 15:39:19 1999
@@ -8,7 +8,7 @@
 local args rest ws cur nth def nm expl descr action opt arg tmp xor
 local single uns ret=1 aret soptseq soptseq1 sopts prefix _line odescr
 local beg optbeg argbeg nargbeg inopt inrest fromrest cmd="$words[1]"
-local matched curopt
+local matched curopt noargs
 
 # Associative arrays used to collect information about the options.
 
@@ -625,6 +625,10 @@
       fromrest=yes
       [[ -n "$inrest" ]] && opt=''
     fi
+    if [[ -z "$def" ]]; then
+      _message 'no more arguments'
+      noargs=yes
+    fi
   fi
 
   # In any case, we have to complete option names here, but we may
@@ -814,7 +818,7 @@
   # Probably add the option names.
 
   if [[ -n "$opt" &&
-        ( ( nm -eq compstate[nmatches] && -z "$aret" ) ||
+        ( ( ( nm -eq compstate[nmatches] || -n "$noargs" ) && -z "$aret" ) ||
           -z "$compconfig[option_prefix]" || 
           "$compconfig[option_prefix]" = *\!${cmd}* ||
           "$PREFIX" = [-+]* ) ]]; then


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


^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: Completion listing of command options ( Re: Size of select listing?)
@ 1999-09-14  9:56 Sven Wischnowsky
  0 siblings, 0 replies; 9+ messages in thread
From: Sven Wischnowsky @ 1999-09-14  9:56 UTC (permalink / raw)
  To: zsh-workers


I wrote:

> This makes `_arguments' spit out a message saying `no more arguments'
> in such command line positions. Is that OK for everyone?

This makes it a bit nicer:

- don't unconditionally turn on listing in `_message'
- display `no arguments' or `no more arguments' depending on whether
  the command takes normal arguments at all
- don't display the message if completing after an option (e.g. `rpm -b<TAB>')

Bye
 Sven

diff -u -r oldcompletion/Base/_arguments Completion/Base/_arguments
--- oldcompletion/Base/_arguments	Tue Sep 14 10:19:44 1999
+++ Completion/Base/_arguments	Tue Sep 14 11:43:57 1999
@@ -628,8 +628,11 @@
       [[ -n "$inrest" ]] && opt=''
     fi
     if [[ -z "$def" ]]; then
-      _message 'no more arguments'
-      noargs=yes
+      if [[ -z "$args$rest" ]]; then
+        noargs='no arguments'
+      else
+        noargs='no more arguments'
+      fi
     fi
   fi
 
@@ -651,6 +654,7 @@
 	for i in ${(s::)prefix[2,-1]%%${tmp[1][2]}*} ${tmp[1][2]}; do
 	  _options[${prefix[1]}$i]=''
 	done
+	noargs=''
 	break
       elif compset -P "$tmp[1]"; then
 
@@ -659,6 +663,7 @@
 
 	def="$dopts[$tmp[1]]"
 	opt=''
+	noargs=''
 	break
       fi
       shift 1 tmp
@@ -675,10 +680,12 @@
 	for i in ${(s::)prefix[2,-1]%%${tmp[1][2]}*} ${tmp[1][2]}; do
 	  _options[${prefix[1]}$i]=''
 	done
+	noargs=''
 	break
       elif compset -P "$tmp[1]"; then
 	def="$odopts[$tmp[1]]"
 	opt=''
+	noargs=''
 	break
       fi
       shift 1 tmp
@@ -913,6 +920,8 @@
 
   break
 done
+
+[[ -n "$noargs" ]] && _message "$noargs"
 
 [[ -n "$aret" ]] && return 300
 
diff -u -r oldcompletion/Core/_message Completion/Core/_message
--- oldcompletion/Core/_message	Tue Sep 14 09:09:07 1999
+++ Completion/Core/_message	Tue Sep 14 11:55:32 1999
@@ -10,8 +10,8 @@
     compstate[list]=list
     compstate[insert]=''
     compadd -UX "${format//\\%d/$1}" -n ''
+    compstate[force_list]=yes
   else
-    compadd -X "${format//\\%d/$1}" -n ''
+    compadd -X "${format//\\%d/$1}" -n '' && compstate[force_list]=yes
   fi
-  compstate[force_list]=yes
 fi

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


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

end of thread, other threads:[~1999-09-14  9:57 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-09-09 15:19 Size of select listing? Andrej Borsenkow
1999-09-10 15:23 ` Oliver Kiddle
1999-09-10 15:45   ` Completion listing of command options (Re: Size of select listing?) Bart Schaefer
1999-09-10 15:46   ` Size of select listing? Peter Stephenson
1999-09-10 15:54   ` Completion listing of command options ( Re: Size of select listing?) Andrej Borsenkow
1999-09-10 15:59   ` Size of select listing? Andrej Borsenkow
1999-09-13  8:34 Completion listing of command options ( Re: Size of select listing?) Sven Wischnowsky
1999-09-13 13:45 Sven Wischnowsky
1999-09-14  9:56 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).