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

Re: Various completion contributions



On Sat, Jan 08, 2011 at 09:03:12PM +0000, Peter Stephenson wrote:

> On Fri, 7 Jan 2011 20:42:15 -0500 gi1242+zsh@xxxxxxxxx wrote:
>
>> I updated/modified a couple of default completion scripts, and wrote a
>> couple of new ones. I'm attaching them to this message in case they
>> would be useful. (Please let me know the "official" way to submit
>> patches / bugs, and I will do so in future).
> 
> Thanks for those.  You need to send things as "diff -u"s, preferably
> against the latest CVS or git archive,

Thanks for letting me know. I've made a couple of changes following your
suggestions, and have attached a diff this time.

>>     _tex	New completion file
> 
> There's already one in Completion/Unix/Type/_tex, so I've ignored
> this.

That only completes file types. I'd remove it and replace it with the
version attached (in Completion/Unix/Command instead).

>>     _unison	New completion file
>>     _xournal	New completion file (only completes filenames).
> 
> No idea what these are but put them in Completion/Unix/Command (again, a
> diff would have shown where it should go).

Sorry. _xournal should go in Completion/X/Command.

I did some "git trickery" to try and generate the diffs. If they don't
work, I can regenerate by hand and resend. Let me know,

Thanks,

GI

-- 
If we don't succeed, we run the risk of failure. --George W. Bush
diff --git a/Completion/Unix/Command/_lp b/Completion/Unix/Command/_lp
index e6bff64..5d46a75 100644
--- a/Completion/Unix/Command/_lp
+++ b/Completion/Unix/Command/_lp
@@ -1,7 +1,5 @@
 #compdef lp lpr lpq lprm lpoptions lpstat
 
