Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: completion for compressed ps|pdf files for gv



Alexandre Duret-Lutz wrote:

> gv can read compressed .ps and .pdf files, and I use this
> feature every days, unfortunately Zsh was not aware of this.
> The suggested patch below adds the -z option to _ps and _pdf to
> complete compressed files and modify _gv to use it.  (This is
> also related to wich #56485 on the Debian bug tracking system.)
> 
> Question: is it really correct to suppress that `_wanted' call
> in _pspdf (since _pdf will provide the description)?

Yes, but we'll want to use the return value of _pdf, too.

I've slightly modified the patch to make _ps and _pdf use their
arguments (possible descriptions) in preference to the description
they build themselves. An I've finally changed _pspdf to call _files
directly. That's bad in term of code sharing, but _ps and _pdf aren't
really that big and, more importantly, one doesn't get funny results
anymore if there is no ps or pdf file (previously one got ps files and 
directories if there were no pdf files).

Bye
 Sven

Index: Completion/User/_gv
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/User/_gv,v
retrieving revision 1.1.1.3
diff -u -r1.1.1.3 _gv
--- Completion/User/_gv	1999/09/07 12:55:06	1.1.1.3
+++ Completion/User/_gv	2000/08/23 08:22:10
@@ -36,4 +36,4 @@
   '-scalebase:scale base:' \
   '-ad:resource file:_files' \
   '-style:resource file:_files' \
-  '*:file:_pspdf'
+  '*:file: _pspdf -z'
Index: Completion/User/_pdf
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/User/_pdf,v
retrieving revision 1.1.1.6
diff -u -r1.1.1.6 _pdf
--- Completion/User/_pdf	1999/12/01 15:29:44	1.1.1.6
+++ Completion/User/_pdf	2000/08/23 08:22:10
@@ -1,11 +1,16 @@
 #compdef acroread pdf2dsc pdf2ps pdfimages pdfinfo pdftopbm pdftops pdftotext xpdf
 
-local expl
+local expl ext=''
 
 # ghostscript:
 #  pdf2dsc pdf2ps
 # xpdf:
 #  pdfimages pdfinfo pdftopbm pdftops pdftotext xpdf
 
+if [[ "$1" == '-z' ]]; then
+  ext='(|.gz|.Z)'
+  shift
+fi
+
 _description files expl 'PDF file'
-_files "$expl[@]" -g '*.(#i)pdf'
+_files "$@" "$expl[@]" -g "*.(#i)pdf$ext"
Index: Completion/User/_ps
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/User/_ps,v
retrieving revision 1.1.1.8
diff -u -r1.1.1.8 _ps
--- Completion/User/_ps	2000/02/13 03:53:36	1.1.1.8
+++ Completion/User/_ps	2000/08/23 08:22:10
@@ -1,9 +1,14 @@
 #compdef ps2epsi ps2pdf psmulti pswrap
 
-local expl
+local expl ext=''
 
 # ghostscript:
 #  ps2epsi ps2pdf
 
-_description files expl 'postscript file'
-_files "$expl[@]" -g '*.(#i)(ps|eps)'
+if [[ "$1" == '-z' ]]; then
+  ext='(|.gz|.Z)'
+  shift
+fi
+
+_description files expl 'PostScript file'
+_files "$@" "$expl[@]" -g "*.(#i)(ps|eps)$ext"
Index: Completion/User/_pspdf
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/User/_pspdf,v
retrieving revision 1.1.1.5
diff -u -r1.1.1.5 _pspdf
--- Completion/User/_pspdf	2000/03/24 00:01:57	1.1.1.5
+++ Completion/User/_pspdf	2000/08/23 08:22:10
@@ -1,11 +1,14 @@
 #compdef gsbj gsdj gsdj500 gslj gslp gsnd ps2ascii ghostview mgv ggv pstoedit pstotgif
 
-local ret=1 expl
+local expl ext
 
 # ghostscript:
 #  gs gsbj gsdj gsdj500 gslj gslp gsnd ps2ascii
 
-_ps && ret=0
-_wanted files expl 'PDF file' _path_files -g '*.(#i)pdf'
+if [[ "$1" == '-z' ]]; then
+  ext='(|.gz|.Z)'
+  shift
+fi
 
-return ret
+_description files expl 'PostScript or PDF file'
+_files "$@" "$expl[@]" -g "*.(#i)(pdf|ps|eps)$ext"

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



Messages sorted by: Reverse Date, Date, Thread, Author