From e5ddd5b62f794e262119053c367ab66eca678475 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Fri, 3 Dec 2010 17:24:40 +0000 Subject: 28468: allow man page completion for files when / is present --- ChangeLog | 8 +++++++- Completion/Unix/Command/_man | 16 ++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 29a53c156..42f090136 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-12-03 Peter Stephenson + + * 28468: Completion/Unix/Command/_man: if argument contains a + "/", complete file instead of manual page reference; prefer + files with man suffixes. + 2010-11-30 Peter Stephenson * unposted: NEWS: add news about ${NAME:OFFSET} and took the @@ -13872,5 +13878,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5132 $ +* $Revision: 1.5133 $ ***************************************************** diff --git a/Completion/Unix/Command/_man b/Completion/Unix/Command/_man index a3a4d4796..d1346f7cc 100644 --- a/Completion/Unix/Command/_man +++ b/Completion/Unix/Command/_man @@ -86,6 +86,18 @@ _man() { _man_pages() { local matcher pages dummy sopt + # What files corresponding to manual pages can end in. + local suf='.((?|<->*)(|.gz|.bz2|.Z|.lzma))' + + if [[ $PREFIX$SUFFIX = */* ]]; then + # Easy way to test for versions of man that allow file names. + # This can't be a normal man page reference. + # Try to complete by glob first. + _path_files -g "*$suf" && return + _path_files + return + fi + zparseopts -E M+:=matcher if (( $#matcher )); then @@ -109,9 +121,9 @@ _man_pages() { if ((CURRENT > 2)) || ! zstyle -t ":completion:${curcontext}:manuals.$sect" insert-sections then - compadd "$@" - ${pages%.((?|<->*)(|.gz|.bz2|.Z|.lzma))} + compadd "$@" - ${pages%$~suf} else - compadd "$@" -P "$sopt$sect " - ${pages%.((?|<->*)(|.gz|.bz2|.Z|.lzma))} + compadd "$@" -P "$sopt$sect " - ${pages%$~suf} fi } -- cgit 1.4.1