-local expl ret=1 printer list disp strs shown
-
 _lp_get_printer()
 {
   # No reason to call _lp_get_printer when service == lpstat. Others matched
@@ -22,6 +20,7 @@ _lp_get_printer()
 
 _lp_job_options()
 {
+  local expl printer
   local -a lopts_with_args lopts_no_args
 
   # Generic options (from lp manual page)
@@ -84,6 +83,9 @@ _lp_job_options()
 
 _lp_list_jobs()
 {
+  local ret=1 printer shown
+  local -a list disp strs
+
   _lp_get_printer
   [[ -n "$printer" ]] && printer=(-P $printer)
 
@@ -125,95 +127,101 @@ _lp_list_jobs()
   return 1
 }
 
-case $service in
-  (lpq)
-    _arguments \
-      '-E[Force encryption]' \
-      '-U:username (for connection to server):_users' \
-      '-h:alternate server:_hosts' \
-      '(-a)-P+[destination printer]:printers:_printers' \
-      '(-P)-a[all printers]' \
-      '-l[long listing]' \
-      '*:poll interval (+seconds):'
-    ;;
-
-  (lprm)
-    _arguments \
-      '-E[Force encryption]' \
-      '-U:username (for connection to server):_users' \
-      '-h:alternate server:_hosts' \
-      '-P+[destination printer]:printers:_printers' \
-      '*:job ids:_lp_list_jobs'
-    ;;
-
-  (lpoptions)
-    _arguments \
-      '-E[Force encryption]' \
-      '-U:username (for connection to server):_users' \
-      '-h:alternate server:_hosts' \
-      '(-p -l -r -x)-d[set default printer]:printers:_printers' \
-      '(-l -x)*-o:job options:_lp_job_options' \
-      '(-d -x)-p[destination printer for options]:printers:_printers' \
-      '(-d -o -r -x)-l[list options]' \
-      '(-d -l -x)*-r:remove option:_lp_job_options' \
-      '(-d -l -r -o)-x[remove all options]:printers:_printers'
-    ;;
-
-  (lpstat)
-    _arguments \
-      '-E[Force encryption]' \
-      '-R[Shows print job ranking]' \
-      '-U:username (for connection to server):_users' \
-      '-W:which jobs:(completed not-completed)' \
-      '-a[Show accepting state]:printers:_printers' \
-      '-c:printer classes:' \
-      '-d[Show current default destination]' \
-      '-h:hostname (alternate server):_hosts' \
-      '-l[long listing]' \
-      '-o[destinations]:printers:_printers' \
-      '-p:printers:_printers' \
-      '-r[CUPS server running status]' \
-      '-s[Status summary]' \
-      '-t[All status info]' \
-      '-u[list jobs by users]:users:_users' \
-      '-v[show devices]:printers:_printers'
-    ;;
-
-  (lpr)
-    _arguments \
-      '-E[Force encryption]' \
-      '-H:hostname (alternate server):_hosts' \
-      '(-C -J -T)'-{C,J,T}':job name:' \
-      '-P+[destination printer]:printers:_printers' \
-      '-U:username (for connection to server):_users' \
-      '-#[Copies]:copies (1--100):' \
-      '-h[Disables banner printing]' \
-      '-l[raw file]' \
-      '-m[Send an email on job completion]' \
-      '*-o:print job options:_lp_job_options' \
-      '-p[format with shaded header incl. date, time etc.]' \
-      '-q[Hold job for printing.]' \
-      '-r[delete files after printing]' \
-      '*:PS/PDF files:_pspdf'
-    ;;
-
-  (lp)
-    _arguments \
-      '-E[Force encryption]' \
-      '-U[username (for connection to server)]:username:_users' \
-      '-c[(OBSOLETE) copy to spool dir before printing]' \
-      '-d[destination printer]:printers:_printers' \
-      '-h:hostname (alternate server):_hosts' \
-      '-i[job id to modify]:job id:' \
-      '-m[Send an email on job completion]' \
-      '-n[Copies]:copies (1--100):' \
-      '*-o:print job options:_lp_job_options' \
-      '-q[Job priority -- 1 (lowest) to 100 (highest)]:priority:' \
-      '-s[Dont report resulting job IDs]' \
-      '-t[Sets the job name]:job name:' \
-      '-u[job submission username]:username:_users' \
-      '-H[Time to print]:print time (or enter hh\:mm):(hold immediate restart resume)' \
-      '-P:page range list:' \
-      '*:PS/PDF files:_pspdf'
-    ;;
-esac
+
+_lp()
+{
+  case $service in
+    (lpq)
+      _arguments \
+	'-E[Force encryption]' \
+	'-U:username (for connection to server):_users' \
+	'-h:alternate server:_hosts' \
+	'(-a)-P+[destination printer]:printers:_printers' \
+	'(-P)-a[all printers]' \
+	'-l[long listing]' \
+	'*:poll interval (+seconds):'
+      ;;
+
+    (lprm)
+      _arguments \
+	'-E[Force encryption]' \
+	'-U:username (for connection to server):_users' \
+	'-h:alternate server:_hosts' \
+	'-P+[destination printer]:printers:_printers' \
+	'*:job ids:_lp_list_jobs'
+      ;;
+
+    (lpoptions)
+      _arguments \
+	'-E[Force encryption]' \
+	'-U:username (for connection to server):_users' \
+	'-h:alternate server:_hosts' \
+	'(-p -l -r -x)-d[set default printer]:printers:_printers' \
+	'(-l -x)*-o:job options:_lp_job_options' \
+	'(-d -x)-p[destination printer for options]:printers:_printers' \
+	'(-d -o -r -x)-l[list options]' \
+	'(-d -l -x)*-r:remove option:_lp_job_options' \
+	'(-d -l -r -o)-x[remove all options]:printers:_printers'
+      ;;
+
+    (lpstat)
+      _arguments \
+	'-E[Force encryption]' \
+	'-R[Shows print job ranking]' \
+	'-U:username (for connection to server):_users' \
+	'-W:which jobs:(completed not-completed)' \
+	'-a[Show accepting state]:printers:_printers' \
+	'-c:printer classes:' \
+	'-d[Show current default destination]' \
+	'-h:hostname (alternate server):_hosts' \
+	'-l[long listing]' \
+	'-o[destinations]:printers:_printers' \
+	'-p:printers:_printers' \
+	'-r[CUPS server running status]' \
+	'-s[Status summary]' \
+	'-t[All status info]' \
+	'-u[list jobs by users]:users:_users' \
+	'-v[show devices]:printers:_printers'
+      ;;
+
+    (lpr)
+      _arguments \
+	'-E[Force encryption]' \
+	'-H:hostname (alternate server):_hosts' \
+	'(-C -J -T)'-{C,J,T}':job name:' \
+	'-P+[destination printer]:printers:_printers' \
+	'-U:username (for connection to server):_users' \
+	'-#[Copies]:copies (1--100):' \
+	'-h[Disables banner printing]' \
+	'-l[raw file]' \
+	'-m[Send an email on job completion]' \
+	'*-o:print job options:_lp_job_options' \
+	'-p[format with shaded header incl. date, time etc.]' \
+	'-q[Hold job for printing.]' \
+	'-r[delete files after printing]' \
+	'*:PS/PDF files:_pspdf'
+      ;;
+
+    (lp)
+      _arguments \
+	'-E[Force encryption]' \
+	'-U[username (for connection to server)]:username:_users' \
+	'-c[(OBSOLETE) copy to spool dir before printing]' \
+	'-d[destination printer]:printers:_printers' \
+	'-h:hostname (alternate server):_hosts' \
+	'-i[job id to modify]:job id:' \
+	'-m[Send an email on job completion]' \
+	'-n[Copies]:copies (1--100):' \
+	'*-o:print job options:_lp_job_options' \
+	'-q[Job priority -- 1 (lowest) to 100 (highest)]:priority:' \
+	'-s[Dont report resulting job IDs]' \
+	'-t[Sets the job name]:job name:' \
+	'-u[job submission username]:username:_users' \
+	'-H[Time to print]:print time (or enter hh\:mm):(hold immediate restart resume)' \
+	'-P:page range list:' \
+	'*:PS/PDF files:_pspdf'
+      ;;
+  esac
+}
+
+_lp "$@"
diff --git a/Completion/Unix/Command/_xournal b/Completion/Unix/Command/_xournal
deleted file mode 100644
index 066ef55..0000000
--- a/Completion/Unix/Command/_xournal
+++ /dev/null
@@ -1,6 +0,0 @@
-#compdef xournal
-
-local expl
-
-_description files expl 'PDF and Xournal files'
-_files "$@" "$expl[@]" -g '*.(#i){xoj,pdf}(-.)'
diff --git a/Completion/Unix/Type/_tex b/Completion/Unix/Type/_tex
deleted file mode 100644
index 3c16dca..0000000
--- a/Completion/Unix/Type/_tex
+++ /dev/null
@@ -1,6 +0,0 @@
-#compdef tex latex slitex pdflatex jadetex pdfjadetex xetex=tex xelatex=latex latexmk
-
-local expl
-
-_description files expl 'TeX or LaTeX file'
-_files "$@" "$expl[@]" -g '*.(tex|TEX|texinfo|texi)(-.)'
diff --git a/Completion/Unix/Command/_tex b/Completion/Unix/Command/_tex
new file mode 100644
index 0000000..9943fe1
--- /dev/null
+++ b/Completion/Unix/Command/_tex
@@ -0,0 +1,29 @@
+#compdef tex latex slitex pdftex pdflatex jadetex pdfjadetex xetex=tex xelatex=latex latexmk
+
+_arguments : \
+    '-enc[enable encTeX extensions]' \
+    '(-no-file-line-error -file-line-error)'{-no,}'-file-line-error[enable/disable file\:line\:error style messages]' \
+    '-fmt=-[use FMTNAME instead of program name or a %& line]:FMTNAME:' \
+    '-halt-on-error[stop processing at the first error]' \
+    '-ini[be initex, for dumping formats]' \
+    '-interaction[set interaction mode]:STRING:(batchmode nonstopmode  scrollmode errorstopmode)' \
+    '-ipc[send DVI output to a socket as well as the usual output file]' \
+    '-ipc-start[as -ipc, and also start the server at the other end]' \
+    '-jobname=-[set the job name]:STRING:' \
+    '-kpathsea-debug=-[set path searching debugging flags according to the bits of NUMBER]:NUMBER:' \
+    '(-no-mktex -mktex)'{-no,}'-mktex=-[enable/disable mktexFMT generation]:FMT:(tex tfm)' \
+    '-mltex[enable MLTeX extensions]' \
+    '-output-comment=-[DVI file comment]:STRING:' \
+    '-output-directory=-[directory to write files to]:DIR:' \
+    '(-no-parse-first-line -parse-first-line)'{-no,}'-parse-first-line[disable/enable parsing of the first line of the input file]' \
+    '-progname=-[set program (and fmt) name]:STRING:' \
+    '-recorder[enable filename recorder]' \
+    '(-no-shell-escape -shell-escape)'{-no,}-shell-escape'[enable/disable \\write18{SHELL COMMAND}]' \
+    '-shell-restricted[enable restricted \\write18]' \
+    '-src-specials[insert source specials into the DVI file]' \
+    '-src-specials=-[insert source specials in certain places of the DVI file]:WHERE:_values -s , WHERE cr display hbox math par parend vbox' \
+    '-translate-file=-[use the TCX file TCXNAME]:TCXNAME:' \
+    '-8bit[make all characters printable by default]' \
+    '-help[display this help and exit]' \
+    '-version[output version information and exit]' \
+    '*:TeX or LaTeX file:_files -g "*.(tex|TEX|texinfo|texi)(-.)"'
diff --git a/Completion/X/Command/_xournal b/Completion/X/Command/_xournal
new file mode 100644
index 0000000..066ef55
--- /dev/null
+++ b/Completion/X/Command/_xournal
@@ -0,0 +1,6 @@
+#compdef xournal
+
+local expl
+
+_description files expl 'PDF and Xournal files'
+_files "$@" "$expl[@]" -g '*.(#i){xoj,pdf}(-.)'


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