]> git.eshelyaron.com Git - emacs.git/commitdiff
* vc-arch.el (vc-arch-extra-menu-map): New var and fun.
authorDan Nicolaescu <dann@ics.uci.edu>
Tue, 18 Sep 2007 01:28:25 +0000 (01:28 +0000)
committerDan Nicolaescu <dann@ics.uci.edu>
Tue, 18 Sep 2007 01:28:25 +0000 (01:28 +0000)
* vc-hooks.el (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.

* menu-bar.el (vc-menu-map): Don't setup any more.
Instead, just create the proper spot in the menu.

* vc.el: Document new VC operation `extra-menu'.

* vc-hooks.el (vc-default-extra-menu, vc-menu-map-filter): New
function.

lisp/ChangeLog
lisp/menu-bar.el
lisp/vc-arch.el
lisp/vc-hooks.el
lisp/vc.el

index adab960465955afe92fe5711377369dfcae7df14..dffaebff3c056be418c2c3e3cdab3e7235aa1619 100644 (file)
@@ -1,3 +1,23 @@
+2007-09-18  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * vc-arch.el (vc-arch-extra-menu-map): New var and fun.
+
+       * vc-hooks.el (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.
+
+       * menu-bar.el (vc-menu-map): Don't setup any more.
+       Instead, just create the proper spot in the menu.
+
+2007-09-18  Dan Nicolaescu  <dann@ics.uci.edu>
+           Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * vc.el: Document new VC operation `extra-menu'.
+
+       * vc-hooks.el (vc-default-extra-menu, vc-menu-map-filter): New
+       function.
+
 2007-09-17  Dan Nicolaescu  <dann@ics.uci.edu>
 
        * vc-git.el (vc-git-log-view-mode): Add font-lock patterns for
index 0c9ff964e3066d33799aacf0eff7ec66bf765f52..eca8d40d7b38722421abbb9ff9496141691603f4 100644 (file)
@@ -1160,11 +1160,9 @@ mail status in mode line"))
 (define-key menu-bar-tools-menu [separator-vc]
   '("--"))
 
-(defvar vc-menu-map (make-sparse-keymap "Version Control"))
 (define-key menu-bar-tools-menu [pcl-cvs]
   '(menu-item "PCL-CVS" cvs-global-menu))
-(define-key menu-bar-tools-menu [vc]
-  (list 'menu-item "Version Control" vc-menu-map))
+(define-key menu-bar-tools-menu [vc] nil) ;Create the place for the VC menu.
 
 (define-key menu-bar-tools-menu [separator-compare]
   '("--"))
index 68a1b1b5f17b85daeae4137845d7df144669310a..36cb9d616da546c79b7ba00e22034b943afe37b7 100644 (file)
@@ -444,6 +444,15 @@ Return non-nil if FILE is unchanged."
              (table (vc-arch--version-completion-table root string)))
        (complete-with-action action table string pred)))))
 
+(defvar vc-arch-extra-menu-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map [add-tagline]
+      '(menu-item "Add tagline" vc-arch-add-tagline))
+    map))
+
+(defun vc-arch-extra-menu () vc-arch-extra-menu-map)
+  
+
 ;;; Less obvious implementations.
 
 (defun vc-arch-find-version (file rev buffer)
index 0af0d7546a793abe97ba6dee0461467d27a3b5ea..6684190e3d20fc190b06ccb64f9bddfbaf42289e 100644 (file)
@@ -707,6 +707,21 @@ Before doing that, check if there are any old backups and get rid of them."
             ;; any VC Dired buffer to synchronize.
             (vc-dired-resynch-file file)))))
 
