aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandre Julliard2008-04-09 18:52:20 +0000
committerAlexandre Julliard2008-04-09 18:52:20 +0000
commitbeac4378aa9ec2f5ade5d91368e5d36200a93053 (patch)
tree689a6e6e4d861fc4e3ca28dd5bbbaa65aaa3d9e6
parentd533750604ffa4d4068ebcf17f14fe5aa9571ed9 (diff)
downloademacs-beac4378aa9ec2f5ade5d91368e5d36200a93053.tar.gz
emacs-beac4378aa9ec2f5ade5d91368e5d36200a93053.zip
(vc-status-add-entries): New function.
(vc-status-add-entry): Removed. (vc-update-vc-status-buffer, vc-status-mark-buffer-changed): Use vc-status-add-entries.
-rw-r--r--lisp/ChangeLog10
-rw-r--r--lisp/vc.el80
2 files changed, 49 insertions, 41 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index bbee9e3e715..cb50cb7ad2b 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,13 @@
12008-04-09 Alexandre Julliard <julliard@winehq.org>
2
3 * vc.el (vc-status-add-entries): New function.
4 (vc-status-add-entry): Removed.
5 (vc-update-vc-status-buffer, vc-status-mark-buffer-changed): Use
6 vc-status-add-entries.
7
8 * emacs-lisp/ewoc.el (ewoc-collect): Return results in the correct
9 order.
10
12008-04-09 Jason Rumney <jasonr@gnu.org> 112008-04-09 Jason Rumney <jasonr@gnu.org>
2 12
3 * makefile.w32-in (LOADDEFS): Add mh-loaddefs.el. 13 * makefile.w32-in (LOADDEFS): Add mh-loaddefs.el.
diff --git a/lisp/vc.el b/lisp/vc.el
index b88b6adf94b..90621b85ecd 100644
--- a/lisp/vc.el
+++ b/lisp/vc.el
@@ -2975,6 +2975,43 @@ specific headers."
2975 2975
2976(put 'vc-status-mode 'mode-class 'special) 2976(put 'vc-status-mode 'mode-class 'special)
2977 2977
2978(defun vc-status-add-entries (entries buffer)
2979 ;; Add ENTRIES to the vc-status buffer BUFFER.
2980 (with-current-buffer buffer
2981 (when entries
2982 ;; Insert the entries sorted by name into the ewoc.
2983 ;; We assume the ewoc is sorted too, which should be the
2984 ;; case if we always add entries with vc-status-add-entries.
2985 (setq entries (sort (copy-sequence entries)
2986 (lambda (entry1 entry2)
2987 (string-lessp (car entry1) (car entry2)))))
2988 (let ((entry (pop entries))
2989 (node (ewoc-nth vc-status 0)))
2990 (while entry
2991 (while (and vc-status-crt-marked
2992 (string-lessp (car vc-status-crt-marked) (car entry)))
2993 (setq vc-status-crt-marked (cdr vc-status-crt-marked)))
2994 (let* ((file (car entry))
2995 (state (nth 1 entry))
2996 (extra (nth 2 entry))
2997 (marked (and vc-status-crt-marked
2998 (string-equal (car vc-status-crt-marked) file))))
2999 (cond ((not node)
3000 (setq node (ewoc-enter-last vc-status
3001 (vc-status-create-fileinfo file state extra marked)))
3002 (setq entry (pop entries)))
3003 ((string-lessp (vc-status-fileinfo->name (ewoc-data node)) file)
3004 (setq node (ewoc-next vc-status node)))
3005 ((string-equal (vc-status-fileinfo->name (ewoc-data node)) file)
3006 (setf (vc-status-fileinfo->state (ewoc-data node)) state)
3007 (setf (vc-status-fileinfo->extra (ewoc-data node)) extra)
3008 (ewoc-invalidate vc-status node)
3009 (setq entry (pop entries)))
3010 (t
3011 (setq node (ewoc-enter-before vc-status node
3012 (vc-status-create-fileinfo file state extra marked)))
3013 (setq entry (pop entries))))))))))
3014
2978(defun vc-update-vc-status-buffer (entries buffer &optional more-to-come) 3015(defun vc-update-vc-status-buffer (entries buffer &optional more-to-come)
2979 ;; ENTRIES is a list of (FILE VC_STATE EXTRA) items. 3016 ;; ENTRIES is a list of (FILE VC_STATE EXTRA) items.
2980 ;; BUFFER is the *vc-status* buffer to be updated with ENTRIES 3017 ;; BUFFER is the *vc-status* buffer to be updated with ENTRIES
@@ -2982,21 +3019,7 @@ specific headers."
2982 ;; asynchronous process. 3019 ;; asynchronous process.
2983 (with-current-buffer buffer 3020 (with-current-buffer buffer
2984 (when entries 3021 (when entries
2985 ;; Insert the entries we got into the ewoc. 3022 (vc-status-add-entries entries buffer)
2986 (dolist (entry entries)
2987 (let* ((file (car entry))
2988 (state (nth 1 entry))
2989 (extra (nth 2 entry)))
2990 (ewoc-enter-last vc-status
2991 (vc-status-create-fileinfo file state extra))))
2992 ;; If we had marked items before the refresh, try mark them here.
2993 ;; XXX: there should be a better way to do this...
2994 (when vc-status-crt-marked
2995 (ewoc-map
2996 (lambda (arg)
2997 (when (member (vc-status-fileinfo->name arg) vc-status-crt-marked)
2998 (setf (vc-status-fileinfo->marked arg) t)))
2999 vc-status))
3000 (ewoc-goto-node vc-status (ewoc-nth vc-status 0))) 3023 (ewoc-goto-node vc-status (ewoc-nth vc-status 0)))
3001 ;; No more updates are expected from the asynchronous process. 3024 ;; No more updates are expected from the asynchronous process.
3002 (unless more-to-come 3025 (unless more-to-come
@@ -3004,31 +3027,6 @@ specific headers."
3004 ;; We are done, turn off the mode-line "in progress" message. 3027 ;; We are done, turn off the mode-line "in progress" message.
3005 (setq mode-line-process nil)))) 3028 (setq mode-line-process nil))))
3006 3029
3007(defun vc-status-add-entry (entry buffer)
3008 ;; Add one ENTRY to the vc-status buffer BUFFER.
3009 ;; This will be used to automatically add files with the "modified"
3010 ;; state when saving them.
3011
3012 ;; ENTRY has the form (FILENAME STATE EXTRA)
3013 (with-current-buffer buffer
3014 (let ((crt (ewoc-nth vc-status 0))
3015 (fname (car entry)))
3016 ;; First try to see if there's already an entry with that name
3017 ;; in the ewoc.
3018 (while (and crt (not (string= (vc-status-fileinfo->name
3019 (ewoc-data crt)) fname)))
3020 (setq crt (ewoc-next vc-status crt)))
3021 (if crt
3022 (progn
3023 ;; Found the file, just update the status.
3024 (setf (vc-status-fileinfo->state (ewoc-data crt)) (nth 1 entry))
3025 (setf (vc-status-fileinfo->extra (ewoc-data crt)) (nth 2 entry))
3026 (ewoc-invalidate vc-status crt))
3027 ;; Could not find the file, insert a new entry.
3028 (ewoc-enter-last
3029 vc-status
3030 (vc-status-create-fileinfo fname (nth 1 entry) (nth 2 entry)))))))
3031
3032(defun vc-status-refresh () 3030(defun vc-status-refresh ()
3033 "Refresh the contents of the VC status buffer. 3031 "Refresh the contents of the VC status buffer.
3034Throw an error if another update process is in progress." 3032Throw an error if another update process is in progress."
@@ -3275,7 +3273,7 @@ that share the same state."
3275 (vc-call-backend backend 'status-fileinfo-extra file))) 3273 (vc-call-backend backend 'status-fileinfo-extra file)))
3276 (entry 3274 (entry
3277 (list file-short (if state state 'unregistered) extra))) 3275 (list file-short (if state state 'unregistered) extra)))
3278 (vc-status-add-entry entry status-buf)))))) 3276 (vc-status-add-entries (list entry) status-buf))))))
3279 ;; We didn't find any vc-status buffers, remove the hook, it is 3277 ;; We didn't find any vc-status buffers, remove the hook, it is
3280 ;; not needed. 3278 ;; not needed.
3281 (unless found-vc-status-buf (remove-hook 'after-save-hook 'vc-status-mark-buffer-changed))))) 3279 (unless found-vc-status-buf (remove-hook 'after-save-hook 'vc-status-mark-buffer-changed)))))