aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Nicolaescu2008-04-04 22:27:26 +0000
committerDan Nicolaescu2008-04-04 22:27:26 +0000
commit5a84a937140c3ec0cdf7e53e626b5dcdb74e5bc7 (patch)
tree1a6baf89076c8cf39e5f19ed979f87aca29f24ab
parenta25fe2887778cf07cc7d01136c126bf693659531 (diff)
downloademacs-5a84a937140c3ec0cdf7e53e626b5dcdb74e5bc7.tar.gz
emacs-5a84a937140c3ec0cdf7e53e626b5dcdb74e5bc7.zip
(vc-default-status-fileinfo-extra): New function.
(vc-status-mark-buffer-changed): Use it. (vc-update-vc-status-buffer): Allow for partial updates.
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/vc.el82
2 files changed, 70 insertions, 18 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index a1732e0b242..4aa8cb329db 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12008-04-04 Dan Nicolaescu <dann@ics.uci.edu>
2
3 * vc.el (vc-default-status-fileinfo-extra): New function.
4 (vc-status-mark-buffer-changed): Use it.
5 (vc-update-vc-status-buffer): Allow for partial updates.
6
12008-04-04 Stefan Monnier <monnier@iro.umontreal.ca> 72008-04-04 Stefan Monnier <monnier@iro.umontreal.ca>
2 8
3 * net/tramp.el (after-init-hook): Don't wrap a lambda around 9 * net/tramp.el (after-init-hook): Don't wrap a lambda around
diff --git a/lisp/vc.el b/lisp/vc.el
index 3c3b51f3faa..db7671f63bb 100644
--- a/lisp/vc.el
+++ b/lisp/vc.el
@@ -175,11 +175,19 @@
175;; If a command needs to be run to compute this list, it should be 175;; If a command needs to be run to compute this list, it should be
176;; run asynchronously using (current-buffer) as the buffer for the 176;; run asynchronously using (current-buffer) as the buffer for the
177;; command. When RESULT is computed, it should be passed back by 177;; command. When RESULT is computed, it should be passed back by
178;; doing: (funcall UPDATE-FUNCTION RESULT STATUS-BUFFER) This 178;; doing: (funcall UPDATE-FUNCTION RESULT STATUS-BUFFER nil).
179;; function is used by `vc-status', a replacement for `vc-dired'. 179;; If the backend uses a process filter, hence it produces partial results,
180;; vc-status is still under development, and is NOT feature 180;; they can be passed back by doing:
181;; complete. As such, the requirements for this function might 181;; (funcall UPDATE-FUNCTION RESULT STATUS-BUFFER t)
182;; change. This is a replacement for `dir-state'. 182;; and then do a (funcall UPDATE-FUNCTION RESULT STATUS-BUFFER nil)
183;; when all the results have been computed.
184;; To provide more backend specific functionality for `vc-status'
185;; the following functions might be needed: `status-extra-headers',
186;; `status-printer', `extra-status-menu' and `status-fileinfo-extra'.
187;; This function is used by `vc-status', a replacement for
188;; `vc-dired'. vc-status is still under development, and is NOT
189;; feature complete. As such, the requirements for this function
190;; might change. This is a replacement for `dir-state'.
183;; 191;;
184;; - status-extra-headers (dir) 192;; - status-extra-headers (dir)
185;; 193;;
@@ -193,6 +201,10 @@
193;; information in `vc-status-fileinfo->extra'. This function can be 201;; information in `vc-status-fileinfo->extra'. This function can be
194;; used to display that extra information in the vc-status buffer. 202;; used to display that extra information in the vc-status buffer.
195;; 203;;
204;; - status-fileinfo-extra (file)
205;;
206;; Compute `vc-status-fileinfo->extra' for FILE.
207;;
196;; * working-revision (file) 208;; * working-revision (file)
197;; 209;;
198;; Return the working revision of FILE. This is the revision fetched 210;; Return the working revision of FILE. This is the revision fetched
@@ -580,6 +592,12 @@
580;; display the branch name in the mode-line. Replace 592;; display the branch name in the mode-line. Replace
581;; vc-cvs-sticky-tag with that. 593;; vc-cvs-sticky-tag with that.
582;; 594;;
595;; - vc-diff should be able to show the diff for all files in a
596;; changeset, especially for VC systems that have per repository version numbers.
597;; log-view should take advantage of this.
598;;
599;; - a way to do repository wide log (instead of just per file/fileset) is needed.
600;;
583;; - the *VC-log* buffer needs font-locking. 601;; - the *VC-log* buffer needs font-locking.
584;; 602;;
585;; - make it easier to write logs. Maybe C-x 4 a should add to the log 603;; - make it easier to write logs. Maybe C-x 4 a should add to the log
@@ -1049,7 +1067,6 @@ BUF defaults to \"*vc*\", can be a string and will be created if necessary."
1049 (setq mode-line-process 1067 (setq mode-line-process
1050 (let ((status (process-status p))) 1068 (let ((status (process-status p)))
1051 ;; Leave mode-line uncluttered, normally. 1069 ;; Leave mode-line uncluttered, normally.
1052 ;; (Let known any weirdness in-form-ally. ;-) --ttn
1053 (unless (eq 'exit status) 1070 (unless (eq 'exit status)
1054 (format " (%s)" status)))) 1071 (format " (%s)" status))))
1055 (let (vc-sentinel-movepoint) 1072 (let (vc-sentinel-movepoint)
@@ -2659,6 +2676,9 @@ With prefix arg READ-SWITCHES, specify a value to override
2659;;; Experimental code for the vc-dired replacement 2676;;; Experimental code for the vc-dired replacement
2660(require 'ewoc) 2677(require 'ewoc)
2661 2678
2679
2680;; Used to store information for the files displayed in the *VC status* buffer.
2681;; Each item displayed corresponds to one of these defstructs.
2662(defstruct (vc-status-fileinfo 2682(defstruct (vc-status-fileinfo
2663 (:copier nil) 2683 (:copier nil)
2664 (:constructor 2684 (:constructor
@@ -2673,9 +2693,15 @@ With prefix arg READ-SWITCHES, specify a value to override
2673(defvar vc-status nil) 2693(defvar vc-status nil)
2674 2694
2675(defun vc-default-status-extra-headers (backend dir) 2695(defun vc-default-status-extra-headers (backend dir)
2696 ;; Be loud by default to remind people to add coded to display
2697 ;; backend specific headers.
2698 ;; XXX: change this to return nil before the release.
2676 "Extra : Add backend specific headers here") 2699 "Extra : Add backend specific headers here")
2677 2700
2678(defun vc-status-headers (backend dir) 2701(defun vc-status-headers (backend dir)
2702 "Display the headers in the *VC status* buffer.
2703It calls the `status-extra-headers' backend method to display backend
2704specific headers."
2679 (concat 2705 (concat
2680 (propertize "VC backend : " 'face 'font-lock-type-face) 2706 (propertize "VC backend : " 'face 'font-lock-type-face)
2681 (propertize (format "%s\n" backend) 'face 'font-lock-variable-name-face) 2707 (propertize (format "%s\n" backend) 'face 'font-lock-variable-name-face)
@@ -2710,6 +2736,7 @@ With prefix arg READ-SWITCHES, specify a value to override
2710 (vc-call-backend backend 'status-printer fileentry))) 2736 (vc-call-backend backend 'status-printer fileentry)))
2711 2737
2712(defun vc-status-move-to-goal-column () 2738(defun vc-status-move-to-goal-column ()
2739 ;; Used to keep the cursor on the file name column.
2713 (beginning-of-line) 2740 (beginning-of-line)
2714 ;; Must be in sync with vc-default-status-printer. 2741 ;; Must be in sync with vc-default-status-printer.
2715 (forward-char 25)) 2742 (forward-char 25))
@@ -2841,7 +2868,11 @@ With prefix arg READ-SWITCHES, specify a value to override
2841 (define-key map "=" 'vc-diff) ;; C-x v = 2868 (define-key map "=" 'vc-diff) ;; C-x v =
2842 (define-key map "a" 'vc-status-register) 2869 (define-key map "a" 'vc-status-register)
2843 (define-key map "+" 'vc-update) ;; C-x v + 2870 (define-key map "+" 'vc-update) ;; C-x v +
2871
2872 ;;XXX: Maybe use something else here, so we can use 'U' for unmark
2873 ;;all, similar to 'M'..
2844 (define-key map "U" 'vc-revert) ;; u is taken by unmark. 2874 (define-key map "U" 'vc-revert) ;; u is taken by unmark.
2875
2845 ;; Can't be "g" (as in vc map), so "A" for "Annotate". 2876 ;; Can't be "g" (as in vc map), so "A" for "Annotate".
2846 (define-key map "A" 'vc-annotate) 2877 (define-key map "A" 'vc-annotate)
2847 (define-key map "l" 'vc-print-log) ;; C-x v l 2878 (define-key map "l" 'vc-print-log) ;; C-x v l
@@ -2869,6 +2900,8 @@ With prefix arg READ-SWITCHES, specify a value to override
2869(defun vc-default-extra-status-menu (backend) 2900(defun vc-default-extra-status-menu (backend)
2870 nil) 2901 nil)
2871 2902
2903;; This is used to that VC backends could add backend specific menu
2904;; items to vc-status-menu-map.
2872(defun vc-status-menu-map-filter (orig-binding) 2905(defun vc-status-menu-map-filter (orig-binding)
2873 (when (and (symbolp orig-binding) (fboundp orig-binding)) 2906 (when (and (symbolp orig-binding) (fboundp orig-binding))
2874 (setq orig-binding (indirect-function orig-binding))) 2907 (setq orig-binding (indirect-function orig-binding)))
@@ -2937,7 +2970,11 @@ With prefix arg READ-SWITCHES, specify a value to override
2937 2970
2938(put 'vc-status-mode 'mode-class 'special) 2971(put 'vc-status-mode 'mode-class 'special)
2939 2972
2940(defun vc-update-vc-status-buffer (entries buffer) 2973(defun vc-update-vc-status-buffer (entries buffer &optional more-to-come)
2974 ;; ENTRIES is a list of (FILE VC_STATE EXTRA) items.
2975 ;; BUFFER is the *vc-status* buffer to be updated with ENTRIES
2976 ;; If MORE-TO-COME is true, then more updates will come from the
2977 ;; asynchronous process.
2941 (with-current-buffer buffer 2978 (with-current-buffer buffer
2942 (when entries 2979 (when entries
2943 ;; Insert the entries we got into the ewoc. 2980 ;; Insert the entries we got into the ewoc.
@@ -2956,9 +2993,11 @@ With prefix arg READ-SWITCHES, specify a value to override
2956 (setf (vc-status-fileinfo->marked arg) t))) 2993 (setf (vc-status-fileinfo->marked arg) t)))
2957 vc-status)) 2994 vc-status))
2958 (ewoc-goto-node vc-status (ewoc-nth vc-status 0))) 2995 (ewoc-goto-node vc-status (ewoc-nth vc-status 0)))
2959 (setq vc-status-process-buffer nil) 2996 ;; No more updates are expected from the asynchronous process.
2960 ;; We are done, turn off the mode-line "in progress" message. 2997 (unless more-to-come
2961 (setq mode-line-process nil))) 2998 (setq vc-status-process-buffer nil)
2999 ;; We are done, turn off the mode-line "in progress" message.
3000 (setq mode-line-process nil))))
2962 3001
2963(defun vc-status-add-entry (entry buffer) 3002(defun vc-status-add-entry (entry buffer)
2964 ;; Add one ENTRY to the vc-status buffer BUFFER. 3003 ;; Add one ENTRY to the vc-status buffer BUFFER.
@@ -3020,7 +3059,7 @@ Throw an error if another update process is in progress."
3020 ;; takes too long. 3059 ;; takes too long.
3021 (setq vc-status-process-buffer 3060 (setq vc-status-process-buffer
3022 (get-buffer-create 3061 (get-buffer-create
3023 (generate-new-buffer-name (format " *VC-%s* status" backend)))) 3062 (generate-new-buffer-name (format " *VC-%s* tmp status" backend))))
3024 (with-current-buffer vc-status-process-buffer 3063 (with-current-buffer vc-status-process-buffer
3025 (cd def-dir) 3064 (cd def-dir)
3026 (erase-buffer) 3065 (erase-buffer)
@@ -3207,12 +3246,11 @@ that share the same state."
3207 vc-status 3246 vc-status
3208 (lambda (crt) (not (eq (vc-status-fileinfo->state crt) 'up-to-date))))) 3247 (lambda (crt) (not (eq (vc-status-fileinfo->state crt) 'up-to-date)))))
3209 3248
3249(defun vc-default-status-fileinfo-extra (backend file)
3250 nil)
3251
3210(defun vc-status-mark-buffer-changed (&optional fname) 3252(defun vc-status-mark-buffer-changed (&optional fname)
3211 (let* ((file (or fname (expand-file-name buffer-file-name))) 3253 (let* ((file (or fname (expand-file-name buffer-file-name)))
3212 (state (and (vc-backend file) (vc-state file)))
3213 ;; XXX: EXTRA is not set here.
3214 ;; It might need to be.
3215 (extra nil)
3216 (found-vc-status-buf nil)) 3254 (found-vc-status-buf nil))
3217 (save-excursion 3255 (save-excursion
3218 (dolist (status-buf (buffer-list)) 3256 (dolist (status-buf (buffer-list))
@@ -3223,9 +3261,17 @@ that share the same state."
3223 (let ((ddir (expand-file-name default-directory))) 3261 (let ((ddir (expand-file-name default-directory)))
3224 ;; This test is cvs-string-prefix-p 3262 ;; This test is cvs-string-prefix-p
3225 (when (eq t (compare-strings file nil (length ddir) ddir nil nil)) 3263 (when (eq t (compare-strings file nil (length ddir) ddir nil nil))
3226 (let* ((file-short (substring file (length ddir))) 3264 (let*
3227 (entry 3265 ((file-short (substring file (length ddir)))
3228 (list file-short (if state state 'unregistered) extra))) 3266 (backend (vc-backend file))
3267 (state (and backend (vc-state file)))
3268 ;; XXX: EXTRA is not set here.
3269 ;; It might need to be.
3270 (extra
3271 (and backend
3272 (vc-call-backend backend 'status-fileinfo-extra file)))
3273 (entry
3274 (list file-short (if state state 'unregistered) extra)))
3229 (vc-status-add-entry entry status-buf)))))) 3275 (vc-status-add-entry entry status-buf))))))
3230 ;; We didn't find any vc-status buffers, remove the hook, it is 3276 ;; We didn't find any vc-status buffers, remove the hook, it is
3231 ;; not needed. 3277 ;; not needed.