Mercurial > emacs
annotate lisp/pcmpl-cvs.el @ 102538:d1b49e289bbf
m-v corrections.
author | Deepak Goel <deego@gnufans.org> |
---|---|
date | Fri, 13 Mar 2009 20:33:27 +0000 |
parents | a9dc0e7c3f2b |
children | 1d1d5d9bd884 |
rev | line source |
---|---|
38414
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
29959
diff
changeset
|
1 ;;; pcmpl-cvs.el --- functions for dealing with cvs completions |
29959 | 2 |
74442 | 3 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, |
100908 | 4 ;; 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. |
46081
e0672852f9dd
Added my name as the maintainer of this file.
John Wiegley <johnw@newartisans.com>
parents:
38414
diff
changeset
|
5 |
e0672852f9dd
Added my name as the maintainer of this file.
John Wiegley <johnw@newartisans.com>
parents:
38414
diff
changeset
|
6 ;; Author: John Wiegley <johnw@gnu.org> |
29959 | 7 |
8 ;; This file is part of GNU Emacs. | |
9 | |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
10 ;; GNU Emacs is free software: you can redistribute it and/or modify |
29959 | 11 ;; it under the terms of the GNU General Public License as published by |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
12 ;; the Free Software Foundation, either version 3 of the License, or |
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
13 ;; (at your option) any later version. |
29959 | 14 |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
29959 | 22 |
23 ;;; Commentary: | |
24 | |
25 ;; These functions provide completion rules for the `cvs' tool. | |
26 | |
27 ;;; Code: | |
28 | |
29 (provide 'pcmpl-cvs) | |
30 | |
31 (require 'pcomplete) | |
32 (require 'executable) | |
33 | |
34 (defgroup pcmpl-cvs nil | |
64016
a32551e9db34
(pcmpl-cvs): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents:
52401
diff
changeset
|
35 "Functions for dealing with CVS completions." |
29959 | 36 :group 'pcomplete) |
37 | |
38 ;; User Variables: | |
39 | |
40 (defcustom pcmpl-cvs-binary (or (executable-find "cvs") "cvs") | |
100171 | 41 "The full path of the 'cvs' binary." |
29959 | 42 :type 'file |
43 :group 'pcmpl-cvs) | |
44 | |
45 ;; Functions: | |
46 | |
47 ;;;###autoload | |
48 (defun pcomplete/cvs () | |
49 "Completion rules for the `cvs' command." | |
50 (let ((pcomplete-help "(cvs)Invoking CVS")) | |
51 (pcomplete-opt "HQqrwlntvfab/T/e*d/z?s") | |
52 (pcomplete-here* (pcmpl-cvs-commands)) | |
53 (cond ((pcomplete-test "add") | |
54 (setq pcomplete-help "(cvs)Adding files") | |
55 (pcomplete-opt "k?m?") | |
56 (while (pcomplete-here (pcmpl-cvs-entries '(??))))) | |
57 ((pcomplete-test "remove") | |
58 (setq pcomplete-help "(cvs)Removing files") | |
59 (pcomplete-opt "flR") | |
60 (while (pcomplete-here (pcmpl-cvs-entries '(?U))))) | |
61 ((pcomplete-test "init") | |
62 (setq pcomplete-help "(cvs)Creating a repository")) | |
63 ((pcomplete-test '("login" "logout")) | |
64 (setq pcomplete-help "(cvs)Password authentication client")) | |
65 ((pcomplete-test "import") | |
66 (setq pcomplete-help "(cvs)import") | |
67 (pcomplete-opt "dk?I(pcmpl-cvs-entries '(??))b?m?W?")) | |
68 ((pcomplete-test "checkout") | |
69 (setq pcomplete-help "(cvs)checkout") | |
70 (pcomplete-opt "ANPRcflnpsr?D?d/k?j?") | |
71 (pcomplete-here (pcmpl-cvs-modules))) | |
72 ((pcomplete-test "rtag") | |
73 (setq pcomplete-help "(cvs)Creating a branch") | |
74 (pcomplete-opt "aflRndbr?DF") | |
75 (pcomplete-here (pcmpl-cvs-modules))) | |
76 ((pcomplete-test "release") | |
77 (setq pcomplete-help "(cvs)release") | |
78 (pcomplete-opt "d") | |
79 (while (pcomplete-here (pcomplete-dirs)))) | |
80 ((pcomplete-test "export") | |
81 (setq pcomplete-help "(cvs)export") | |
82 (pcomplete-opt "NflRnr?D?d/k?") | |
83 (pcomplete-here (pcmpl-cvs-modules))) | |
84 ((pcomplete-test "commit") | |
85 (setq pcomplete-help "(cvs)commit files") | |
86 (pcomplete-opt "nRlfF.m?r(pcmpl-cvs-tags '(?M ?R ?A))") | |
87 (while (pcomplete-here (pcmpl-cvs-entries '(?M ?R ?A))))) | |
88 ((pcomplete-test "diff") | |
89 (setq pcomplete-help "(cvs)Viewing differences") | |
90 (let ((opt-index pcomplete-index) | |
91 saw-backdate) | |
92 (pcomplete-opt "lRD?Nr(pcmpl-cvs-tags)") | |
93 (while (< opt-index pcomplete-index) | |
94 (if (pcomplete-match "^-[Dr]" (- pcomplete-index opt-index)) | |
95 (setq saw-backdate t opt-index pcomplete-index) | |
96 (setq opt-index (1+ opt-index)))) | |
97 (while (pcomplete-here | |
98 (pcmpl-cvs-entries (unless saw-backdate '(?M))))))) | |
99 ((pcomplete-test "unedit") | |
100 (setq pcomplete-help "(cvs)Editing files") | |
101 (pcomplete-opt "lR") | |
102 (while (pcomplete-here (pcmpl-cvs-entries '(?M ?R ?A))))) | |
103 ((pcomplete-test "update") | |
104 (setq pcomplete-help "(cvs)update") | |
105 (pcomplete-opt | |
106 (concat "APdflRpk?r(pcmpl-cvs-tags '(?U ?P))D?" | |
107 "j(pcmpl-cvs-tags '(?U ?P))" | |
108 "I(pcmpl-cvs-entries '(??))W?")) | |
109 (while (pcomplete-here (pcmpl-cvs-entries '(?U ?P))))) | |
110 (t | |
111 (while (pcomplete-here (pcmpl-cvs-entries))))))) | |
112 | |
113 (defun pcmpl-cvs-commands () | |
114 "Return a list of available CVS commands." | |
115 (with-temp-buffer | |
116 (call-process pcmpl-cvs-binary nil t nil "--help-commands") | |
117 (goto-char (point-min)) | |
118 (let (cmds) | |
119 (while (re-search-forward "^\\s-+\\([a-z]+\\)" nil t) | |
120 (setq cmds (cons (match-string 1) cmds))) | |
121 (pcomplete-uniqify-list cmds)))) | |
122 | |
123 (defun pcmpl-cvs-modules () | |
124 "Return a list of available modules under CVS." | |
125 (with-temp-buffer | |
126 (call-process pcmpl-cvs-binary nil t nil "checkout" "-c") | |
127 (goto-char (point-min)) | |
128 (let (entries) | |
129 (while (re-search-forward "\\(\\S-+\\)$" nil t) | |
130 (setq entries (cons (match-string 1) entries))) | |
131 (pcomplete-uniqify-list entries)))) | |
132 | |
133 (defun pcmpl-cvs-tags (&optional opers) | |
134 "Return all the tags which could apply to the files related to OPERS." | |
135 (let ((entries (pcmpl-cvs-entries opers)) | |
136 tags) | |
137 (with-temp-buffer | |
138 (apply 'call-process pcmpl-cvs-binary nil t nil | |
139 "status" "-v" entries) | |
140 (goto-char (point-min)) | |
141 (while (re-search-forward "Existing Tags:" nil t) | |
142 (forward-line) | |
143 (while (not (looking-at "^$")) | |
144 (unless (looking-at "^\\s-+\\(\\S-+\\)\\s-+") | |
145 (error "Error in output from `cvs status -v'")) | |
146 (setq tags (cons (match-string 1) tags)) | |
147 (forward-line)))) | |
148 (pcomplete-uniqify-list tags))) | |
149 | |
150 (defun pcmpl-cvs-entries (&optional opers) | |
151 "Return the Entries for the current directory. | |
152 If OPERS is a list of characters, return entries for which that | |
153 operation character applies, as displayed by 'cvs -n update'." | |
154 (let* ((arg (pcomplete-arg)) | |
155 (dir (file-name-as-directory | |
156 (or (file-name-directory arg) ""))) | |
157 (nondir (or (file-name-nondirectory arg) "")) | |
158 entries) | |
159 (if opers | |
160 (with-temp-buffer | |
161 (and dir (cd dir)) | |
162 (call-process pcmpl-cvs-binary nil t nil | |
163 "-q" "-n" "-f" "update"); "-l") | |
164 (goto-char (point-min)) | |
165 (while (re-search-forward "^\\(.\\) \\(.+\\)$" nil t) | |
166 (if (memq (string-to-char (match-string 1)) opers) | |
167 (setq entries (cons (match-string 2) entries))))) | |
168 (with-temp-buffer | |
169 (insert-file-contents (concat dir "CVS/Entries")) | |
170 (goto-char (point-min)) | |
171 (while (not (eobp)) | |
172 (let* ((line (buffer-substring (line-beginning-position) | |
173 (line-end-position))) | |
174 (fields (split-string line "/")) | |
175 text) | |
176 (if (eq (aref line 0) ?/) | |
177 (setq fields (cons "" fields))) | |
178 (setq text (nth 1 fields)) | |
179 (when text | |
180 (if (string= (nth 0 fields) "D") | |
181 (setq text (file-name-as-directory text))) | |
182 (setq entries (cons text entries)))) | |
183 (forward-line)))) | |
184 (setq pcomplete-stub nondir) | |
185 (pcomplete-uniqify-list entries))) | |
186 | |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
187 ;; arch-tag: d2aeac43-4bf5-4509-a496-74b863c6642b |
29959 | 188 ;;; pcmpl-cvs.el ends here |