Mercurial > emacs
comparison lisp/vc.el @ 93425:8459d55c7312
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.
author | Dan Nicolaescu <dann@ics.uci.edu> |
---|---|
date | Sun, 30 Mar 2008 15:29:35 +0000 |
parents | 8e46096e0cb3 |
children | 33bf5e278fa3 |
comparison
equal
deleted
inserted
replaced
93424:bc6b2ba17b08 | 93425:8459d55c7312 |
---|---|
180 ;; change. This is a replacement for `dir-state'. | 180 ;; change. This is a replacement for `dir-state'. |
181 ;; | 181 ;; |
182 ;; - status-extra-headers (dir) | 182 ;; - status-extra-headers (dir) |
183 ;; | 183 ;; |
184 ;; Return a string that will be added to the *vc-status* buffer header. | 184 ;; Return a string that will be added to the *vc-status* buffer header. |
185 ;; | |
186 ;; - status-printer (fileinfo) | |
187 ;; | |
188 ;; Pretty print the `vc-status-fileinfo' FILEINFO. | |
189 ;; If a backend needs to show more information than the default FILE | |
190 ;; and STATE in the vc-status listing, it can store that extra | |
191 ;; information in `vc-status-fileinfo->extra'. This function can be | |
192 ;; used to display that extra information in the vc-status buffer. | |
185 ;; | 193 ;; |
186 ;; * working-revision (file) | 194 ;; * working-revision (file) |
187 ;; | 195 ;; |
188 ;; Return the working revision of FILE. This is the revision fetched | 196 ;; Return the working revision of FILE. This is the revision fetched |
189 ;; by the last checkout or upate, not necessarily the same thing as the | 197 ;; by the last checkout or upate, not necessarily the same thing as the |
2642 ;;; Experimental code for the vc-dired replacement | 2650 ;;; Experimental code for the vc-dired replacement |
2643 (require 'ewoc) | 2651 (require 'ewoc) |
2644 | 2652 |
2645 (defstruct (vc-status-fileinfo | 2653 (defstruct (vc-status-fileinfo |
2646 (:copier nil) | 2654 (:copier nil) |
2647 (:constructor vc-status-create-fileinfo (state name &optional marked)) | 2655 (:constructor |
2656 vc-status-create-fileinfo (name state extra &optional marked)) | |
2648 (:conc-name vc-status-fileinfo->)) | 2657 (:conc-name vc-status-fileinfo->)) |
2649 marked | 2658 marked |
2650 state | 2659 state |
2651 name) | 2660 name |
2661 ;; For storing backend specific information. | |
2662 extra) | |
2652 | 2663 |
2653 (defvar vc-status nil) | 2664 (defvar vc-status nil) |
2654 | 2665 |
2655 (defun vc-default-status-extra-headers (backend dir) | 2666 (defun vc-default-status-extra-headers (backend dir) |
2656 "Extra : Add backend specific headers here") | 2667 "Extra : Add backend specific headers here") |
2662 (propertize "Working dir: " 'face 'font-lock-type-face) | 2673 (propertize "Working dir: " 'face 'font-lock-type-face) |
2663 (propertize (format "%s\n" dir) 'face 'font-lock-variable-name-face) | 2674 (propertize (format "%s\n" dir) 'face 'font-lock-variable-name-face) |
2664 (vc-call-backend backend 'status-extra-headers dir) | 2675 (vc-call-backend backend 'status-extra-headers dir) |
2665 "\n")) | 2676 "\n")) |
2666 | 2677 |
2667 (defun vc-status-printer (fileentry) | 2678 (defun vc-default-status-printer (backend fileentry) |
2668 "Pretty print FILEENTRY." | 2679 "Pretty print FILEENTRY." |
2669 ;; If you change the layout here, change vc-status-move-to-goal-column. | 2680 ;; If you change the layout here, change vc-status-move-to-goal-column. |
2670 (let ((state (vc-status-fileinfo->state fileentry))) | 2681 (let ((state (vc-status-fileinfo->state fileentry))) |
2671 (insert | 2682 (insert |
2672 (propertize | 2683 (propertize |
2683 (propertize | 2694 (propertize |
2684 (format "%s" (vc-status-fileinfo->name fileentry)) | 2695 (format "%s" (vc-status-fileinfo->name fileentry)) |
2685 'face 'font-lock-function-name-face | 2696 'face 'font-lock-function-name-face |
2686 'mouse-face 'highlight)))) | 2697 'mouse-face 'highlight)))) |
2687 | 2698 |
2699 (defun vc-status-printer (fileentry) | |
2700 (let ((backend (vc-responsible-backend default-directory))) | |
2701 (vc-call-backend backend 'status-printer fileentry))) | |
2702 | |
2688 (defun vc-status-move-to-goal-column () | 2703 (defun vc-status-move-to-goal-column () |
2689 (beginning-of-line) | 2704 (beginning-of-line) |
2690 ;; Must be in sync with vc-status-printer. | 2705 ;; Must be in sync with vc-default-status-printer. |
2691 (forward-char 25)) | 2706 (forward-char 25)) |
2692 | 2707 |
2693 (defun vc-status-prepare-status-buffer (dir &optional create-new) | 2708 (defun vc-status-prepare-status-buffer (dir &optional create-new) |
2694 "Find a *vc-status* buffer showing DIR, or create a new one." | 2709 "Find a *vc-status* buffer showing DIR, or create a new one." |
2695 (setq dir (expand-file-name dir)) | 2710 (setq dir (expand-file-name dir)) |
2916 (defun vc-update-vc-status-buffer (entries buffer) | 2931 (defun vc-update-vc-status-buffer (entries buffer) |
2917 (with-current-buffer buffer | 2932 (with-current-buffer buffer |
2918 (when entries | 2933 (when entries |
2919 ;; Insert the entries we got into the ewoc. | 2934 ;; Insert the entries we got into the ewoc. |
2920 (dolist (entry entries) | 2935 (dolist (entry entries) |
2936 (let* ((file (car entry)) | |
2937 (entrycdr (cdr entry)) | |
2938 (state (if (listp entrycdr) (nth 1 entry))) | |
2939 (extra (if (listp entrycdr) (nth 2 entry)))) | |
2921 (ewoc-enter-last vc-status | 2940 (ewoc-enter-last vc-status |
2922 (vc-status-create-fileinfo (cdr entry) (car entry)))) | 2941 (vc-status-create-fileinfo file state extra)))) |
2923 ;; If we had marked items before the refresh, try mark them here. | 2942 ;; If we had marked items before the refresh, try mark them here. |
2924 ;; XXX: there should be a better way to do this... | 2943 ;; XXX: there should be a better way to do this... |
2925 (when vc-status-crt-marked | 2944 (when vc-status-crt-marked |
2926 (ewoc-map | 2945 (ewoc-map |
2927 (lambda (arg) | 2946 (lambda (arg) |
2952 ;; Found the file, just update the status. | 2971 ;; Found the file, just update the status. |
2953 (setf (vc-status-fileinfo->state (ewoc-data crt)) (cdr entry)) | 2972 (setf (vc-status-fileinfo->state (ewoc-data crt)) (cdr entry)) |
2954 (ewoc-invalidate vc-status crt)) | 2973 (ewoc-invalidate vc-status crt)) |
2955 ;; Could not find the file, insert a new entry. | 2974 ;; Could not find the file, insert a new entry. |
2956 (ewoc-enter-last | 2975 (ewoc-enter-last |
2957 vc-status (vc-status-create-fileinfo (cdr entry) (car entry))))))) | 2976 ;; XXX: `vc-status-fileinfo->extra' is not set here. |
2977 ;; It might need to be. | |
2978 vc-status | |
2979 (vc-status-create-fileinfo (car entry) (cdr entry) nil)))))) | |
2958 | 2980 |
2959 (defun vc-status-refresh () | 2981 (defun vc-status-refresh () |
2960 "Refresh the contents of the VC status buffer. | 2982 "Refresh the contents of the VC status buffer. |
2961 Throw an error if another update process is in progress." | 2983 Throw an error if another update process is in progress." |
2962 (interactive) | 2984 (interactive) |