From 58f10bffac5fa90a35685a06f284f5a38d279987 Mon Sep 17 00:00:00 2001 From: Dan Nicolaescu Date: Sun, 30 Mar 2008 15:29:35 +0000 Subject: [PATCH] Allow backends to display backend specific information in the vc-status listing. (vc-status-fileinfo): Add a field for backend specific information. (vc-status-printer): Rename to ... (vc-default-status-printer): ... this. (vc-status-printer): New function. (vc-update-vc-status-buffer): Set the backend specific file info if provided. --- lisp/ChangeLog | 11 +++++++++++ lisp/vc.el | 34 ++++++++++++++++++++++++++++------ 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 937b98f4c0f..e6bfdbac49a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,14 @@ +2008-03-30 Dan Nicolaescu + + * vc.el: Allow backends to display backend specific information in + the vc-status listing. + (vc-status-fileinfo): Add a field for backend specific information. + (vc-status-printer): Rename to ... + (vc-default-status-printer): ... this. + (vc-status-printer): New function. + (vc-update-vc-status-buffer): Set the backend specific file info + if provided. + 2008-03-30 Stefan Monnier * textmodes/remember.el (remember-diary-convert-entry): Revert last diff --git a/lisp/vc.el b/lisp/vc.el index 43093568f3c..cdd4e2f3ff3 100644 --- a/lisp/vc.el +++ b/lisp/vc.el @@ -183,6 +183,14 @@ ;; ;; Return a string that will be added to the *vc-status* buffer header. ;; +;; - status-printer (fileinfo) +;; +;; Pretty print the `vc-status-fileinfo' FILEINFO. +;; If a backend needs to show more information than the default FILE +;; and STATE in the vc-status listing, it can store that extra +;; information in `vc-status-fileinfo->extra'. This function can be +;; used to display that extra information in the vc-status buffer. +;; ;; * working-revision (file) ;; ;; Return the working revision of FILE. This is the revision fetched @@ -2644,11 +2652,14 @@ With prefix arg READ-SWITCHES, specify a value to override (defstruct (vc-status-fileinfo (:copier nil) - (:constructor vc-status-create-fileinfo (state name &optional marked)) + (:constructor + vc-status-create-fileinfo (name state extra &optional marked)) (:conc-name vc-status-fileinfo->)) marked state - name) + name + ;; For storing backend specific information. + extra) (defvar vc-status nil) @@ -2664,7 +2675,7 @@ With prefix arg READ-SWITCHES, specify a value to override (vc-call-backend backend 'status-extra-headers dir) "\n")) -(defun vc-status-printer (fileentry) +(defun vc-default-status-printer (backend fileentry) "Pretty print FILEENTRY." ;; If you change the layout here, change vc-status-move-to-goal-column. (let ((state (vc-status-fileinfo->state fileentry))) @@ -2685,9 +2696,13 @@ With prefix arg READ-SWITCHES, specify a value to override 'face 'font-lock-function-name-face 'mouse-face 'highlight)))) +(defun vc-status-printer (fileentry) + (let ((backend (vc-responsible-backend default-directory))) + (vc-call-backend backend 'status-printer fileentry))) + (defun vc-status-move-to-goal-column () (beginning-of-line) - ;; Must be in sync with vc-status-printer. + ;; Must be in sync with vc-default-status-printer. (forward-char 25)) (defun vc-status-prepare-status-buffer (dir &optional create-new) @@ -2918,8 +2933,12 @@ With prefix arg READ-SWITCHES, specify a value to override (when entries ;; Insert the entries we got into the ewoc. (dolist (entry entries) + (let* ((file (car entry)) + (entrycdr (cdr entry)) + (state (if (listp entrycdr) (nth 1 entry))) + (extra (if (listp entrycdr) (nth 2 entry)))) (ewoc-enter-last vc-status - (vc-status-create-fileinfo (cdr entry) (car entry)))) + (vc-status-create-fileinfo file state extra)))) ;; If we had marked items before the refresh, try mark them here. ;; XXX: there should be a better way to do this... (when vc-status-crt-marked @@ -2954,7 +2973,10 @@ With prefix arg READ-SWITCHES, specify a value to override (ewoc-invalidate vc-status crt)) ;; Could not find the file, insert a new entry. (ewoc-enter-last - vc-status (vc-status-create-fileinfo (cdr entry) (car entry))))))) + ;; XXX: `vc-status-fileinfo->extra' is not set here. + ;; It might need to be. + vc-status + (vc-status-create-fileinfo (car entry) (cdr entry) nil)))))) (defun vc-status-refresh () "Refresh the contents of the VC status buffer. -- 2.39.5