Mercurial > emacs
comparison lisp/vc-cvs.el @ 81820:37a7f9bddc45
(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.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Thu, 12 Jul 2007 03:10:45 +0000 |
parents | 12e5ff38b024 |
children | 0d37b602a4f0 |
comparison
equal
deleted
inserted
replaced
81819:f6d3d2315f54 | 81820:37a7f9bddc45 |
---|---|
29 | 29 |
30 ;;; Code: | 30 ;;; Code: |
31 | 31 |
32 (eval-when-compile | 32 (eval-when-compile |
33 (require 'vc)) | 33 (require 'vc)) |
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) | |
34 | 38 |
35 ;;; | 39 ;;; |
36 ;;; Customization options | 40 ;;; Customization options |
37 ;;; | 41 ;;; |
38 | 42 |
532 (apply 'vc-cvs-command "*vc-diff*" 1 nil "diff" | 536 (apply 'vc-cvs-command "*vc-diff*" 1 nil "diff" |
533 (and rev1 (concat "-r" rev1)) | 537 (and rev1 (concat "-r" rev1)) |
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 |
548 encoded as fractional days." | 574 encoded as fractional days." |
549 (vc-annotate-convert-time | 575 (vc-annotate-convert-time |