comparison lisp/vc-hooks.el @ 82499:3ecf9562ce0b

(vc-menu-entry): New var. (vc-mode-line-map): Use it so that this menu also uses the extra-menu. (menu-bar-tools-menu): Add the VC menu here rather than in menu-bar.el. (vc-menu-map): Declare and initialize in one step. (vc-menu-map-filter): Move&rename from menu-bar.el:menu-bar-vc-filter
author Stefan Monnier <monnier@iro.umontreal.ca>
date Tue, 21 Aug 2007 15:07:36 +0000
parents e5a68f18fcb9
children 5c15d3c510b1
comparison
equal deleted inserted replaced
82498:e80c1b8b7d58 82499:3ecf9562ce0b
717 (if (featurep 'vc) 717 (if (featurep 'vc)
718 ;; If VC is not loaded, then there can't be 718 ;; If VC is not loaded, then there can't be
719 ;; any VC Dired buffer to synchronize. 719 ;; any VC Dired buffer to synchronize.
720 (vc-dired-resynch-file file))))) 720 (vc-dired-resynch-file file)))))
721 721
722 (defvar vc-menu-entry
723 '(menu-item "Version Control" vc-menu-map
724 :filter vc-menu-map-filter))
725
726 (when (boundp 'menu-bar-tools-menu)
727 ;; We do not need to worry here about the placement of this entry
728 ;; because menu-bar.el has already created the proper spot for us
729 ;; and this will simply use it.
730 (define-key menu-bar-tools-menu [vc] vc-menu-entry))
731
722 (defconst vc-mode-line-map 732 (defconst vc-mode-line-map
723 (let ((map (make-sparse-keymap))) 733 (let ((map (make-sparse-keymap)))
724 (define-key map [mode-line down-mouse-1] 'vc-menu-map) 734 (define-key map [mode-line down-mouse-1] vc-menu-entry)
725 map)) 735 map))
726 736
727 (defun vc-mode-line (file) 737 (defun vc-mode-line (file)
728 "Set `vc-mode' to display type of version control for FILE. 738 "Set `vc-mode' to display type of version control for FILE.
729 The value is set in the current buffer, which should be the buffer 739 The value is set in the current buffer, which should be the buffer
916 (define-key map "~" 'vc-version-other-window) 926 (define-key map "~" 'vc-version-other-window)
917 map)) 927 map))
918 (fset 'vc-prefix-map vc-prefix-map) 928 (fset 'vc-prefix-map vc-prefix-map)
919 (define-key global-map "\C-xv" 'vc-prefix-map) 929 (define-key global-map "\C-xv" 'vc-prefix-map)
920 930
921 (if (not (boundp 'vc-menu-map)) 931 (defvar vc-menu-map
922 ;; Don't do the menu bindings if menu-bar.el wasn't loaded to defvar 932 (let ((map (make-sparse-keymap "Version Control")))
923 ;; vc-menu-map. 933 ;;(define-key map [show-files]
924 () 934 ;; '("Show Files under VC" . (vc-directory t)))
925 ;;(define-key vc-menu-map [show-files] 935 (define-key map [vc-retrieve-snapshot]
926 ;; '("Show Files under VC" . (vc-directory t))) 936 '("Retrieve Snapshot" . vc-retrieve-snapshot))
927 (define-key vc-menu-map [vc-retrieve-snapshot] 937 (define-key map [vc-create-snapshot]
928 '("Retrieve Snapshot" . vc-retrieve-snapshot)) 938 '("Create Snapshot" . vc-create-snapshot))
929 (define-key vc-menu-map [vc-create-snapshot] 939 (define-key map [vc-directory] '("VC Directory Listing" . vc-directory))
930 '("Create Snapshot" . vc-create-snapshot)) 940 (define-key map [separator1] '("----"))
931 (define-key vc-menu-map [vc-directory] '("VC Directory Listing" . vc-directory)) 941 (define-key map [vc-annotate] '("Annotate" . vc-annotate))
932 (define-key vc-menu-map [separator1] '("----")) 942 (define-key map [vc-rename-file] '("Rename File" . vc-rename-file))
933 (define-key vc-menu-map [vc-annotate] '("Annotate" . vc-annotate)) 943 (define-key map [vc-version-other-window]
934 (define-key vc-menu-map [vc-rename-file] '("Rename File" . vc-rename-file)) 944 '("Show Other Version" . vc-version-other-window))
935 (define-key vc-menu-map [vc-version-other-window] 945 (define-key map [vc-diff] '("Compare with Base Version" . vc-diff))
936 '("Show Other Version" . vc-version-other-window)) 946 (define-key map [vc-update-change-log]
937 (define-key vc-menu-map [vc-diff] '("Compare with Base Version" . vc-diff)) 947 '("Update ChangeLog" . vc-update-change-log))
938 (define-key vc-menu-map [vc-update-change-log] 948 (define-key map [vc-print-log] '("Show History" . vc-print-log))
939 '("Update ChangeLog" . vc-update-change-log)) 949 (define-key map [separator2] '("----"))
940 (define-key vc-menu-map [vc-print-log] '("Show History" . vc-print-log)) 950 (define-key map [vc-insert-header]
941 (define-key vc-menu-map [separator2] '("----")) 951 '("Insert Header" . vc-insert-headers))
942 (define-key vc-menu-map [vc-insert-header] 952 (define-key map [undo] '("Undo Last Check-In" . vc-rollback))
943 '("Insert Header" . vc-insert-headers)) 953 (define-key map [vc-revert]
944 (define-key vc-menu-map [undo] '("Undo Last Check-In" . vc-rollback)) 954 '("Revert to Base Version" . vc-revert))
945 (define-key vc-menu-map [vc-revert] 955 (define-key map [vc-update]
946 '("Revert to Base Version" . vc-revert)) 956 '("Update to Latest Version" . vc-update))
947 (define-key vc-menu-map [vc-update] 957 (define-key map [vc-next-action] '("Check In/Out" . vc-next-action))
948 '("Update to Latest Version" . vc-update)) 958 (define-key map [vc-register] '("Register" . vc-register))
949 (define-key vc-menu-map [vc-next-action] '("Check In/Out" . vc-next-action)) 959 map))
950 (define-key vc-menu-map [vc-register] '("Register" . vc-register))) 960
961 (defalias 'vc-menu-map vc-menu-map)
962
963 (defun vc-menu-map-filter (orig-binding)
964 (if (and (symbolp orig-binding) (fboundp orig-binding))
965 (setq orig-binding (indirect-function orig-binding)))
966 (let ((ext-binding
967 (if vc-mode (vc-call-backend (vc-backend buffer-file-name) 'extra-menu))))
968 ;; Give the VC backend a chance to add menu entries
969 ;; specific for that backend.
970 (if (null ext-binding)
971 orig-binding
972 (append orig-binding
973 '((ext-menu-separator "---"))
974 ext-binding))))
951 975
952 (defun vc-default-extra-menu (backend) 976 (defun vc-default-extra-menu (backend)
953 nil) 977 nil)
954 978
955 ;; These are not correct and it's not currently clear how doing it 979 ;; These are not correct and it's not currently clear how doing it