Mercurial > emacs
comparison lisp/vc-hooks.el @ 4063:cebb261b0f10
(vc-rcs-status): Include head version number in mode line if there
are no locks.
author | Paul Eggert <eggert@twinsun.com> |
---|---|
date | Mon, 12 Jul 1993 22:04:35 +0000 |
parents | b9f3b023e5c9 |
children | d42fc10d9c96 |
comparison
equal
deleted
inserted
replaced
4062:d7f5f18ddbc5 | 4063:cebb261b0f10 |
---|---|
150 ;; force update of mode line | 150 ;; force update of mode line |
151 (set-buffer-modified-p (buffer-modified-p)) | 151 (set-buffer-modified-p (buffer-modified-p)) |
152 vc-type)) | 152 vc-type)) |
153 | 153 |
154 (defun vc-rcs-status (file) | 154 (defun vc-rcs-status (file) |
155 ;; Return string " [LOCKER:REV]" if FILE under RCS control, otherwise nil, | 155 ;; Return string for placement in modeline by `vc-mode-line'. |
156 ;; for placement in modeline by `vc-mode-line'. | 156 ;; If FILE is not registered under RCS, return nil. |
157 | 157 ;; If FILE is registered but not locked, return " REV" if there is a head |
158 ;; If FILE is not locked then return just "". If the FILE is locked | 158 ;; revision and " @@" otherwise. |
159 ;; then return *all* the locks currently set, in a single string of the | 159 ;; If FILE is locked then return all locks in a string of the |
160 ;; form " LOCKER1:REV1 LOCKER2:REV2 ...". | 160 ;; form " LOCKER1:REV1 LOCKER2:REV2 ...". |
161 | 161 |
162 ;; Algorithm: | 162 ;; Algorithm: |
163 | 163 |
164 ;; 1. Check for master file corresponding to FILE being visited. | 164 ;; 1. Check for master file corresponding to FILE being visited. |
175 | 175 |
176 ;; Limitations: | 176 ;; Limitations: |
177 | 177 |
178 ;; The output doesn't show which version you are actually looking at. | 178 ;; The output doesn't show which version you are actually looking at. |
179 ;; The modeline can get quite cluttered when there are multiple locks. | 179 ;; The modeline can get quite cluttered when there are multiple locks. |
180 ;; The head revision is probably not what you want if you've used `rcs -b'. | |
180 | 181 |
181 (let ((master (vc-name file)) | 182 (let ((master (vc-name file)) |
182 found) | 183 found) |
183 | 184 |
184 ;; If master file exists, then parse its contents, otherwise we return the | 185 ;; If master file exists, then parse its contents, otherwise we return the |
203 (beginning-of-line) | 204 (beginning-of-line) |
204 (setq found (re-search-forward "^locks\\([^;]*\\);" nil t))) | 205 (setq found (re-search-forward "^locks\\([^;]*\\);" nil t))) |
205 | 206 |
206 (if found | 207 (if found |
207 ;; Clean control characters from text. | 208 ;; Clean control characters from text. |
208 (let ((status | 209 (let* ((locks |
209 (save-restriction | 210 (save-restriction |
210 (narrow-to-region (match-beginning 1) (match-end 1)) | 211 (narrow-to-region (match-beginning 1) (match-end 1)) |
211 (goto-char (point-min)) | 212 (goto-char (point-min)) |
212 (while (re-search-forward "[ \b\t\n\v\f\r]+" nil t) | 213 (while (re-search-forward "[ \b\t\n\v\f\r]+" nil t) |
213 (replace-match " " t t)) | 214 (replace-match " " t t)) |
214 (buffer-string)))) | 215 (buffer-string))) |
216 (status | |
217 (if (not (string-equal locks "")) | |
218 locks | |
219 (goto-char (point-min)) | |
220 (if (looking-at "head[ \b\t\n\v\f\r]+\\([.0-9]+\\)") | |
221 (concat " " (buffer-substring (match-beginning 1) | |
222 (match-end 1))) | |
223 " @@")))) | |
215 ;; Clean work buffer. | 224 ;; Clean work buffer. |
216 (erase-buffer) | 225 (erase-buffer) |
217 (set-buffer-modified-p nil) | 226 (set-buffer-modified-p nil) |
218 status)))))) | 227 status)))))) |
219 | 228 |