+(defvar vc-menu-entry
+  '(menu-item "Version Control" vc-menu-map
+    :filter vc-menu-map-filter))
+
+(when (boundp 'menu-bar-tools-menu)
+  ;; We do not need to worry here about the placement of this entry
+  ;; because menu-bar.el has already created the proper spot for us
+  ;; and this will simply use it.
+  (define-key menu-bar-tools-menu [vc] vc-menu-entry))
+
+(defconst vc-mode-line-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map [mode-line down-mouse-1] vc-menu-entry)
+    map))
+
 (defun vc-mode-line (file)
   "Set `vc-mode' to display type of version control for FILE.
 The value is set in the current buffer, which should be the buffer
@@ -880,36 +895,54 @@ Used in `find-file-not-found-functions'."
 (fset 'vc-prefix-map vc-prefix-map)
 (define-key global-map "\C-xv" 'vc-prefix-map)
 
-(if (not (boundp 'vc-menu-map))
-    ;; Don't do the menu bindings if menu-bar.el wasn't loaded to defvar
-    ;; vc-menu-map.
-    ()
-  ;;(define-key vc-menu-map [show-files]
-  ;;  '("Show Files under VC" . (vc-directory t)))
-  (define-key vc-menu-map [vc-retrieve-snapshot]
-    '("Retrieve Snapshot" . vc-retrieve-snapshot))
-  (define-key vc-menu-map [vc-create-snapshot]
-    '("Create Snapshot" . vc-create-snapshot))
-  (define-key vc-menu-map [vc-directory] '("VC Directory Listing" . vc-directory))
-  (define-key vc-menu-map [separator1] '("----"))
-  (define-key vc-menu-map [vc-annotate] '("Annotate" . vc-annotate))
-  (define-key vc-menu-map [vc-rename-file] '("Rename File" . vc-rename-file))
-  (define-key vc-menu-map [vc-version-other-window]
-    '("Show Other Version" . vc-version-other-window))
-  (define-key vc-menu-map [vc-diff] '("Compare with Base Version" . vc-diff))
-  (define-key vc-menu-map [vc-update-change-log]
-    '("Update ChangeLog" . vc-update-change-log))
-  (define-key vc-menu-map [vc-print-log] '("Show History" . vc-print-log))
-  (define-key vc-menu-map [separator2] '("----"))
-  (define-key vc-menu-map [vc-insert-header]
-    '("Insert Header" . vc-insert-headers))
-  (define-key vc-menu-map [undo] '("Undo Last Check-In" . vc-cancel-version))
-  (define-key vc-menu-map [vc-revert-buffer]
-    '("Revert to Base Version" . vc-revert-buffer))
-  (define-key vc-menu-map [vc-update]
-    '("Update to Latest Version" . vc-update))
-  (define-key vc-menu-map [vc-next-action] '("Check In/Out" . vc-next-action))
-  (define-key vc-menu-map [vc-register] '("Register" . vc-register)))
+(defvar vc-menu-map
+  (let ((map (make-sparse-keymap "Version Control")))
+    ;;(define-key map [show-files]
+    ;;  '("Show Files under VC" . (vc-directory t)))
+    (define-key map [vc-retrieve-snapshot]
+      '("Retrieve Snapshot" . vc-retrieve-snapshot))
+    (define-key map [vc-create-snapshot]
+      '("Create Snapshot" . vc-create-snapshot))
+    (define-key map [vc-directory] '("VC Directory Listing" . vc-directory))
+    (define-key map [separator1] '("----"))
+    (define-key map [vc-annotate] '("Annotate" . vc-annotate))
+    (define-key map [vc-rename-file] '("Rename File" . vc-rename-file))
+    (define-key map [vc-version-other-window]
+      '("Show Other Version" . vc-version-other-window))
+    (define-key map [vc-diff] '("Compare with Base Version" . vc-diff))
+    (define-key map [vc-update-change-log]
+      '("Update ChangeLog" . vc-update-change-log))
+    (define-key map [vc-print-log] '("Show History" . vc-print-log))
+    (define-key map [separator2] '("----"))
+    (define-key map [vc-insert-header]
+      '("Insert Header" . vc-insert-headers))
+    (define-key map [undo] '("Undo Last Check-In" . vc-cancel-version))
+    (define-key map [vc-revert-buffer]
+      '("Revert to Base Version" . vc-revert-buffer))
+    (define-key map [vc-update]
+      '("Update to Latest Version" . vc-update))
+    (define-key map [vc-next-action] '("Check In/Out" . vc-next-action))
+    (define-key map [vc-register] '("Register" . vc-register))
+    map))
+
+(defalias 'vc-menu-map vc-menu-map)
+
+(defun vc-menu-map-filter (orig-binding)
+  (if (and (symbolp orig-binding) (fboundp orig-binding))
+      (setq orig-binding (indirect-function orig-binding)))
+  (let ((ext-binding
+         (if vc-mode (vc-call-backend (vc-backend buffer-file-name)
+                                      'extra-menu))))
+    ;; Give the VC backend a chance to add menu entries
+    ;; specific for that backend.
+    (if (null ext-binding)
+        orig-binding
+      (append orig-binding
+             '((ext-menu-separator "---"))
+              ext-binding))))
+
+(defun vc-default-extra-menu (backend)
+  nil)
 
 ;; These are not correct and it's not currently clear how doing it
 ;; better (with more complicated expressions) might slow things down
index 6a0adc248dae19c9833fd0bd5c7d592bb539d9ca..e0d15f374da8095451c21e4b17c1ef048bc79831 100644 (file)
 ;;
 ;;   Operation called in current buffer when opening a non-existing file.
 ;;   By default, this asks the user if she wants to check out the file.
+;;
+;; - extra-menu ()
+;;
+;;   Return a menu keymap, the items in the keymap will appear at the
+;;   end of the Version Control menu.  The goal is to allow backends
+;;   to specify extra menu items that appear in the VC menu.  This way
+;;   you can provide menu entries for functionality that is specific
+;;   to your backend and which does not map to any of the VC generic
+;;   concepts.
 
 ;;; Code: