Commit 029619c8 authored by Eli Zaretskii's avatar Eli Zaretskii

Make the same key that opens TTY menus also exit the menu.

 lisp/menu-bar.el (tty-menu-navigation-map): Remap F10 to tty-menu-exit.
parent abe02020
2013-10-11 Eli Zaretskii <eliz@gnu.org>
* menu-bar.el (tty-menu-navigation-map): Remap F10 to tty-menu-exit.
2013-10-11 Stefan Monnier <monnier@iro.umontreal.ca>
* progmodes/sh-script.el: Provide simpl(e|istic) completion.
......
......@@ -2261,6 +2261,50 @@ If nil, the current mouse position is used."
(popup-menu-normalize-position (event-end position)))
(t position)))
(defcustom tty-menu-open-use-tmm nil
"If non-nil, \\[menu-bar-open] on a TTY will invoke `tmm-menubar'.
If nil, \\[menu-bar-open] will drop down the menu corresponding to the
first (leftmost) menu-bar item; you can select other items by typing
\\[forward-char], \\[backward-char], \\[right-char] and \\[left-char]."
:type '(choice (const :tag "F10 drops down TTY menus" nil)
(const :tag "F10 invokes tmm-menubar" t))
:group 'display
:version "24.4")
(defvar tty-menu--initial-menu-x 1
"X coordinate of the first menu-bar menu dropped by F10.
This is meant to be used only for debugging TTY menus.")
(defun menu-bar-open (&optional frame)
"Start key navigation of the menu bar in FRAME.
This function decides which method to use to access the menu
depending on FRAME's terminal device. On X displays, it calls
`x-menu-bar-open'; on Windows, `w32-menu-bar-open'; otherwise it
calls either `popup-menu' or `tmm-menubar' depending on whether
\`tty-menu-open-use-tmm' is nil or not.
If FRAME is nil or not given, use the selected frame."
(interactive)
(let ((type (framep (or frame (selected-frame)))))
(cond
((eq type 'x) (x-menu-bar-open frame))
((eq type 'w32) (w32-menu-bar-open frame))
((and (null tty-menu-open-use-tmm)
(not (zerop (or (frame-parameter nil 'menu-bar-lines) 0))))
(let* ((x tty-menu--initial-menu-x)
(menu (menu-bar-menu-at-x-y x 0 frame)))
(popup-menu (or
(lookup-key global-map (vector 'menu-bar menu))
(lookup-key (current-local-map) (vector 'menu-bar menu)))
(posn-at-x-y x 0 nil t) nil t)))
(t (with-selected-frame (or frame (selected-frame))
(tmm-menubar))))))
(global-set-key [f10] 'menu-bar-open)
(defvar tty-menu-navigation-map
(let ((map (make-sparse-keymap)))
;; The next line is disabled because it breaks interpretation of
......@@ -2282,7 +2326,8 @@ If nil, the current mouse position is used."
(next-line . tty-menu-next-item)
(previous-line . tty-menu-prev-item)
(newline . tty-menu-select)
(newline-and-indent . tty-menu-select)))
(newline-and-indent . tty-menu-select)
(menu-bar-open . tty-menu-exit)))
(substitute-key-definition (car bind) (cdr bind)
map (current-global-map)))
......@@ -2327,51 +2372,6 @@ If nil, the current mouse position is used."
map)
"Keymap used while processing TTY menus.")
(defcustom tty-menu-open-use-tmm nil
"If non-nil, \\[menu-bar-open] on a TTY will invoke `tmm-menubar'.
If nil, \\[menu-bar-open] will drop down the menu corresponding to the
first (leftmost) menu-bar item; you can select other items by typing
\\[forward-char], \\[backward-char], \\[right-char] and \\[left-char]."
:type '(choice (const :tag "F10 drops down TTY menus" nil)
(const :tag "F10 invokes tmm-menubar" t))
:group 'display
:version "24.4")
(defvar tty-menu--initial-menu-x 1
"X coordinate of the first menu-bar menu dropped by F10.
This is meant to be used only for debugging TTY menus.")
(defun menu-bar-open (&optional frame)
"Start key navigation of the menu bar in FRAME.
This function decides which method to use to access the menu
depending on FRAME's terminal device. On X displays, it calls
`x-menu-bar-open'; on Windows, `w32-menu-bar-open'; otherwise it
calls either `popup-menu' or `tmm-menubar' depending on whether
\`tty-menu-open-use-tmm' is nil or not.
If FRAME is nil or not given, use the selected frame."
(interactive)
(let ((type (framep (or frame (selected-frame)))))
(cond
((eq type 'x) (x-menu-bar-open frame))
((eq type 'w32) (w32-menu-bar-open frame))
((and (null tty-menu-open-use-tmm)
(not (zerop (or (frame-parameter nil 'menu-bar-lines) 0))))
(let* ((x tty-menu--initial-menu-x)
(menu (menu-bar-menu-at-x-y x 0 frame)))
(popup-menu (or
(lookup-key global-map (vector 'menu-bar menu))
(lookup-key (current-local-map) (vector 'menu-bar menu)))
(posn-at-x-y x 0 nil t) nil t)))
(t (with-selected-frame (or frame (selected-frame))
(tmm-menubar))))))
(global-set-key [f10] 'menu-bar-open)
(provide 'menu-bar)
;;; menu-bar.el ends here
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment