zsh-workers
 help / color / mirror / code / Atom feed
* man page completion (was Re: Few newbie questions..)
       [not found] <20010817173924.73063.qmail@web20304.mail.yahoo.com>
@ 2001-08-21 10:08 ` Oliver Kiddle
  2002-01-10 10:56   ` Sven Wischnowsky
  0 siblings, 1 reply; 2+ messages in thread
From: Oliver Kiddle @ 2001-08-21 10:08 UTC (permalink / raw)
  To: zsh-workers; +Cc: Jukka Lehti

Jukka Lehti wrote:
> 
> When I type for example 'man local' and hit tab
> I can choose from:
> 
> locale.1 locale.3 locale.7
> 
> I prefer the man completion to show me the section
> numbers (although I have remove the number before
> pressing enter since man can't find e.g. locale.1).

Having the section number visible is a useful idea which I'd also like.
Putting it in the actual match is not ideal though. It would be better
to have the section number in a description or to group different
sections separately under different headings.

I expect some people would prefer not to have this separate grouping.
`zstyle ':completion:*:man.*' group-name manual' might group them all
together but you would then still get separate headings for each group
and I'm not sure if it is possible to replace them with one. It would
also allow other things like use of the tag-order style.

To get this working, it needs something like this:
  sects=( ${pages:e} )
  typeset -U $sects
  for sect in $sects; do
    _wanted "man.$sect" expl "manual page, section $sect" \
        compadd "$@" - ${${(M)pages:#*.${sect}}%.(?|<->*)}
  done

Bart Wrote:
> On Aug 18, 11:00pm, Peter Stephenson wrote:
> } Probably _man_pages and a few others should get the treatment meted out
> } to helper functions in _cvs, namely defining the function only if
> } $functions[_man_pages] is not defined.
> 
> Actually, I don't like the treatment of the functions in _cvs.  It makes
> it very difficult to reload the entire file, which I have occasionally
> wanted to do.

Yes, it can be a nuisance to reload the completion functions which
define other functions. I don't see why it is necessary with _man as
_man_pages is called once, as the last line in _man. The _wanted could
be used directly on compadd.

Oliver

_____________________________________________________________________
This message has been checked for all known viruses by the 
MessageLabs Virus Scanning Service. For further information visit
http://www.messagelabs.com/stats.asp


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

* Re: man page completion (was Re: Few newbie questions..)
  2001-08-21 10:08 ` man page completion (was Re: Few newbie questions..) Oliver Kiddle
@ 2002-01-10 10:56   ` Sven Wischnowsky
  0 siblings, 0 replies; 2+ messages in thread
From: Sven Wischnowsky @ 2002-01-10 10:56 UTC (permalink / raw)
  To: zsh-workers


Ages ago, Oliver Kiddle wrote:

> ...
> 
> Having the section number visible is a useful idea which I'd also like.
> Putting it in the actual match is not ideal though. It would be better
> to have the section number in a description or to group different
> sections separately under different headings.
> 
> I expect some people would prefer not to have this separate grouping.
> `zstyle ':completion:*:man.*' group-name manual' might group them all
> together but you would then still get separate headings for each group
> and I'm not sure if it is possible to replace them with one. It would
> also allow other things like use of the tag-order style.

I seem to have missed this, otherwise I'd have implemented it.  Here
is a patch, using a new style `separate-sections' to select if the
sections should be added separately at all. Defaults to `false' for
backward compatibility. Hence I'm going to commit this.

Bye
  Sven

Index: Completion/Unix/Command/_man
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_man,v
retrieving revision 1.4
diff -u -r1.4 _man
--- Completion/Unix/Command/_man	2001/08/21 18:06:25	1.4
+++ Completion/Unix/Command/_man	2002/01/10 10:54:52
@@ -40,8 +40,28 @@
     dirs=( $^manpath/(sman|man|cat)*/ )
     awk='{print $1}'
   fi
+  if zstyle -t ":completion:${curcontext}:manuals" separate-sections; then
+    typeset -U sects
+    local ret=1
 
-  _wanted manuals expl 'manual page' _man_pages
+    sects=( ${(o)${dirs##*(man|cat)}%/} )
+
+    (( $#sects )) || return 1
+
+    _tags manuals.${^sects}
+    while _tags; do
+      for sect in $sects; do
+        _requested manuals.$sect expl "manual page, section $sect" _man_pages &&
+            ret=0
+      done
+      (( ret )) || return 0
+    done
+
+    return 1
+  else
+    sect=
+    _wanted manuals expl 'manual page' _man_pages
+  fi
 }
 
 _man_pages() {
@@ -56,7 +76,7 @@
     matcher=
   fi
 
-  pages=( $dirs )
+  pages=( ${(M)dirs:#*$sect/} )
   compfiles -p pages '' '' "$matcher" '' dummy '*'
   pages=( ${^~pages}(N:t:r) )
 
Index: Completion/Zsh/Command/_zstyle
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Zsh/Command/_zstyle,v
retrieving revision 1.5
diff -u -r1.5 _zstyle
--- Completion/Zsh/Command/_zstyle	2002/01/04 12:09:31	1.5
+++ Completion/Zsh/Command/_zstyle	2002/01/10 10:54:53
@@ -100,6 +100,7 @@
   remove-all-dups	 c:bool
   select-prompt          c:
   select-scroll          c:
+  separate-sections      c:bool
   single-ignored         c:single-ignored
   sort			 c:bool
   special-dirs		 c:sdirs
Index: Doc/Zsh/compsys.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compsys.yo,v
retrieving revision 1.138
diff -u -r1.138 compsys.yo
--- Doc/Zsh/compsys.yo	2002/01/04 12:09:31	1.138
+++ Doc/Zsh/compsys.yo	2002/01/10 10:54:53
@@ -1971,6 +1971,15 @@
 that number (or plus the number, since it is negative).  The default is to
 scroll by single lines.
 )
+kindex(separate-sections, completion style)
+item(tt(separate-sections))(
+This style is used with the tt(manuals) tag when completing names of
+manual pages.  If it is `true', entries for different sections are
+added separately using tag names of the form `tt(manual.)var(X)',
+where var(X) is the section number.  This means that it is possible to
+make pages from different sections be listed separately by setting the
+tt(group-name) style.  The default for this style is `false'.
+)
 kindex(single-ignored, completion style)
 item(tt(single-ignored))(
 This is used by the tt(_ignored) completer.  It specifies what

-- 
Sven Wischnowsky                           wischnow@berkom.de


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

end of thread, other threads:[~2002-01-10 10:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20010817173924.73063.qmail@web20304.mail.yahoo.com>
2001-08-21 10:08 ` man page completion (was Re: Few newbie questions..) Oliver Kiddle
2002-01-10 10: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).