Emacs fiddling: show the menu-bar when the mouse is near the top of the frame

Posted by David N. Welton Mon, 16 Nov 2009 18:58:00 GMT

My wife is having dinner with the baby at her parents', so I took a moment to do a bit of pure, pointless, fun hacking after reading a discussion of which emacs gui features to turn off on a site I frequent. I turn off the tool bar and the scroll bar to get as much screen real estate as possible, but leave the menu bar on, because it doesn't take up that much space, and I occasionally use it to grab some little used feature whose full function name I don't recall.

My idea: make the menu bar appear only if the mouse is in that general vicinity. This initial implementation is hacky and doesn't work quite right; but it shouldn't take much to make it work. It's probably actually already been done somewhere, but it was fun to hack up something for the sake of hacking... something I don't get enough time for these days.

    (defun menu-bar-show-hide-helper ()
      (if (< (cddr (mouse-pixel-position)) 20)
      (menu-bar-mode 1)
    (menu-bar-mode 0)))

    (defun menu-bar-show-hide ()
      (run-with-idle-timer 0.1 t 'menu-bar-show-hide-helper))

I'll add fixes and updates as they are sent in.

4 comments |

Trackbacks

Use the following link to trackback from your own site:
http://journal.dedasys.com/trackbacks?article_id=2168

  1. Social comments and analytics for this post From uberVU - social comments
    This post was mentioned on Twitter by droidfeed: Emacs fiddling: show the menu-bar when the mouse is near the top of the frame http://bit.ly/2B8Vvx
  1. Mark
    about {{count}} hours later:

    See also active-menu (I used to use it in xemacs, now I just hide the menu-bar :)) It looks un-maintained now though: http://www.emacswiki.org/emacs/ActiveMenu

  2. Francois
    about {{count}} hours later:

    Having a timer running every tenth of a second for that is simply atrocious.

    When this kind of philosophy of coding ("I don't give a shit if it's slow, I like it") generalizes, what you obtain is the sluginess of a Windows computer.

    Beuark.

  3. Steve Kemp
    about {{count}} hours later:

    I like the idea, and was also wary of the timer.

    The only built-in functionality that I use relating to mouse pointer is the "mouse-avoidance" mode which moves the pointer away from the cursor (avoid.el).

    Looking over the code it uses the same approach, of an idle timer. Perhaps that suggests there isn't anything more suitable.

    I did use apropops to search for a "mouse-move" hook but no joy. Which is a surprise.

  4. David N. Welton
    {{count}} days later:

    Francois, as I said, the idea was "hacky", which is generally an invitation, at least in the open source world I inhabit, to improve on the solution by suggesting superior approaches, rather than simply complaining.

    See Steve's comment, for instance.

    There is a mouse-move hook, if you dig around a little bit, but it has to be specifically enabled, which gives me the impression that it would actually be more resource-intensive than the timer.