4

When I hit C-f2 in any Mac OS X app (e.g., terminal, firefox), I get keyboard access to the menu bar (file/edit/options &c) In emacs I get a message <C-f2> is undefined in the Echo Area. When I hit f10 (menu-bar-open) in Emacs, get the 2 item menu search with google and add to itunes as a spoken track or sometimes the single grayed-out item menu select.

  • How do i get Emacs to pass C-f2 to the OS?
  • How do I get f10 to invoke the real menu in Emacs?
deprecated
  • 2,775
  • 14
  • 15
sds
  • 5,928
  • 20
  • 39
  • I don't have the answer to your question, but wanted to mention an alternative method to popup the same type of menu using `mouse-popup-menubar` Perhaps (with a little bit of a tweak) you could set that to a keyboard shortcut instead of the control right-click. I use that instead of the main menu-bar, which I hide so that I get a little more screen real estate and a less distracting view when working. – lawlist Nov 26 '14 at 19:23
  • And another option, which is not an answer, but may be useful: `menu-bar-open` It offers the same options as the menu-bar, but through the mini-buffer input. http://www.gnu.org/software/emacs/manual/html_node/emacs/Menu-Bar.html – lawlist Nov 26 '14 at 19:47
  • @lawlist: that's what `f10` already calls. – sds Nov 26 '14 at 19:49

4 Answers4

3

Here is the solution:

(define-key global-map (kbd "C-<f2>")
  (lambda ()
    (interactive)
    (x-popup-menu (list '(0 0) (selected-frame))
                  (mouse-menu-bar-map))))

Also fixed in the source tree so that now f10 does the right thing.

This gives mouse-less access to the menu-bar functionality, not the OS menu interface, so the question of how to tell Emacs to pass certain keys to the OS remains open.

sds
  • 5,928
  • 20
  • 39
  • I'm seeing the the same behavior as `mouse-popup-menubar` with Emacs Trunk versions dated October and November 2014 on Snow Leopard 10.6.8. The only difference is that the pop-up menu appears in the left-hand corner instead of wherever the mouse is. This answer is not really the OSX equivalent of accessing the OSX menubar, which displays the Emacs menubar. – lawlist Nov 27 '14 at 19:12
  • By way of example to explain my previous comment, `(global-set-key [C-down-mouse-3] 'mouse-popup-menubar)` will configure the same pop-up menu (as is used in this answer) for the key combination **Ctrl+Right-Click** -- the OSX menubar is not being used. – lawlist Nov 27 '14 at 19:26
  • 1
    @lawlist: see edit – sds Nov 27 '14 at 19:37
  • This is great. I actually mapped to *just* F2. – WestCoastProjects Mar 17 '15 at 19:53
  • How could a real solution be achieved? Digging into emacs ObjC/Cocoa code? – nephewtom Apr 05 '15 at 17:29
  • @tomasorti: you might be able to find the code in the [Mac Port](http://www.math.s.chiba-u.ac.jp/~mituharu/emacs-mac.git) – sds Apr 06 '15 at 01:41
0

Without any configuration:

  • Ctrl-Alt-DownArrow

this selects the apple icon in the menu-bar. From them, move left or right using the right/left keys.

This is for OSX 10.11.3 but maybe previous versions too? Please confirm!

  • Cmd-?:

Out of the box, OS X 10.10 has the shortcut 'Cmd-?' (That is, 'Cmd-Shift-/') to access the Help menu of the menu bar.

This opens the menu Help and put the cursor in the text box in the 'Search Help' menu item.

From there, use the arrow keys to access other menus/menu items.

user2707671
  • 101
  • 2
0

This does work for me with Fn ^F2 (control function F2) using YAMAMOTO Mitsuharu's "Emacs Mac Port", installed via Homebrew. More precisely, my current OS and emacs versions are

OS X 10.10.1 (14B25)
GNU Emacs 24.4.1 (x86_64-apple-darwin14.0.0, Carbon Version 157 AppKit 1343.14) of 2014-10-21 on iris-mac.crya.privado

The Fn ^F2 shortcut is intercepted by the OS and never gets to Emacs. It gives keyboard access to the menubar just as in other apps. You have presumably turned on the option "Use all F1, F2, etc keys as standard function keys" in the Keyboard sheet of System Preferences, so you can just type ^F2 without using the Fn key.

deprecated
  • 2,775
  • 14
  • 15
0

To use the menu bar on a Mac you use F10. This can be accomplished by pressing the Fn button on a MacBook Pro and then pressing F10.