# HG changeset patch # User Dan Nicolaescu # Date 1200699178 0 # Node ID 3bd7c8c8bbe780b3fddad5a03620ebde5805cfc0 # Parent e1d6c4e34d2cd1562f2fa55daf0cb7a1d68f7d8d * 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. diff -r e1d6c4e34d2c -r 3bd7c8c8bbe7 lisp/ChangeLog --- a/lisp/ChangeLog Fri Jan 18 22:50:17 2008 +0000 +++ b/lisp/ChangeLog Fri Jan 18 23:32:58 2008 +0000 @@ -1,3 +1,15 @@ +2008-01-18 Dan Nicolaescu + + * 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. + 2008-01-18 Stefan Monnier * doc-view.el (doc-view-pdf/ps->png): Make sure we a have a valid cwd. diff -r e1d6c4e34d2c -r 3bd7c8c8bbe7 lisp/vc-hg.el --- a/lisp/vc-hg.el Fri Jan 18 22:50:17 2008 +0000 +++ b/lisp/vc-hg.el Fri Jan 18 23:32:58 2008 +0000 @@ -480,35 +480,41 @@ (define-derived-mode vc-hg-incoming-mode vc-hg-log-view-mode "Hg-Incoming") - ;; XXX Experimental function for the vc-dired replacement. -(defun vc-hg-dir-status (dir) - "Return a list of conses (file . state) for DIR." - (with-temp-buffer - (vc-hg-command (current-buffer) nil dir "status") - (goto-char (point-min)) - (let ((status-char nil) - (file nil) - (translation '((?= . up-to-date) - (?C . up-to-date) - (?A . added) - (?R . removed) - (?M . edited) - (?I . ignored) - (?! . deleted) - (?? . unregistered))) - (translated nil) +(defun vc-hg-after-dir-status (update-function buff) + (let ((status-char nil) + (file nil) + (translation '((?= . up-to-date) + (?C . up-to-date) + (?A . added) + (?R . removed) + (?M . edited) + (?I . ignored) + (?! . deleted) + (?? . unregistered))) + (translated nil) (result nil)) + (goto-char (point-min)) (while (not (eobp)) (setq status-char (char-after)) (setq file (buffer-substring-no-properties (+ (point) 2) - (line-end-position))) + (line-end-position))) (setq translated (assoc status-char translation)) (when (and translated (not (eq (cdr translated) 'up-to-date))) (push (cons file (cdr translated)) result)) (forward-line)) - result))) + (funcall update-function result buff))) + +;; XXX Experimental function for the vc-dired replacement. +(defun vc-hg-dir-status (dir update-function status-buffer) + "Return a list of conses (file . state) for DIR." + (with-current-buffer + (get-buffer-create + (expand-file-name " *VC-hg* tmp status" dir)) + (vc-hg-command (current-buffer) 'async dir "status") + (vc-exec-after + `(vc-hg-after-dir-status (quote ,update-function) ,status-buffer)))) ;; XXX this adds another top level menu, instead figure out how to ;; replace the Log-View menu. diff -r e1d6c4e34d2c -r 3bd7c8c8bbe7 lisp/vc.el --- a/lisp/vc.el Fri Jan 18 22:50:17 2008 +0000 +++ b/lisp/vc.el Fri Jan 18 23:32:58 2008 +0000 @@ -544,8 +544,6 @@ ;; ;; - decide if vc-status should replace vc-dired. ;; -;; - vc-status should be made asynchronous. -;; ;; - vc-status needs a menu, mouse bindings and some color bling. ;;; Code: @@ -2622,16 +2620,26 @@ (put 'vc-status-mode 'mode-class 'special) +(defun vc-update-vc-status-buffer (entries buffer) + (with-current-buffer buffer + (dolist (entry entries) + (ewoc-enter-last vc-status + (vc-status-create-fileinfo (cdr entry) (car entry)))) + (ewoc-goto-node vc-status (ewoc-nth vc-status 0)))) + (defun vc-status-refresh () "Refresh the contents of the VC status buffer." (interactive) ;; This is not very efficient; ewoc could use a new function here. (ewoc-filter vc-status (lambda (node) nil)) (let ((backend (vc-responsible-backend default-directory))) - (dolist (entry (vc-call-backend backend 'dir-status default-directory)) - (ewoc-enter-last vc-status - (vc-status-create-fileinfo (cdr entry) (car entry))))) - (ewoc-goto-node vc-status (ewoc-nth vc-status 0))) + ;; Call the dir-status backend function. dir-status is supposed to + ;; be asynchronous. It should compute the results and call the + ;; function passed as a an arg to update the vc-status buffer with + ;; the results. + (vc-call-backend + backend 'dir-status default-directory + #'vc-update-vc-status-buffer (current-buffer)))) (defun vc-status-next-line (arg) "Go to the next line.