diff options
| author | Dan Nicolaescu | 2008-01-18 23:32:58 +0000 |
|---|---|---|
| committer | Dan Nicolaescu | 2008-01-18 23:32:58 +0000 |
| commit | 5ab612e823bb32aed3514c26b58e5aa7c0fab136 (patch) | |
| tree | 87495f3de4d3e1e5e9539f4ad811f9b47857c7aa | |
| parent | 64a7c220b34248e33ca25c3e6dde0e6e178b9fda (diff) | |
| download | emacs-5ab612e823bb32aed3514c26b58e5aa7c0fab136.tar.gz emacs-5ab612e823bb32aed3514c26b58e5aa7c0fab136.zip | |
* vc.el: Make vc-status asynchronous.
(vc-update-vc-status-buffer): New function broken out of ...
(vc-status-refresh): ... here. Pass vc-update-vc-status-buffer to
the dir-status backend function.
* vc-hg.el (vc-hg-dir-status): Compute the status asynchronously.
Move the output processing to ...
(vc-hg-after-dir-status): ... here. Call the function passed as
an argument with the results.
| -rw-r--r-- | lisp/ChangeLog | 12 | ||||
| -rw-r--r-- | lisp/vc-hg.el | 44 | ||||
| -rw-r--r-- | lisp/vc.el | 20 |
3 files changed, 51 insertions, 25 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 182812f2c7a..a629893a38d 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,15 @@ | |||
| 1 | 2008-01-18 Dan Nicolaescu <dann@ics.uci.edu> | ||
| 2 | |||
| 3 | * vc.el: Make vc-status asynchronous. | ||
| 4 | (vc-update-vc-status-buffer): New function broken out of ... | ||
| 5 | (vc-status-refresh): ... here. Pass vc-update-vc-status-buffer to | ||
| 6 | the dir-status backend function. | ||
| 7 | |||
| 8 | * vc-hg.el (vc-hg-dir-status): Compute the status asynchronously. | ||
| 9 | Move the output processing to ... | ||
| 10 | (vc-hg-after-dir-status): ... here. Call the function passed as | ||
| 11 | an argument with the results. | ||
| 12 | |||
| 1 | 2008-01-18 Stefan Monnier <monnier@iro.umontreal.ca> | 13 | 2008-01-18 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 14 | ||
| 3 | * doc-view.el (doc-view-pdf/ps->png): Make sure we a have a valid cwd. | 15 | * doc-view.el (doc-view-pdf/ps->png): Make sure we a have a valid cwd. |
diff --git a/lisp/vc-hg.el b/lisp/vc-hg.el index fe441d984f7..c3c3b5577f3 100644 --- a/lisp/vc-hg.el +++ b/lisp/vc-hg.el | |||
| @@ -480,35 +480,41 @@ REV is the revision to check out into WORKFILE." | |||
| 480 | 480 | ||
| 481 | (define-derived-mode vc-hg-incoming-mode vc-hg-log-view-mode "Hg-Incoming") | 481 | (define-derived-mode vc-hg-incoming-mode vc-hg-log-view-mode "Hg-Incoming") |
| 482 | 482 | ||
| 483 | |||
| 484 | ;; XXX Experimental function for the vc-dired replacement. | 483 | ;; XXX Experimental function for the vc-dired replacement. |
| 485 | (defun vc-hg-dir-status (dir) | 484 | (defun vc-hg-after-dir-status (update-function buff) |
| 486 | "Return a list of conses (file . state) for DIR." | 485 | (let ((status-char nil) |
| 487 | (with-temp-buffer | 486 | (file nil) |
| 488 | (vc-hg-command (current-buffer) nil dir "status") | 487 | (translation '((?= . up-to-date) |
| 489 | (goto-char (point-min)) | 488 | (?C . up-to-date) |
| 490 | (let ((status-char nil) | 489 | (?A . added) |
| 491 | (file nil) | 490 | (?R . removed) |
| 492 | (translation '((?= . up-to-date) | 491 | (?M . edited) |
| 493 | (?C . up-to-date) | 492 | (?I . ignored) |
| 494 | (?A . added) | 493 | (?! . deleted) |
| 495 | (?R . removed) | 494 | (?? . unregistered))) |
| 496 | (?M . edited) | 495 | (translated nil) |
| 497 | (?I . ignored) | ||
| 498 | (?! . deleted) | ||
| 499 | (?? . unregistered))) | ||
| 500 | (translated nil) | ||
| 501 | (result nil)) | 496 | (result nil)) |
| 497 | (goto-char (point-min)) | ||
| 502 | (while (not (eobp)) | 498 | (while (not (eobp)) |
| 503 | (setq status-char (char-after)) | 499 | (setq status-char (char-after)) |
| 504 | (setq file | 500 | (setq file |
| 505 | (buffer-substring-no-properties (+ (point) 2) | 501 | (buffer-substring-no-properties (+ (point) 2) |
| 506 | (line-end-position))) | 502 | (line-end-position))) |
| 507 | (setq translated (assoc status-char translation)) | 503 | (setq translated (assoc status-char translation)) |
| 508 | (when (and translated (not (eq (cdr translated) 'up-to-date))) | 504 | (when (and translated (not (eq (cdr translated) 'up-to-date))) |
| 509 | (push (cons file (cdr translated)) result)) | 505 | (push (cons file (cdr translated)) result)) |
| 510 | (forward-line)) | 506 | (forward-line)) |
| 511 | result))) | 507 | (funcall update-function result buff))) |
| 508 | |||
| 509 | ;; XXX Experimental function for the vc-dired replacement. | ||
| 510 | (defun vc-hg-dir-status (dir update-function status-buffer) | ||
| 511 | "Return a list of conses (file . state) for DIR." | ||
| 512 | (with-current-buffer | ||
| 513 | (get-buffer-create | ||
| 514 | (expand-file-name " *VC-hg* tmp status" dir)) | ||
| 515 | (vc-hg-command (current-buffer) 'async dir "status") | ||
| 516 | (vc-exec-after | ||
| 517 | `(vc-hg-after-dir-status (quote ,update-function) ,status-buffer)))) | ||
| 512 | 518 | ||
| 513 | ;; XXX this adds another top level menu, instead figure out how to | 519 | ;; XXX this adds another top level menu, instead figure out how to |
| 514 | ;; replace the Log-View menu. | 520 | ;; replace the Log-View menu. |
diff --git a/lisp/vc.el b/lisp/vc.el index bb05625f577..a0f8ce1702c 100644 --- a/lisp/vc.el +++ b/lisp/vc.el | |||
| @@ -544,8 +544,6 @@ | |||
| 544 | ;; | 544 | ;; |
| 545 | ;; - decide if vc-status should replace vc-dired. | 545 | ;; - decide if vc-status should replace vc-dired. |
| 546 | ;; | 546 | ;; |
| 547 | ;; - vc-status should be made asynchronous. | ||
| 548 | ;; | ||
| 549 | ;; - vc-status needs a menu, mouse bindings and some color bling. | 547 | ;; - vc-status needs a menu, mouse bindings and some color bling. |
| 550 | 548 | ||
| 551 | ;;; Code: | 549 | ;;; Code: |
| @@ -2622,16 +2620,26 @@ With prefix arg READ-SWITCHES, specify a value to override | |||
| 2622 | 2620 | ||
| 2623 | (put 'vc-status-mode 'mode-class 'special) | 2621 | (put 'vc-status-mode 'mode-class 'special) |
| 2624 | 2622 | ||
| 2623 | (defun vc-update-vc-status-buffer (entries buffer) | ||
| 2624 | (with-current-buffer buffer | ||
| 2625 | (dolist (entry entries) | ||
| 2626 | (ewoc-enter-last vc-status | ||
| 2627 | (vc-status-create-fileinfo (cdr entry) (car entry)))) | ||
| 2628 | (ewoc-goto-node vc-status (ewoc-nth vc-status 0)))) | ||
| 2629 | |||
| 2625 | (defun vc-status-refresh () | 2630 | (defun vc-status-refresh () |
| 2626 | "Refresh the contents of the VC status buffer." | 2631 | "Refresh the contents of the VC status buffer." |
| 2627 | (interactive) | 2632 | (interactive) |
| 2628 | ;; This is not very efficient; ewoc could use a new function here. | 2633 | ;; This is not very efficient; ewoc could use a new function here. |
| 2629 | (ewoc-filter vc-status (lambda (node) nil)) | 2634 | (ewoc-filter vc-status (lambda (node) nil)) |
| 2630 | (let ((backend (vc-responsible-backend default-directory))) | 2635 | (let ((backend (vc-responsible-backend default-directory))) |
| 2631 | (dolist (entry (vc-call-backend backend 'dir-status default-directory)) | 2636 | ;; Call the dir-status backend function. dir-status is supposed to |
| 2632 | (ewoc-enter-last vc-status | 2637 | ;; be asynchronous. It should compute the results and call the |
| 2633 | (vc-status-create-fileinfo (cdr entry) (car entry))))) | 2638 | ;; function passed as a an arg to update the vc-status buffer with |
| 2634 | (ewoc-goto-node vc-status (ewoc-nth vc-status 0))) | 2639 | ;; the results. |
| 2640 | (vc-call-backend | ||
| 2641 | backend 'dir-status default-directory | ||
| 2642 | #'vc-update-vc-status-buffer (current-buffer)))) | ||
| 2635 | 2643 | ||
| 2636 | (defun vc-status-next-line (arg) | 2644 | (defun vc-status-next-line (arg) |
| 2637 | "Go to the next line. | 2645 | "Go to the next line. |