I am opening emacs in --no-window-system mode and I switched xterm-mouse-mode on. Mouse clicks within a buffer work. However, I want the menu at the top of the window to open when I click on it.

I.e., when I click on File, I want the dropdown menu to show up the list with the options to open a file or to save the current buffer and so on.

What happens actually instead is that on the right half of the shell window a new buffer opens, showing a message like the one visible here: like the one visible here.

How can I get the menu bar at the top of emacs to work as I expect it? I want the ordinary behaviour from all other "normal" GUI editors, which do not operate on the command line. Thanks in advance!


2 Answers 2


I want the ordinary behaviour from all other "normal" GUI editors

But you're not running it as a GUI editor, you're running in a terminal.

When menu-bar-mode is enabled (as it is for you), you can type <f10> to open the menus, and then navigate with the keyboard.

Or you can use the menus regardless by typing M-`

You may be able to get some mouse interaction by enabling xterm-mouse-mode in Emacs, but that won't necessarily do what you want for the menus. (In my case clicking on the menu names triggers the M-` behaviour for that menu.)

  • So there is no way to use the top menu completely by the mouse? Commented May 1, 2017 at 7:17
  • I don't know. The fact that xterm-mouse-mode exists and is able to detect clicks on the specific menu toolbar items, combined with the fact that the menu UI opened by <f10> is otherwise what you're after, does make me think that it may be possible to combine those two things to get the result you're looking for. I haven't looked into that myself, though.
    – phils
    Commented May 1, 2017 at 9:49

Indeed, there are two different ways to show TTY menus:

  • either tmm-menubar (the "ugly" menu),
  • or popup-menu (the "nicer" menu).

It appears <f10> calls popup-menu by default, but this is customizable if ever we want to downgrade this to tmm-menubar:

tty-menu-open-use-tmm is a variable defined in menu-bar.el.gz.


If non-nil, <f10> on a TTY will invoke tmm-menubar.

If nil, <f10> will drop down the menu corresponding to the
first (leftmost) menu-bar item; you can select other items by typing
C-f, C-b, <right> and <left>.

This variable was added, or its default value changed, in Emacs 24.4.

Anyway, it's feasible to come up with a lisp solution to have <mouse-1> behave the same.

Here is a proof of concept, inspired by this answer by @npostavs, itself inspired by menu-bar.el:

(defun menu-bar-get-minimal-x (menu-symbol x y)
  (let ((xx (- x 1)))
    (if (< xx tty-menu--initial-menu-x)
      (if (equal (menu-bar-menu-at-x-y xx y (selected-frame)) menu-symbol)
          (menu-bar-get-minimal-x menu-symbol xx y)

(defun menu-bar-open-x-y (mouse-event)
  (interactive "e")
  (pcase mouse-event
    (`(mouse-1 (,_ menu-bar (,x . ,y) . ,_))
     (let ((menu (menu-bar-menu-at-x-y x y)))
       (popup-menu (or
                     global-map (vector 'menu-bar menu))
                     (current-local-map) (vector 'menu-bar menu))
                    (cdar (minor-mode-key-binding (vector 'menu-bar menu)))
                   (posn-at-x-y (menu-bar-get-minimal-x menu x y) y nil t)
                   nil t)))
    (_ (message "unsupported event %S" (car mouse-event)))))

(define-key global-map (kbd "<menu-bar> <mouse-1>") 'menu-bar-open-x-y)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.