aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Nicolaescu2008-03-23 18:12:18 +0000
committerDan Nicolaescu2008-03-23 18:12:18 +0000
commitd39730b89520fe99363728c744f345446197ee00 (patch)
treea425450820cd8fae50d12312ae96c731341db537
parentcc48343f9927d807154e2331db6102a3f521cf7c (diff)
downloademacs-d39730b89520fe99363728c744f345446197ee00.tar.gz
emacs-d39730b89520fe99363728c744f345446197ee00.zip
(vc-status-prepare-status-buffer): Fix thinko.
(vc-status-menu-map): Add binding for vc-status-kill-dir-status-process. Add :enable for vc-status-refresh. (vc-status-menu-map-filter): Remove vc-ignore-menu-filter test. (vc-status-tool-bar-map): Add binding for vc-status-kill-dir-status-process. Don't test display-graphic-p and don't bind vc-ignore-menu-filter. (vc-update-vc-status-buffer, vc-status-kill-dir-status-process): Reset vc-status-process-buffer. (vc-status-refresh): Don't run two refreshes at a time. (vc-status): If the buffer is already in vc-status-mode only refresh.
-rw-r--r--lisp/ChangeLog13
-rw-r--r--lisp/vc.el202
2 files changed, 119 insertions, 96 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 4f726a0824f..18cf78e04cb 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,16 @@
12008-03-23 Dan Nicolaescu <dann@ics.uci.edu>
2
3 * vc.el (vc-status-prepare-status-buffer): Fix thinko.
4 (vc-status-menu-map): Add binding for
5 vc-status-kill-dir-status-process. Add :enable for vc-status-refresh.
6 (vc-status-menu-map-filter): Remove vc-ignore-menu-filter test.
7 (vc-status-tool-bar-map): Add binding for vc-status-kill-dir-status-process.
8 Don't test display-graphic-p and don't bind vc-ignore-menu-filter.
9 (vc-update-vc-status-buffer, vc-status-kill-dir-status-process):
10 Reset vc-status-process-buffer.
11 (vc-status-refresh): Don't run two refreshes at a time.
12 (vc-status): If the buffer is already in vc-status-mode only refresh.
13
12008-03-23 Andreas Schwab <schwab@suse.de> 142008-03-23 Andreas Schwab <schwab@suse.de>
2 15
3 * menu-bar.el (menu-bar-showhide-fringe-ind-menu) [mixed]: Fix 16 * menu-bar.el (menu-bar-showhide-fringe-ind-menu) [mixed]: Fix
diff --git a/lisp/vc.el b/lisp/vc.el
index c50b72f7d3f..d849fc22d34 100644
--- a/lisp/vc.el
+++ b/lisp/vc.el
@@ -2670,7 +2670,7 @@ With prefix arg READ-SWITCHES, specify a value to override
2670 " " 2670 " "
2671 (propertize 2671 (propertize
2672 (format "%-20s" state) 2672 (format "%-20s" state)
2673 'face (if (eq state 'up-to-date) 2673 'face (if (eq state 'up-to-date)
2674 'font-lock-builtin-face 2674 'font-lock-builtin-face
2675 'font-lock-variable-name-face) 2675 'font-lock-variable-name-face)
2676 'mouse-face 'highlight) 2676 'mouse-face 'highlight)
@@ -2688,90 +2688,99 @@ With prefix arg READ-SWITCHES, specify a value to override
2688(defun vc-status-prepare-status-buffer (dir &optional create-new) 2688(defun vc-status-prepare-status-buffer (dir &optional create-new)
2689 "Find a *vc-status* buffer showing DIR, or create a new one." 2689 "Find a *vc-status* buffer showing DIR, or create a new one."
2690 (setq dir (expand-file-name dir)) 2690 (setq dir (expand-file-name dir))
2691 (let ((bname "*vc-status*")) 2691 (let* ((bname "*vc-status*")
2692 ;; Look for another *vc-status* buffer visiting the same directory. 2692 ;; Look for another *vc-status* buffer visiting the same directory.
2693 (save-excursion 2693 (buf (save-excursion
2694 (unless create-new 2694 (unless create-new
2695 (dolist (buffer (buffer-list)) 2695 (dolist (buffer (buffer-list))
2696 (set-buffer buffer) 2696 (set-buffer buffer)
2697 (when (and (eq major-mode 'vc-status-mode) 2697 (when (and (eq major-mode 'vc-status-mode)
2698 (string= default-directory dir)) 2698 (string= (expand-file-name default-directory) dir))
2699 (return buffer))))) 2699 (return buffer)))))))
2700 ;; Create a new *vc-status* buffer. 2700 (if buf
2701 (with-current-buffer (create-file-buffer bname) 2701 buf
2702 (cd dir) 2702 ;; Create a new *vc-status* buffer.
2703 (vc-setup-buffer (current-buffer)) 2703 (with-current-buffer (create-file-buffer bname)
2704 (current-buffer)))) 2704 (cd dir)
2705 (vc-setup-buffer (current-buffer))
2706 (current-buffer)))))
2705 2707
2706;;;###autoload 2708;;;###autoload
2707(defun vc-status (dir) 2709(defun vc-status (dir)
2708 "Show the VC status for DIR." 2710 "Show the VC status for DIR."
2709 (interactive "DVC status for directory: ") 2711 (interactive "DVC status for directory: ")
2710 (switch-to-buffer (vc-status-prepare-status-buffer dir)) 2712 (switch-to-buffer (vc-status-prepare-status-buffer dir))
2711 (vc-status-mode)) 2713 (if (eq major-mode 'vc-status-mode)
2714 (vc-status-refresh)
2715 (vc-status-mode)))
2712 2716
2713(defvar vc-status-menu-map 2717(defvar vc-status-menu-map
2714 (let ((map (make-sparse-keymap "VC-status"))) 2718 (let ((map (make-sparse-keymap "VC-status")))
2715 (define-key map [quit] 2719 (define-key map [quit]
2716 '(menu-item "Quit" bury-buffer 2720 '(menu-item "Quit" bury-buffer
2717 :help "Quit")) 2721 :help "Quit"))
2718 (define-key map [refresh] 2722 (define-key map [kill]
2723 '(menu-item "Kill Update Command" vc-status-kill-dir-status-process
2724 :enable vc-status-process-buffer
2725 :help "Kill the command that updates VC status buffer"))
2726 (define-key map [refresh]
2719 '(menu-item "Refresh" vc-status-refresh 2727 '(menu-item "Refresh" vc-status-refresh
2728 :enable (not vc-status-process-buffer)
2720 :help "Refresh the contents of the VC status buffer")) 2729 :help "Refresh the contents of the VC status buffer"))
2721 (define-key map [remup] 2730 (define-key map [remup]
2722 '(menu-item "Remove up-to-date" vc-status-remove-up-to-date 2731 '(menu-item "Remove up-to-date" vc-status-remove-up-to-date
2723 :help "Remove up-to-date items from display")) 2732 :help "Remove up-to-date items from display"))
2724 ;; VC commands. 2733 ;; VC commands.
2725 (define-key map [separator-vc-commands] '("--")) 2734 (define-key map [separator-vc-commands] '("--"))
2726 (define-key map [annotate] 2735 (define-key map [annotate]
2727 '(menu-item "Annotate" vc-annotate 2736 '(menu-item "Annotate" vc-annotate
2728 :help "Display the edit history of the current file using colors")) 2737 :help "Display the edit history of the current file using colors"))
2729 (define-key map [diff] 2738 (define-key map [diff]
2730 '(menu-item "Compare with Base Version" vc-diff 2739 '(menu-item "Compare with Base Version" vc-diff
2731 :help "Compare file set with the base version")) 2740 :help "Compare file set with the base version"))
2732 (define-key map [register] 2741 (define-key map [register]
2733 '(menu-item "Register" vc-status-register 2742 '(menu-item "Register" vc-status-register
2734 :help "Register file set into the version control system")) 2743 :help "Register file set into the version control system"))
2735 ;; vc-print-log uses the current buffer, not a file. 2744 ;; vc-print-log uses the current buffer, not a file.
2736 ;; (define-key map [log] 2745 ;; (define-key map [log]
2737 ;; '(menu-item "Show history" vc-status-print-log 2746 ;; '(menu-item "Show history" vc-status-print-log
2738 ;; :help "List the change log of the current file set in a window")) 2747 ;; :help "List the change log of the current file set in a window"))
2739 2748
2740 ;; Movement. 2749 ;; Movement.
2741 (define-key map [separator-movement] '("--")) 2750 (define-key map [separator-movement] '("--"))
2742 (define-key map [next-line] 2751 (define-key map [next-line]
2743 '(menu-item "Next line" vc-status-next-line 2752 '(menu-item "Next line" vc-status-next-line
2744 :help "Go to the next line" :keys "n")) 2753 :help "Go to the next line" :keys "n"))
2745 (define-key map [previous-line] 2754 (define-key map [previous-line]
2746 '(menu-item "Previous line" vc-status-previous-line 2755 '(menu-item "Previous line" vc-status-previous-line
2747 :help "Go to the previous line")) 2756 :help "Go to the previous line"))
2748 ;; Marking. 2757 ;; Marking.
2749 (define-key map [separator-marking] '("--")) 2758 (define-key map [separator-marking] '("--"))
2750 (define-key map [unmark-all] 2759 (define-key map [unmark-all]
2751 '(menu-item "Unmark All" vc-status-unmark-all-files 2760 '(menu-item "Unmark All" vc-status-unmark-all-files
2752 :help "Unmark all files that are in the same state as the current file\ 2761 :help "Unmark all files that are in the same state as the current file\
2753\nWith prefix argument unmark all files")) 2762\nWith prefix argument unmark all files"))
2754 (define-key map [unmark-previous] 2763 (define-key map [unmark-previous]
2755 '(menu-item "Unmark previous " vc-status-unmark-file-up 2764 '(menu-item "Unmark previous " vc-status-unmark-file-up
2756 :help "Move to the previous line and unmark the file")) 2765 :help "Move to the previous line and unmark the file"))
2757 2766
2758 (define-key map [mark-all] 2767 (define-key map [mark-all]
2759 '(menu-item "Mark All" vc-status-mark-all-files 2768 '(menu-item "Mark All" vc-status-mark-all-files
2760 :help "Mark all files that are in the same state as the current file\ 2769 :help "Mark all files that are in the same state as the current file\
2761\nWith prefix argument mark all files")) 2770\nWith prefix argument mark all files"))
2762 (define-key map [unmark] 2771 (define-key map [unmark]
2763 '(menu-item "Unmark" vc-status-unmark 2772 '(menu-item "Unmark" vc-status-unmark
2764 :help "Unmark the current file or all files in the region")) 2773 :help "Unmark the current file or all files in the region"))
2765 2774
2766 (define-key map [mark] 2775 (define-key map [mark]
2767 '(menu-item "Mark" vc-status-mark 2776 '(menu-item "Mark" vc-status-mark
2768 :help "Mark the current file or all files in the region")) 2777 :help "Mark the current file or all files in the region"))
2769 2778
2770 (define-key map [separator-open] '("--")) 2779 (define-key map [separator-open] '("--"))
2771 (define-key map [open-other] 2780 (define-key map [open-other]
2772 '(menu-item "Open in other window" vc-status-find-file-other-window 2781 '(menu-item "Open in other window" vc-status-find-file-other-window
2773 :help "Find the file on the current line, in another window")) 2782 :help "Find the file on the current line, in another window"))
2774 (define-key map [open] 2783 (define-key map [open]
2775 '(menu-item "Open file" vc-status-find-file 2784 '(menu-item "Open file" vc-status-find-file
2776 :help "Find the file on the current line")) 2785 :help "Find the file on the current line"))
2777 map) 2786 map)
@@ -2825,18 +2834,16 @@ With prefix arg READ-SWITCHES, specify a value to override
2825 nil) 2834 nil)
2826 2835
2827(defun vc-status-menu-map-filter (orig-binding) 2836(defun vc-status-menu-map-filter (orig-binding)
2828 (if (boundp 'vc-ignore-menu-filter) 2837 (when (and (symbolp orig-binding) (fboundp orig-binding))
2829 orig-binding 2838 (setq orig-binding (indirect-function orig-binding)))
2830 (when (and (symbolp orig-binding) (fboundp orig-binding)) 2839 (let ((ext-binding
2831 (setq orig-binding (indirect-function orig-binding))) 2840 (vc-call-backend (vc-responsible-backend default-directory)
2832 (let ((ext-binding 2841 'extra-status-menu)))
2833 (vc-call-backend (vc-responsible-backend default-directory) 2842 (if (null ext-binding)
2834 'extra-status-menu))) 2843 orig-binding
2835 (if (null ext-binding) 2844 (append orig-binding
2836 orig-binding 2845 '("----")
2837 (append orig-binding 2846 ext-binding))))
2838 '("----")
2839 ext-binding)))))
2840 2847
2841(defun vc-status-menu (e) 2848(defun vc-status-menu (e)
2842 "Popup the VC status menu." 2849 "Popup the VC status menu."
@@ -2844,29 +2851,28 @@ With prefix arg READ-SWITCHES, specify a value to override
2844 (popup-menu vc-status-menu-map e)) 2851 (popup-menu vc-status-menu-map e))
2845 2852
2846(defvar vc-status-tool-bar-map 2853(defvar vc-status-tool-bar-map
2847 (if (display-graphic-p) 2854 (let ((map (make-sparse-keymap)))
2848 (let ((map (make-sparse-keymap)) 2855 (tool-bar-local-item-from-menu 'vc-status-find-file "open"
2849 (vc-ignore-menu-filter t)) ;; Backend may not support vc-status 2856 map vc-status-mode-map)
2850 (tool-bar-local-item-from-menu 'vc-status-find-file "open" 2857 (tool-bar-local-item "bookmark_add"
2851 map vc-status-mode-map) 2858 'vc-status-toggle-mark 'vc-status-toggle-mark map
2852 (tool-bar-local-item "bookmark_add" 2859 :help "Toggle mark on current item")
2853 'vc-status-toggle-mark 'vc-status-toggle-mark map 2860 (tool-bar-local-item-from-menu 'vc-status-previous-line "left-arrow"
2854 :help "Toggle mark on current item") 2861 map vc-status-mode-map
2855 (tool-bar-local-item-from-menu 'vc-status-previous-line "left-arrow" 2862 :rtl "right-arrow")
2856 map vc-status-mode-map 2863 (tool-bar-local-item-from-menu 'vc-status-next-line "right-arrow"
2857 :rtl "right-arrow") 2864 map vc-status-mode-map
2858 (tool-bar-local-item-from-menu 'vc-status-next-line "right-arrow" 2865 :rtl "left-arrow")
2859 map vc-status-mode-map 2866 (tool-bar-local-item-from-menu 'vc-status-refresh "refresh"
2860 :rtl "left-arrow") 2867 map vc-status-mode-map)
2861 (tool-bar-local-item-from-menu 'vc-status-refresh "refresh" 2868 (tool-bar-local-item-from-menu 'nonincremental-search-forward
2862 map vc-status-mode-map) 2869 "search" map)
2863 (tool-bar-local-item-from-menu 'nonincremental-search-forward 2870 (tool-bar-local-item-from-menu 'vc-status-kill-dir-status-process "cancel"
2864 "search" map) 2871 map vc-status-mode-map)
2865 (tool-bar-local-item-from-menu 'bury-buffer "exit" 2872 (tool-bar-local-item-from-menu 'bury-buffer "exit"
2866 map vc-status-mode-map) 2873 map vc-status-mode-map)
2867 map))) 2874 map))
2868 2875
2869
2870(defvar vc-status-process-buffer nil 2876(defvar vc-status-process-buffer nil
2871 "The buffer used for the asynchronous call that computes the VC status.") 2877 "The buffer used for the asynchronous call that computes the VC status.")
2872 2878
@@ -2911,11 +2917,12 @@ With prefix arg READ-SWITCHES, specify a value to override
2911 (setf (vc-status-fileinfo->marked arg) t))) 2917 (setf (vc-status-fileinfo->marked arg) t)))
2912 vc-status)) 2918 vc-status))
2913 (ewoc-goto-node vc-status (ewoc-nth vc-status 0))) 2919 (ewoc-goto-node vc-status (ewoc-nth vc-status 0)))
2914 ;; We are done, turn of the in progress message in the mode-line. 2920 (setq vc-status-process-buffer nil)
2921 ;; We are done, turn off the mode-line "in progress" message.
2915 (setq mode-line-process nil))) 2922 (setq mode-line-process nil)))
2916 2923
2917(defun vc-status-add-entry (entry buffer) 2924(defun vc-status-add-entry (entry buffer)
2918 ;; Add one ENTRY to the vc-status buffer BUFFER. 2925 ;; Add one ENTRY to the vc-status buffer BUFFER.
2919 ;; This will be used to automatically add files with the "modified" 2926 ;; This will be used to automatically add files with the "modified"
2920 ;; state when saving them. 2927 ;; state when saving them.
2921 2928
@@ -2925,11 +2932,11 @@ With prefix arg READ-SWITCHES, specify a value to override
2925 (fname (car entry))) 2932 (fname (car entry)))
2926 ;; First try to see if there's already an entry with that name 2933 ;; First try to see if there's already an entry with that name
2927 ;; in the ewoc. 2934 ;; in the ewoc.
2928 (while (and crt (not (string= (vc-status-fileinfo->name 2935 (while (and crt (not (string= (vc-status-fileinfo->name
2929 (ewoc-data crt)) fname))) 2936 (ewoc-data crt)) fname)))
2930 (setq crt (ewoc-next vc-status crt))) 2937 (setq crt (ewoc-next vc-status crt)))
2931 (if crt 2938 (if crt
2932 (progn 2939 (progn
2933 ;; Found the file, just update the status. 2940 ;; Found the file, just update the status.
2934 (setf (vc-status-fileinfo->state (ewoc-data crt)) (cdr entry)) 2941 (setf (vc-status-fileinfo->state (ewoc-data crt)) (cdr entry))
2935 (ewoc-invalidate vc-status crt)) 2942 (ewoc-invalidate vc-status crt))
@@ -2938,39 +2945,42 @@ With prefix arg READ-SWITCHES, specify a value to override
2938 vc-status (vc-status-create-fileinfo (cdr entry) (car entry))))))) 2945 vc-status (vc-status-create-fileinfo (cdr entry) (car entry)))))))
2939 2946
2940(defun vc-status-refresh () 2947(defun vc-status-refresh ()
2941 "Refresh the contents of the VC status buffer." 2948 "Refresh the contents of the VC status buffer.
2949Throw an error if another update process is in progress."
2942 (interactive) 2950 (interactive)
2943 2951 (if vc-status-process-buffer
2944 ;; This is not very efficient; ewoc could use a new function here. 2952 (error "Another update process is in progress, cannot run two at a time")
2945 ;; We clear the ewoc, but remember the marked files so that we can 2953 ;; This is not very efficient; ewoc could use a new function here.
2946 ;; mark them after the refresh is done. 2954 ;; We clear the ewoc, but remember the marked files so that we can
2947 (setq vc-status-crt-marked 2955 ;; mark them after the refresh is done.
2948 (mapcar 2956 (setq vc-status-crt-marked
2949 (lambda (elem) 2957 (mapcar
2950 (vc-status-fileinfo->name elem)) 2958 (lambda (elem)
2951 (ewoc-collect 2959 (vc-status-fileinfo->name elem))
2952 vc-status 2960 (ewoc-collect
2953 (lambda (crt) (vc-status-fileinfo->marked crt))))) 2961 vc-status
2954 (ewoc-filter vc-status (lambda (node) nil)) 2962 (lambda (crt) (vc-status-fileinfo->marked crt)))))
2955 2963 (ewoc-filter vc-status (lambda (node) nil))
2956 (let ((backend (vc-responsible-backend default-directory))) 2964
2957 (vc-set-mode-line-busy-indicator) 2965 (let ((backend (vc-responsible-backend default-directory)))
2958 ;; Call the dir-status backend function. dir-status is supposed to 2966 (vc-set-mode-line-busy-indicator)
2959 ;; be asynchronous. It should compute the results and call the 2967 ;; Call the dir-status backend function. dir-status is supposed to
2960 ;; function passed as a an arg to update the vc-status buffer with 2968 ;; be asynchronous. It should compute the results and call the
2961 ;; the results. 2969 ;; function passed as a an arg to update the vc-status buffer with
2962 (setq vc-status-process-buffer 2970 ;; the results.
2963 (vc-call-backend 2971 (setq vc-status-process-buffer
2964 backend 'dir-status default-directory 2972 (vc-call-backend
2965 #'vc-update-vc-status-buffer (current-buffer))))) 2973 backend 'dir-status default-directory
2974 #'vc-update-vc-status-buffer (current-buffer))))))
2966 2975
2967(defun vc-status-kill-dir-status-process () 2976(defun vc-status-kill-dir-status-process ()
2968 "Kill the temporary buffer and associated process." 2977 "Kill the temporary buffer and associated process."
2969 (interactive) 2978 (interactive)
2970 (when (and (bufferp vc-status-process-buffer) 2979 (when (and (bufferp vc-status-process-buffer)
2971 (buffer-live-p vc-status-process-buffer)) 2980 (buffer-live-p vc-status-process-buffer))
2972 (let ((proc (get-buffer-process vc-status-process-buffer))) 2981 (let ((proc (get-buffer-process vc-status-process-buffer)))
2973 (when proc (delete-process proc)) 2982 (when proc (delete-process proc))
2983 (setq vc-status-process-buffer nil)
2974 (setq mode-line-process nil)))) 2984 (setq mode-line-process nil))))
2975 2985
2976(defun vc-status-next-line (arg) 2986(defun vc-status-next-line (arg)