diff options
| author | Dan Nicolaescu | 2007-09-18 01:28:25 +0000 |
|---|---|---|
| committer | Dan Nicolaescu | 2007-09-18 01:28:25 +0000 |
| commit | 793a22023e753cb9eddbde2d937b88026904f1a6 (patch) | |
| tree | 3c09473fb6f71cd46cf9509547b0eb9b32d3baf9 | |
| parent | 7262a148b6c23cd8c00d4c0e6a5c66410a98bf81 (diff) | |
| download | emacs-793a22023e753cb9eddbde2d937b88026904f1a6.tar.gz emacs-793a22023e753cb9eddbde2d937b88026904f1a6.zip | |
* 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.
* vc.el: Document new VC operation `extra-menu'.
* vc-hooks.el (vc-default-extra-menu, vc-menu-map-filter): New
function.
| -rw-r--r-- | lisp/ChangeLog | 20 | ||||
| -rw-r--r-- | lisp/menu-bar.el | 4 | ||||
| -rw-r--r-- | lisp/vc-arch.el | 9 | ||||
| -rw-r--r-- | lisp/vc-hooks.el | 93 | ||||
| -rw-r--r-- | lisp/vc.el | 9 |
5 files changed, 102 insertions, 33 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index adab9604659..dffaebff3c0 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,23 @@ | |||
| 1 | 2007-09-18 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * vc-arch.el (vc-arch-extra-menu-map): New var and fun. | ||
| 4 | |||
| 5 | * vc-hooks.el (vc-menu-entry): New var. | ||
| 6 | (vc-mode-line-map): Use it so that this menu also uses the extra-menu. | ||
| 7 | (menu-bar-tools-menu): Add the VC menu here rather than in menu-bar.el. | ||
| 8 | (vc-menu-map): Declare and initialize in one step. | ||
| 9 | |||
| 10 | * menu-bar.el (vc-menu-map): Don't setup any more. | ||
| 11 | Instead, just create the proper spot in the menu. | ||
| 12 | |||
| 13 | 2007-09-18 Dan Nicolaescu <dann@ics.uci.edu> | ||
| 14 | Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 15 | |||
| 16 | * vc.el: Document new VC operation `extra-menu'. | ||
| 17 | |||
| 18 | * vc-hooks.el (vc-default-extra-menu, vc-menu-map-filter): New | ||
| 19 | function. | ||
| 20 | |||
| 1 | 2007-09-17 Dan Nicolaescu <dann@ics.uci.edu> | 21 | 2007-09-17 Dan Nicolaescu <dann@ics.uci.edu> |
| 2 | 22 | ||
| 3 | * vc-git.el (vc-git-log-view-mode): Add font-lock patterns for | 23 | * vc-git.el (vc-git-log-view-mode): Add font-lock patterns for |
diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el index 0c9ff964e30..eca8d40d7b3 100644 --- a/lisp/menu-bar.el +++ b/lisp/menu-bar.el | |||
| @@ -1160,11 +1160,9 @@ mail status in mode line")) | |||
| 1160 | (define-key menu-bar-tools-menu [separator-vc] | 1160 | (define-key menu-bar-tools-menu [separator-vc] |
| 1161 | '("--")) | 1161 | '("--")) |
| 1162 | 1162 | ||
| 1163 | (defvar vc-menu-map (make-sparse-keymap "Version Control")) | ||
| 1164 | (define-key menu-bar-tools-menu [pcl-cvs] | 1163 | (define-key menu-bar-tools-menu [pcl-cvs] |
| 1165 | '(menu-item "PCL-CVS" cvs-global-menu)) | 1164 | '(menu-item "PCL-CVS" cvs-global-menu)) |
| 1166 | (define-key menu-bar-tools-menu [vc] | 1165 | (define-key menu-bar-tools-menu [vc] nil) ;Create the place for the VC menu. |
| 1167 | (list 'menu-item "Version Control" vc-menu-map)) | ||
| 1168 | 1166 | ||
| 1169 | (define-key menu-bar-tools-menu [separator-compare] | 1167 | (define-key menu-bar-tools-menu [separator-compare] |
| 1170 | '("--")) | 1168 | '("--")) |
diff --git a/lisp/vc-arch.el b/lisp/vc-arch.el index 68a1b1b5f17..36cb9d616da 100644 --- a/lisp/vc-arch.el +++ b/lisp/vc-arch.el | |||
| @@ -444,6 +444,15 @@ Return non-nil if FILE is unchanged." | |||
| 444 | (table (vc-arch--version-completion-table root string))) | 444 | (table (vc-arch--version-completion-table root string))) |
| 445 | (complete-with-action action table string pred))))) | 445 | (complete-with-action action table string pred))))) |
| 446 | 446 | ||
| 447 | (defvar vc-arch-extra-menu-map | ||
| 448 | (let ((map (make-sparse-keymap))) | ||
| 449 | (define-key map [add-tagline] | ||
| 450 | '(menu-item "Add tagline" vc-arch-add-tagline)) | ||
| 451 | map)) | ||
| 452 | |||
| 453 | (defun vc-arch-extra-menu () vc-arch-extra-menu-map) | ||
| 454 | |||
| 455 | |||
| 447 | ;;; Less obvious implementations. | 456 | ;;; Less obvious implementations. |
| 448 | 457 | ||
| 449 | (defun vc-arch-find-version (file rev buffer) | 458 | (defun vc-arch-find-version (file rev buffer) |
diff --git a/lisp/vc-hooks.el b/lisp/vc-hooks.el index 0af0d7546a7..6684190e3d2 100644 --- a/lisp/vc-hooks.el +++ b/lisp/vc-hooks.el | |||
| @@ -707,6 +707,21 @@ Before doing that, check if there are any old backups and get rid of them." | |||
| 707 | ;; any VC Dired buffer to synchronize. | 707 | ;; any VC Dired buffer to synchronize. |
| 708 | (vc-dired-resynch-file file))))) | 708 | (vc-dired-resynch-file file))))) |
| 709 | 709 | ||
| 710 | (defvar vc-menu-entry | ||
| 711 | '(menu-item "Version Control" vc-menu-map | ||
| 712 | :filter vc-menu-map-filter)) | ||
| 713 | |||
| 714 | (when (boundp 'menu-bar-tools-menu) | ||
| 715 | ;; We do not need to worry here about the placement of this entry | ||
| 716 | ;; because menu-bar.el has already created the proper spot for us | ||
| 717 | ;; and this will simply use it. | ||
| 718 | (define-key menu-bar-tools-menu [vc] vc-menu-entry)) | ||
| 719 | |||
| 720 | (defconst vc-mode-line-map | ||
| 721 | (let ((map (make-sparse-keymap))) | ||
| 722 | (define-key map [mode-line down-mouse-1] vc-menu-entry) | ||
| 723 | map)) | ||
| 724 | |||
| 710 | (defun vc-mode-line (file) | 725 | (defun vc-mode-line (file) |
| 711 | "Set `vc-mode' to display type of version control for FILE. | 726 | "Set `vc-mode' to display type of version control for FILE. |
| 712 | The value is set in the current buffer, which should be the buffer | 727 | The value is set in the current buffer, which should be the buffer |
| @@ -880,36 +895,54 @@ Used in `find-file-not-found-functions'." | |||
| 880 | (fset 'vc-prefix-map vc-prefix-map) | 895 | (fset 'vc-prefix-map vc-prefix-map) |
| 881 | (define-key global-map "\C-xv" 'vc-prefix-map) | 896 | (define-key global-map "\C-xv" 'vc-prefix-map) |
| 882 | 897 | ||
| 883 | (if (not (boundp 'vc-menu-map)) | 898 | (defvar vc-menu-map |
| 884 | ;; Don't do the menu bindings if menu-bar.el wasn't loaded to defvar | 899 | (let ((map (make-sparse-keymap "Version Control"))) |
| 885 | ;; vc-menu-map. | 900 | ;;(define-key map [show-files] |
| 886 | () | 901 | ;; '("Show Files under VC" . (vc-directory t))) |
| 887 | ;;(define-key vc-menu-map [show-files] | 902 | (define-key map [vc-retrieve-snapshot] |
| 888 | ;; '("Show Files under VC" . (vc-directory t))) | 903 | '("Retrieve Snapshot" . vc-retrieve-snapshot)) |
| 889 | (define-key vc-menu-map [vc-retrieve-snapshot] | 904 | (define-key map [vc-create-snapshot] |
| 890 | '("Retrieve Snapshot" . vc-retrieve-snapshot)) | 905 | '("Create Snapshot" . vc-create-snapshot)) |
| 891 | (define-key vc-menu-map [vc-create-snapshot] | 906 | (define-key map [vc-directory] '("VC Directory Listing" . vc-directory)) |
| 892 | '("Create Snapshot" . vc-create-snapshot)) | 907 | (define-key map [separator1] '("----")) |
| 893 | (define-key vc-menu-map [vc-directory] '("VC Directory Listing" . vc-directory)) | 908 | (define-key map [vc-annotate] '("Annotate" . vc-annotate)) |
| 894 | (define-key vc-menu-map [separator1] '("----")) | 909 | (define-key map [vc-rename-file] '("Rename File" . vc-rename-file)) |
| 895 | (define-key vc-menu-map [vc-annotate] '("Annotate" . vc-annotate)) | 910 | (define-key map [vc-version-other-window] |
| 896 | (define-key vc-menu-map [vc-rename-file] '("Rename File" . vc-rename-file)) | 911 | '("Show Other Version" . vc-version-other-window)) |
| 897 | (define-key vc-menu-map [vc-version-other-window] | 912 | (define-key map [vc-diff] '("Compare with Base Version" . vc-diff)) |
| 898 | '("Show Other Version" . vc-version-other-window)) | 913 | (define-key map [vc-update-change-log] |
| 899 | (define-key vc-menu-map [vc-diff] '("Compare with Base Version" . vc-diff)) | 914 | '("Update ChangeLog" . vc-update-change-log)) |
| 900 | (define-key vc-menu-map [vc-update-change-log] | 915 | (define-key map [vc-print-log] '("Show History" . vc-print-log)) |
| 901 | '("Update ChangeLog" . vc-update-change-log)) | 916 | (define-key map [separator2] '("----")) |
| 902 | (define-key vc-menu-map [vc-print-log] '("Show History" . vc-print-log)) | 917 | (define-key map [vc-insert-header] |
| 903 | (define-key vc-menu-map [separator2] '("----")) | 918 | '("Insert Header" . vc-insert-headers)) |
| 904 | (define-key vc-menu-map [vc-insert-header] | 919 | (define-key map [undo] '("Undo Last Check-In" . vc-cancel-version)) |
| 905 | '("Insert Header" . vc-insert-headers)) | 920 | (define-key map [vc-revert-buffer] |
| 906 | (define-key vc-menu-map [undo] '("Undo Last Check-In" . vc-cancel-version)) | 921 | '("Revert to Base Version" . vc-revert-buffer)) |
| 907 | (define-key vc-menu-map [vc-revert-buffer] | 922 | (define-key map [vc-update] |
| 908 | '("Revert to Base Version" . vc-revert-buffer)) | 923 | '("Update to Latest Version" . vc-update)) |
| 909 | (define-key vc-menu-map [vc-update] | 924 | (define-key map [vc-next-action] '("Check In/Out" . vc-next-action)) |
| 910 | '("Update to Latest Version" . vc-update)) | 925 | (define-key map [vc-register] '("Register" . vc-register)) |
| 911 | (define-key vc-menu-map [vc-next-action] '("Check In/Out" . vc-next-action)) | 926 | map)) |
| 912 | (define-key vc-menu-map [vc-register] '("Register" . vc-register))) | 927 | |
| 928 | (defalias 'vc-menu-map vc-menu-map) | ||
| 929 | |||
| 930 | (defun vc-menu-map-filter (orig-binding) | ||
| 931 | (if (and (symbolp orig-binding) (fboundp orig-binding)) | ||
| 932 | (setq orig-binding (indirect-function orig-binding))) | ||
| 933 | (let ((ext-binding | ||
| 934 | (if vc-mode (vc-call-backend (vc-backend buffer-file-name) | ||
| 935 | 'extra-menu)))) | ||
| 936 | ;; Give the VC backend a chance to add menu entries | ||
| 937 | ;; specific for that backend. | ||
| 938 | (if (null ext-binding) | ||
| 939 | orig-binding | ||
| 940 | (append orig-binding | ||
| 941 | '((ext-menu-separator "---")) | ||
| 942 | ext-binding)))) | ||
| 943 | |||
| 944 | (defun vc-default-extra-menu (backend) | ||
| 945 | nil) | ||
| 913 | 946 | ||
| 914 | ;; These are not correct and it's not currently clear how doing it | 947 | ;; These are not correct and it's not currently clear how doing it |
| 915 | ;; better (with more complicated expressions) might slow things down | 948 | ;; better (with more complicated expressions) might slow things down |
diff --git a/lisp/vc.el b/lisp/vc.el index 6a0adc248da..e0d15f374da 100644 --- a/lisp/vc.el +++ b/lisp/vc.el | |||
| @@ -463,6 +463,15 @@ | |||
| 463 | ;; | 463 | ;; |
| 464 | ;; Operation called in current buffer when opening a non-existing file. | 464 | ;; Operation called in current buffer when opening a non-existing file. |
| 465 | ;; By default, this asks the user if she wants to check out the file. | 465 | ;; By default, this asks the user if she wants to check out the file. |
| 466 | ;; | ||
| 467 | ;; - extra-menu () | ||
| 468 | ;; | ||
| 469 | ;; Return a menu keymap, the items in the keymap will appear at the | ||
| 470 | ;; end of the Version Control menu. The goal is to allow backends | ||
| 471 | ;; to specify extra menu items that appear in the VC menu. This way | ||
| 472 | ;; you can provide menu entries for functionality that is specific | ||
| 473 | ;; to your backend and which does not map to any of the VC generic | ||
| 474 | ;; concepts. | ||
| 466 | 475 | ||
| 467 | ;;; Code: | 476 | ;;; Code: |
| 468 | 477 | ||