diff options
| author | Stefan Monnier | 2007-07-12 03:10:45 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2007-07-12 03:10:45 +0000 |
| commit | 98ad325cb3594f67360210e7c29238d4f8fdb970 (patch) | |
| tree | 176021cf3be6b79d79599079bbe9add94439a9ab | |
| parent | 1bed504abe704d9ddb2b6a68c86b8569ed05860e (diff) | |
| download | emacs-98ad325cb3594f67360210e7c29238d4f8fdb970.tar.gz emacs-98ad325cb3594f67360210e7c29238d4f8fdb970.zip | |
(vc-functions): Clear up the cache when reloading the file.
(vc-cvs-annotate-first-line-re): New const.
(vc-cvs-annotate-process-filter): New fun.
(vc-cvs-annotate-command): Use them and run the command asynchronously.
| -rw-r--r-- | lisp/vc-cvs.el | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/lisp/vc-cvs.el b/lisp/vc-cvs.el index 3b35efe47c3..f5afcca581d 100644 --- a/lisp/vc-cvs.el +++ b/lisp/vc-cvs.el | |||
| @@ -32,6 +32,10 @@ | |||
| 32 | (eval-when-compile | 32 | (eval-when-compile |
| 33 | (require 'vc)) | 33 | (require 'vc)) |
| 34 | 34 | ||
| 35 | ;; Clear up the cache to force vc-call to check again and discover | ||
| 36 | ;; new functions when we reload this file. | ||
| 37 | (put 'CVS 'vc-functions nil) | ||
| 38 | |||
| 35 | ;;; | 39 | ;;; |
| 36 | ;;; Customization options | 40 | ;;; Customization options |
| 37 | ;;; | 41 | ;;; |
| @@ -534,14 +538,36 @@ The changes are between FIRST-VERSION and SECOND-VERSION." | |||
| 534 | (and rev2 (concat "-r" rev2)) | 538 | (and rev2 (concat "-r" rev2)) |
| 535 | (vc-switches 'CVS 'diff)))))) | 539 | (vc-switches 'CVS 'diff)))))) |
| 536 | 540 | ||
| 541 | (defconst vc-cvs-annotate-first-line-re "^[0-9]") | ||
| 542 | |||
| 543 | (defun vc-cvs-annotate-process-filter (process string) | ||
| 544 | (setq string (concat (process-get process 'output) string)) | ||
| 545 | (if (not (string-match vc-cvs-annotate-first-line-re string)) | ||
| 546 | ;; Still waiting for the first real line. | ||
| 547 | (process-put process 'output string) | ||
| 548 | (let ((vc-filter (process-get process 'vc-filter))) | ||
| 549 | (set-process-filter process vc-filter) | ||
| 550 | (funcall vc-filter process (substring string (match-beginning 0)))))) | ||
| 551 | |||
| 537 | (defun vc-cvs-annotate-command (file buffer &optional version) | 552 | (defun vc-cvs-annotate-command (file buffer &optional version) |
| 538 | "Execute \"cvs annotate\" on FILE, inserting the contents in BUFFER. | 553 | "Execute \"cvs annotate\" on FILE, inserting the contents in BUFFER. |
| 539 | Optional arg VERSION is a version to annotate from." | 554 | Optional arg VERSION is a version to annotate from." |
| 540 | (vc-cvs-command buffer 0 file "annotate" (if version (concat "-r" version))) | 555 | (vc-cvs-command buffer |
| 541 | (with-current-buffer buffer | 556 | (if (and (vc-stay-local-p file) (fboundp 'start-process)) |
| 542 | (goto-char (point-min)) | 557 | 'async 0) |
| 543 | (re-search-forward "^[0-9]") | 558 | file "annotate" |
| 544 | (delete-region (point-min) (1- (point))))) | 559 | (if version (concat "-r" version))) |
| 560 | ;; Strip the leading few lines. | ||
| 561 | (let ((proc (get-buffer-process buffer))) | ||
| 562 | (if proc | ||
| 563 | ;; If running asynchronously, use a process filter. | ||
| 564 | (progn | ||
| 565 | (process-put proc 'vc-filter (process-filter proc)) | ||
| 566 | (set-process-filter proc 'vc-cvs-annotate-process-filter)) | ||
| 567 | (with-current-buffer buffer | ||
| 568 | (goto-char (point-min)) | ||
| 569 | (re-search-forward vc-cvs-annotate-first-line-re) | ||
| 570 | (delete-region (point-min) (1- (point))))))) | ||
| 545 | 571 | ||
| 546 | (defun vc-cvs-annotate-current-time () | 572 | (defun vc-cvs-annotate-current-time () |
| 547 | "Return the current time, based at midnight of the current day, and | 573 | "Return the current time, based at midnight of the current day, and |