From cb223bba1d6ce91c2da8a976898eca6bc4b36309 Mon Sep 17 00:00:00 2001 From: Dan Nicolaescu Date: Wed, 1 Aug 2007 17:13:45 +0000 Subject: [PATCH] * vc.el: Document new VC operation `extra-menu'. * vc-hooks.el (vc-default-extra-menu): New function. * menu-bar.el (menu-bar-vc-filter): New function. (menu-bar-tools-menu): Use it as a filter. --- etc/NEWS | 3 +++ lisp/ChangeLog | 10 ++++++++++ lisp/menu-bar.el | 14 +++++++++++++- lisp/vc-hooks.el | 3 +++ lisp/vc.el | 13 +++++++++++-- 5 files changed, 40 insertions(+), 3 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 09877e9518c..f56a7a0bf0c 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -96,6 +96,9 @@ considered for update. *** The VC mode-line entry now has a tooltip. +*** VC backends can provide extra menu entries to be added to the "Version Control" menu. +This can be used to add menu entries for backend specific functions. + *** VC has some support for Bazaar (bzr). ** sgml-electric-tag-pair-mode lets you simultaneously edit matched tag pairs. diff --git a/lisp/ChangeLog b/lisp/ChangeLog index dd1f8eeb22a..123c2cdc479 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,13 @@ +2007-08-01 Dan Nicolaescu + Stefan Monnier + + * vc.el: Document new VC operation `extra-menu'. + + * vc-hooks.el (vc-default-extra-menu): New function. + + * menu-bar.el (menu-bar-vc-filter): New function. + (menu-bar-tools-menu): Use it as a filter. + 2007-08-01 Glenn Morris * progmodes/fortran.el: Remove leading `*' from all defcustom doc diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el index d9f6405cf57..6b579763689 100644 --- a/lisp/menu-bar.el +++ b/lisp/menu-bar.el @@ -1165,7 +1165,19 @@ mail status in mode line")) (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)) + (list 'menu-item "Version Control" vc-menu-map + :filter 'menu-bar-vc-filter)) + +(defun menu-bar-vc-filter (orig-binding) + (let ((ext-binding + (if vc-mode (vc-call 'extra-menu buffer-file-name)))) + ;; 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)))) (define-key menu-bar-tools-menu [separator-compare] '("--")) diff --git a/lisp/vc-hooks.el b/lisp/vc-hooks.el index a8b6297caa2..18083f22e05 100644 --- a/lisp/vc-hooks.el +++ b/lisp/vc-hooks.el @@ -950,6 +950,9 @@ Used in `find-file-not-found-functions'." (define-key vc-menu-map [vc-next-action] '("Check In/Out" . vc-next-action)) (define-key vc-menu-map [vc-register] '("Register" . vc-register))) +(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 ;; on older systems. diff --git a/lisp/vc.el b/lisp/vc.el index 5030fb64471..78e098d874f 100644 --- a/lisp/vc.el +++ b/lisp/vc.el @@ -387,7 +387,7 @@ ;; ;; Only required if `annotate-command' is defined for the backend, ;; AND you'd like the current time considered to be anything besides -;; (vs-annotate-convert-time (current-time)) -- i.e. the current +;; (vc-annotate-convert-time (current-time)) -- i.e. the current ;; time with hours, minutes, and seconds included. Probably safe to ;; ignore. Return the current-time, in units of fractional days. ;; @@ -480,11 +480,20 @@ ;; ;; Operation called in current buffer when opening a file. This can ;; be used by the backend to setup some local variables it might need. -; +;; ;; - find-file-not-found-hook () ;; ;; 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: -- 2.39.5