* 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.
This commit is contained in:
parent
64a7c220b3
commit
5ab612e823
3 changed files with 51 additions and 25 deletions
|
@ -1,3 +1,15 @@
|
|||
2008-01-18 Dan Nicolaescu <dann@ics.uci.edu>
|
||||
|
||||
* 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 <monnier@iro.umontreal.ca>
|
||||
|
||||
* doc-view.el (doc-view-pdf/ps->png): Make sure we a have a valid cwd.
|
||||
|
|
|
@ -480,35 +480,41 @@ REV is the revision to check out into WORKFILE."
|
|||
|
||||
(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.
|
||||
|
|
20
lisp/vc.el
20
lisp/vc.el
|
@ -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 @@ With prefix arg READ-SWITCHES, specify a value to override
|
|||
|
||||
(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.
|
||||
|
|
Loading…
Add table
Reference in a new issue