diff options
| author | Stefan Monnier | 2000-07-18 23:43:41 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2000-07-18 23:43:41 +0000 |
| commit | 21ad0f7b2f55e3701febc76470e77a88eace19dd (patch) | |
| tree | 9f7eb4e1a47072ca7da9e1fd226b2fc4c3b2de7c | |
| parent | 3b33a0059c10b22373eeee7914685afa7af20108 (diff) | |
| download | emacs-21ad0f7b2f55e3701febc76470e77a88eace19dd.tar.gz emacs-21ad0f7b2f55e3701febc76470e77a88eace19dd.zip | |
(popup-menu): New function.
(mouse-major-mode-menu): Use it.
| -rw-r--r-- | lisp/ChangeLog | 33 | ||||
| -rw-r--r-- | lisp/mouse.el | 43 |
2 files changed, 49 insertions, 27 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 3b326ed4d32..53810eea67a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2000-07-18 Stefan Monnier <monnier@cs.yale.edu> | ||
| 2 | |||
| 3 | * mouse.el (popup-menu): New function. | ||
| 4 | (mouse-major-mode-menu): Use it. | ||
| 5 | |||
| 1 | 2000-07-18 Dave Love <fx@gnu.org> | 6 | 2000-07-18 Dave Love <fx@gnu.org> |
| 2 | 7 | ||
| 3 | * bindings.el (mode-line-mule-info, mode-line-modified): help-echo | 8 | * bindings.el (mode-line-mule-info, mode-line-modified): help-echo |
| @@ -5,7 +10,7 @@ | |||
| 5 | 10 | ||
| 6 | 2000-07-18 Gerd Moellmann <gerd@gnu.org> | 11 | 2000-07-18 Gerd Moellmann <gerd@gnu.org> |
| 7 | 12 | ||
| 8 | * faces.el (face-font-selection-order) | 13 | * faces.el (face-font-selection-order) |
| 9 | (face-font-family-alternatives): Add custom type. | 14 | (face-font-family-alternatives): Add custom type. |
| 10 | 15 | ||
| 11 | 2000-07-18 Dave Love <fx@gnu.org> | 16 | 2000-07-18 Dave Love <fx@gnu.org> |
| @@ -46,27 +51,26 @@ | |||
| 46 | * eshell/esh-cmd.el (eshell-cmd): Ditto. | 51 | * eshell/esh-cmd.el (eshell-cmd): Ditto. |
| 47 | * eshell/em-smart.el (eshell-smart): Ditto. | 52 | * eshell/em-smart.el (eshell-smart): Ditto. |
| 48 | * eshell/em-banner.el (eshell-banner): Ditto. | 53 | * eshell/em-banner.el (eshell-banner): Ditto. |
| 49 | * eshell/em-alias.el (eshell-alias, eshell-bad-command-tolerance): | 54 | * eshell/em-alias.el (eshell-alias, eshell-bad-command-tolerance): Ditto. |
| 50 | Ditto. | ||
| 51 | 55 | ||
| 52 | * eshell/em-unix.el (eshell-shuffle-files): Don't disable | 56 | * eshell/em-unix.el (eshell-shuffle-files): Don't disable |
| 53 | same-file check in the MS-DOS version (it does support inodes). | 57 | same-file check in the MS-DOS version (it does support inodes). |
| 54 | 58 | ||
| 55 | * eshell/em-alias.el (eshell-maybe-replace-by-alias): Doc fix. | 59 | * eshell/em-alias.el (eshell-maybe-replace-by-alias): Doc fix. |
| 56 | 60 | ||
| 57 | * eshell/eshell.el (eshell-directory-name): Run default directory | 61 | * eshell/eshell.el (eshell-directory-name): |
| 58 | name through convert-standard-filename. | 62 | Run default directory name through convert-standard-filename. |
| 59 | 63 | ||
| 60 | 2000-07-18 Kenichi Handa <handa@etl.go.jp> | 64 | 2000-07-18 Kenichi Handa <handa@etl.go.jp> |
| 61 | 65 | ||
| 62 | * international/mule-cmds.el (select-safe-coding-system): Fix typo | 66 | * international/mule-cmds.el (select-safe-coding-system): |
| 63 | in the comment. | 67 | Fix typo in the comment. |
| 64 | 68 | ||
| 65 | * language/european.el (compound-text): Force katakana-jisx0201 to | 69 | * language/european.el (compound-text): |
| 66 | be designated to G1. | 70 | Force katakana-jisx0201 to be designated to G1. |
| 67 | 71 | ||
| 68 | * international/mule-conf.el (oldjis-newjis-jisroman-ascii): Don't | 72 | * international/mule-conf.el (oldjis-newjis-jisroman-ascii): |
| 69 | translate some national variant characters of latin-jisx0201. | 73 | Don't translate some national variant characters of latin-jisx0201. |
| 70 | (x-ctext): Force katakana-jisx0201 to be designated to G1. | 74 | (x-ctext): Force katakana-jisx0201 to be designated to G1. |
| 71 | 75 | ||
| 72 | * international/kkc.el (kkc-after-update-conversion-functions): | 76 | * international/kkc.el (kkc-after-update-conversion-functions): |
| @@ -75,14 +79,13 @@ | |||
| 75 | 79 | ||
| 76 | 2000-07-16 John Wiegley <johnw@gnu.org> | 80 | 2000-07-16 John Wiegley <johnw@gnu.org> |
| 77 | 81 | ||
| 78 | * lisp/align.el (align-newline-and-indent): Adding new function. | 82 | * lisp/align.el (align-newline-and-indent): |
| 79 | for auto-aligning blocks of code on RET. | 83 | Adding new function. for auto-aligning blocks of code on RET. |
| 80 | (align-region): Fixed badly formatted minibuffer message. | 84 | (align-region): Fixed badly formatted minibuffer message. |
| 81 | 85 | ||
| 82 | 2000-07-17 Kenichi Handa <handa@etl.go.jp> | 86 | 2000-07-17 Kenichi Handa <handa@etl.go.jp> |
| 83 | 87 | ||
| 84 | * international/kkc.el (kkc-show-conversion-list-count): Customize | 88 | * international/kkc.el (kkc-show-conversion-list-count): Customize it. |
| 85 | it. | ||
| 86 | (kkc-region): Update kkc-next-count and kkc-prev-count here. Show | 89 | (kkc-region): Update kkc-next-count and kkc-prev-count here. Show |
| 87 | the conversion list at first if appropriate. | 90 | the conversion list at first if appropriate. |
| 88 | (kkc-next): Don't update kkc-next-count here. | 91 | (kkc-next): Don't update kkc-next-count here. |
diff --git a/lisp/mouse.el b/lisp/mouse.el index 9057e781d5d..ad86868f13c 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el | |||
| @@ -44,6 +44,35 @@ | |||
| 44 | 44 | ||
| 45 | ;; Provide a mode-specific menu on a mouse button. | 45 | ;; Provide a mode-specific menu on a mouse button. |
| 46 | 46 | ||
| 47 | (defun popup-menu (menu &optional position prefix) | ||
| 48 | "Popup the given menu and call the selected option. | ||
| 49 | MENU can be a keymap or an easymenu-style menu. | ||
| 50 | POSITION can be a click event or ((XOFFSET YOFFSET) WINDOW) and defaults to | ||
| 51 | the current mouse position. | ||
| 52 | PREFIX is the prefix argument (if any) to pass to the command." | ||
| 53 | (let* ((map (if (keymapp menu) menu | ||
| 54 | (let* ((map (easy-menu-create-menu (car menu) (cdr menu))) | ||
| 55 | (filter (when (symbolp map) | ||
| 56 | (plist-get (get map 'menu-pro) :filter)))) | ||
| 57 | (if filter (funcall filter (symbol-function map)) map)))) | ||
| 58 | event) | ||
| 59 | ;; The looping behavior was taken from lmenu's popup-menu-popup | ||
| 60 | (while (and map (setq event (x-popup-menu position map))) | ||
| 61 | ;; Strangely x-popup-menu returns a list. | ||
| 62 | ;; mouse-major-mode-menu was using a weird: | ||
| 63 | ;; (key-binding (apply 'vector (append '(menu-bar) menu-prefix events))) | ||
| 64 | (let ((cmd (lookup-key map (apply 'vector event)))) | ||
| 65 | (setq map nil) | ||
| 66 | ;; Clear out echoing, which perhaps shows a prefix arg. | ||
| 67 | (message "") | ||
| 68 | (when cmd | ||
| 69 | (if (keymapp cmd) | ||
| 70 | ;; Try again but with the submap. | ||
| 71 | (setq map cmd) | ||
| 72 | (setq prefix-arg prefix) | ||
| 73 | ;; mouse-major-mode-menu was using `command-execute' instead. | ||
| 74 | (call-interactively cmd))))))) | ||
| 75 | |||
| 47 | (defun mouse-major-mode-menu (event prefix) | 76 | (defun mouse-major-mode-menu (event prefix) |
| 48 | "Pop up a mode-specific menu of mouse commands. | 77 | "Pop up a mode-specific menu of mouse commands. |
| 49 | Default to the Edit menu if the major mode doesn't define a menu." | 78 | Default to the Edit menu if the major mode doesn't define a menu." |
| @@ -70,18 +99,8 @@ Default to the Edit menu if the major mode doesn't define a menu." | |||
| 70 | ;; Make our menu inherit from the desired keymap which we want | 99 | ;; Make our menu inherit from the desired keymap which we want |
| 71 | ;; to display as the menu now. | 100 | ;; to display as the menu now. |
| 72 | (set-keymap-parent newmap ancestor)) | 101 | (set-keymap-parent newmap ancestor)) |
| 73 | (setq result (x-popup-menu t (list newmap))) | 102 | (popup-menu newmap event prefix))) |
| 74 | (if result | 103 | |
| 75 | (let ((command (key-binding | ||
| 76 | (apply 'vector (append '(menu-bar) | ||
| 77 | mouse-major-mode-menu-prefix | ||
| 78 | result))))) | ||
| 79 | ;; Clear out echoing, which perhaps shows a prefix arg. | ||
| 80 | (message "") | ||
| 81 | (if command | ||
| 82 | (progn | ||
| 83 | (setq prefix-arg prefix) | ||
| 84 | (command-execute command))))))) | ||
| 85 | 104 | ||
| 86 | ;; Compute and cache the equivalent keys in MENU and all its submenus. | 105 | ;; Compute and cache the equivalent keys in MENU and all its submenus. |
| 87 | ;;;(defun mouse-major-mode-menu-compute-equiv-keys (menu) | 106 | ;;;(defun mouse-major-mode-menu-compute-equiv-keys (menu) |