Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: _diff (new), _prcs (upgrade)
- X-seq: zsh-workers 9436
- From: Alexandre Duret-Lutz <duret_g@xxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxxx
- Subject: PATCH: _diff (new), _prcs (upgrade)
- Date: 27 Jan 2000 15:52:23 +0100
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
Here is a diff completion fonction. I have separated _diff_options
(complete options) from _diff (also complete filenames), so that
completion functions like _prcs may use only _diff_options.
Index: Completion/User/_prcs
--- Completion/User/_prcs Mon, 24 Jan 2000 13:13:23 +0100 Alexandre
+++ Completion/User/_prcs Thu, 27 Jan 2000 15:39:51 +0100 Alexandre
@@ -65,6 +65,7 @@
compress\:"instruct PRCS to save disk space for project"
init\:"create a repository entry"
pdelete\:"delete a repository entry"
+ pinfo\:"list all projects in the repository"
prename\:"rename a repository entry"
rebuild\:"reconstruct PRCS data files in the repository"
uncompress\:"instruct PRCS to save time in processing project"))'
@@ -75,6 +76,9 @@
access|compress|init|pdelete|prename|rebuild)
_prcs_arguments ':project name:_prcs_projects'
;;
+ pinfo)
+ _prcs_arguments
+ ;;
uncompress)
_prcs_arguments \
'-i[expand the entire project immediately]' \
@@ -120,11 +124,6 @@
'*:file or directory:_files'
;;
diff)
-#
-# FIXME: when there will be a _diff completion function,
-# we should complete with diff options after `--' :
-# prcs diff [OPTION ...] [PROJECT [FILE-OR-DIR ...]] [-- [DIFF-OPTION ...]]
-#
_prcs_arguments \
'*--revison=[version of the project]:revision:' \
'*-r[version of the project]:revision:' \
@@ -134,6 +133,7 @@
'(--new)-N[compare new files against empty files]' \
"(-P)--exclude-project-file[don't diff the project file]" \
"(--exclude-project-file)-P[don't diff the project file]" \
+ '--[introduce diff options]:*:diff options: _diff_options' \
':project name:_prcs_projects' \
'*:file or directory:_files'
;;
Index: Completion/User/_diff_options
--- Completion/User/_diff_options Thu, 27 Jan 2000 15:51:05 +0100 Alexandre
+++ Completion/User/_diff_options Thu, 27 Jan 2000 15:38:01 +0100 Alexandre
@@ -0,0 +1,127 @@
+#autoload
+
+local of ofwuc ouc oss ofwy ofwg ofwl
+
+(( $+_diff_is_gnu )) || {
+ _diff_is_gnu=0;
+ [[ $(diff -v </dev/null) == *GNU* ]] && _diff_is_gnu=1
+}
+
+if (( _diff_is_gnu ))
+then
+ # output formats
+ of="-y --side-by-side -n --rcs -e -f --ed -q --brief -c -C --context -u -U \
+ --unified --old-group-format --new-group-format --changed-group-format \
+ --unchanged-group-format --line-format --old-line-format --new-line-format \
+ --changed-line-format"
+
+ # output formats w/o unified and context
+ ofwuc="-y --side-by-side -n --rcs -e -f --ed -q --brief --old-group-format \
+ --new-group-format --changed-group-format --unchanged-group-format \
+ --line-format --old-line-format --new-line-format --changed-line-format"
+
+ # option specific to unified or context diff
+ ouc='-L --label -p --show-c-function -F --show-function-line'
+
+ # option specific to side by side
+ oss='-W --width --left-column --suppress-common-lines'
+
+ # output formats w/o side by side
+ ofwy="-n --rcs -e -f --ed -q --brief -c -C --context -u -U --unified \
+ --old-group-format --new-group-format --changed-group-format \
+ --unchanged-group-format --line-format --old-line-format \
+ --new-line-format --changed-line-format"
+
+ # output formats w/o group format
+ ofwg="-n --rcs -e -f --ed -q --brief -c -C --context -u -U --unified \
+ --line-format --old-line-format --new-line-format --changed-line-format"
+
+ # output formats w/o line format
+ ofwl="-n --rcs -e -f --ed -q --brief -c -C --context -u -U --unified \
+ --old-group-format --new-group-format --changed-group-format \
+ --unchanged-group-format"
+
+ _arguments -s \
+ '(-i)--ignore-case[case insensitive]' \
+ '(--ignore-case)-i[case insensitive]' \
+ '(-w)--ignore-all-space[ignore all white space]' \
+ '(--ignore-all-space)-w[ignore all white space]' \
+ '(-b)--ignore-space-change[ignore changes in the amount of white space]' \
+ '(--ignore-space-change)-b[ignore changes in the amount of white space]' \
+ '(-B)--ignore-blank-lines[ignore lines that are all blank]' \
+ '(--ignore-blank-lines)-B[ignore lines that are all blank]' \
+ '(-I)--ignore-matching-lines=[ignore lines that match regex]:regex:' \
+ '(--ignore-matching-lines)-I[ignore lines that match regex]:regex:' \
+ '(-a)--text[treat all files as text]' \
+ '(--text)-a[treat all files as text]' \
+ "($of $oss)--context=[context diff]::# lines of copied context:" \
+ "($of $oss)-C[output a context diff]:# lines of copied context:" \
+ "($of $oss)-c[output a context diff]" \
+ "($of $oss)--unified=[output a unified diff]::# lines of unified context:" \
+ "($of $oss)-U[output a unified diff]:# lines of unified context:" \
+ "($of $oss)-u[output a unified diff]" \
+ "($ofwuc $oss -L)--label[set label to use instead of file name]:label:" \
+ "($ofwuc $oss --label)-L[set label to use instead of file name]:label:" \
+ "($ofwuc $oss -p)--show-c-function[show C function of each change]" \
+ "($ofwuc $oss --show-c-function)-p[show C function of each change]" \
+ "($ofwuc $oss -F)--show-function-line=[show the most recent line matching regex]:regex:" \
+ "($ofwuc $oss --show-function-line)-F[show the most recent line matching regex]:regex:" \
+ "($of $ouc $oss)--brief[output only whether files differ]" \
+ "($of $ouc $oss)-q[output only whether files differ]" \
+ "($of $ouc $oss)--ed[output an ed script]" \
+ "($of $ouc $oss)-f[output a reversed ed script]" \
+ "($of $ouc $oss)-e[output an ed script]" \
+ "($of $ouc $oss)--rcs[RCS format diff]" \
+ "($of $ouc $oss)-n[RCS format diff]" \
+ "($of $ouc)--side-by-side[output in two columns]" \
+ "($of $ouc)-y[output in two columns]" \
+ "($ofwy $ouc -W)--width[set size of line]:# characters per line:" \
+ "($ofwy $ouc --width)-W[set size of line]:# characters per line:" \
+ "($ofwy $ouc)--left-column[output only left column of common lines]" \
+ "($ofwy $ouc)--suppress-common-lines[do not ouput commun lines]" \
+ "($ofwg $ouc $oss)--old-group-format=[set old group format]:group format:" \
+ "($ofwg $ouc $oss)--new-group-format=[set new group format]:group format:" \
+ "($ofwg $ouc $oss)--changed-group-format=[set changed group format]:group format:" \
+ "($ofwg $ouc $oss)--unchanged-group-format=[set unchanged group format]:group format:" \
+ "($ofwl $ouc $oss)--line-format=[set line format]:line format:" \
+ "($ofwl $ouc $oss)--old-line-format=[set old line format]:line format:" \
+ "($ofwl $ouc $oss)--new-line-format=[set new line format]:line format:" \
+ "($ofwl $ouc $oss)--changed-line-format=[set changed line format]:line format:" \
+ '(-l)--paginate[output through pr]' \
+ '(--paginate)-l[output through pr]' \
+ '(-t)--expand-tabs[expand tabs to spaces]' \
+ '(--expand-tabs)-t[expand tabs to spaces]' \
+ '(-T)--initial-tab[prepend a tab]' \
+ '(--initial-tab)-T[prepend a tab]' \
+ '(-r)--recursive[recursively compare subdirectories]' \
+ '(--recursive)-r[recursively compare subdirectories]' \
+ '(-N)--new-file[treat absent files as empty]' \
+ '(--new-file)-N[treat absent files as empty]' \
+ '(-P)--unidirectional-new-file[treat absent first files as empty]' \
+ '(--unidirectional-new-file)-P[treat absent first files as empty]' \
+ '(-s)--report-identical-files[report when two files are the same]' \
+ '(--report-identical-files)-s[report when two files are the same]' \
+ '(-x)--exclude=[exclude files matching pattern]:pattern:' \
+ '(--exclude)-x[exclude files matching pattern]:pattern:' \
+ '(-X)--exclude-from=[exclude files matching pattern in file]:file:_files' \
+ '(--exclude-from)-X[exclude files matching pattern in file]:file:_files' \
+ '(-S)--starting-file=[set first file in comparison]:file:_files' \
+ '(--starting-file)-S=[set first file in comparison]:file:_files' \
+ '--horizon-lines=[set number of lines to keep in prefix and suffix]:number:' \
+ '(-d)--mininal[try to find a smaler set of changes]' \
+ '(--mininal)-d[try to find a smaler set of changes]' \
+ '(-H)--speed-large-files[assume large files and many small changes]' \
+ '(--speed-large-files)-H[assume large files and many small changes]' \
+ '(--version)-v[output version info]' \
+ '(-v)--version[output version info]' \
+ '--help[help text]' \
+ $@
+else
+ _arguments \
+ "(-e -f)-c[output a context diff]" \
+ "(-c -f)-e[output an ed script]" \
+ "(-c -e)-f[output a reversed ed script]" \
+ '-b[skip trailing white spaces]' \
+ '-r[recursively compare subdirectories]' \
+ $@
+fi
Index: Completion/User/_diff
--- Completion/User/_diff Thu, 27 Jan 2000 15:51:05 +0100 Alexandre
+++ Completion/User/_diff Thu, 27 Jan 2000 15:08:15 +0100 Alexandre
@@ -0,0 +1,3 @@
+#compdef diff
+
+_diff_options ':original file:_files' ':new file:_files'
--
Alexandre Duret-Lutz
Messages sorted by:
Reverse Date,
Date,
Thread,
Author