emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[patch] showing menu bar temporarily when f10 is pressed


From: Masatake YAMATO
Subject: [patch] showing menu bar temporarily when f10 is pressed
Date: Wed, 20 Jun 2012 03:41:16 +0900 (JST)

Hi,

Are you using menu bar?

Menu bar is useful to know what kind of major commands are available.
M-x [tab] shows too many commands.:-P 

As you may know you can activate menu bar with `menu-bar-open'.  In
addition These days, as far as I know \C-n, \C-p, \C-f, \C-b, and \C-g
are available in choosing menu items. So even if you don't use mouse,
menu bar is still useful.

However, menu bar occupies one line. If menu bar is turend off, emacs
can show one more text line for editing or viewing.  I guess you,
experts of Emacs, may turn off menu bar. I know many of you may be
eager for more area to show source code lines. Me, too. However,
sometimes I want to use menu bar. Especially in gud mode.

This patch enhances the behavior of f10(`menu-bar-open').
With this patch, `menu-bar-open' shows menu bar temporarily
even if menu-bar-mode is turned off. After choosing something
menu item or \C-g, the menu bar is hidden automatically.

Even without this patch, you can choose menu item with tmm.  you can
choose a menu item with specifying the first character of menu item
you want to choose recursively. But I would like to choose a menu item
with positionally/geometrically operation. I guess you would, too.


Masatake YAMATO


=== modified file 'lisp/ChangeLog'
--- lisp/ChangeLog      2012-06-14 14:22:37 +0000
+++ lisp/ChangeLog      2012-06-19 17:52:08 +0000
@@ -1,3 +1,8 @@
+2012-06-19  Masatake YAMATO  <address@hidden>
+
+       * term/x-win.el (x-menu-temorary-visibility): New custom var.
+       (x-menu-bar-open): Show menu bar temporarily if 
`x-menu-temorary-visibility'.
+
 2012-06-14  Andreas Schwab  <address@hidden>
 
        * play/doctor.el (doctor-doc): Remove parameter and use

=== modified file 'lisp/term/x-win.el'
--- lisp/term/x-win.el  2012-04-27 05:40:46 +0000
+++ lisp/term/x-win.el  2012-06-19 17:50:31 +0000
@@ -1190,6 +1190,15 @@
                      (const TEXT)))
   :group 'killing)
 
+(defcustom x-menu-temorary-visibility t
+  "Control whether use menu bar or `tmm-menubar' when `x-menu-bar-open' is 
invoked.
+Non-nil means showing menu bar temporarily even if `menu-bar-mode' is turned 
off.
+If nil, the behavior is changed whether `menu-bar-mode' is on or off. See 
`x-menu-bar-open'
+for more detail."
+  :type 'boolean
+  :group 'x
+  :version "24.2")
+
 ;; Get a selection value of type TYPE by calling x-get-selection with
 ;; an appropriate DATA-TYPE argument decided by `x-select-request-type'.
 ;; The return value is already decoded.  If x-get-selection causes an
@@ -1305,11 +1314,28 @@
 (declare-function accelerate-menu "xmenu.c" (&optional frame) t)
 
 (defun x-menu-bar-open (&optional frame)
-  "Open the menu bar if `menu-bar-mode' is on, otherwise call `tmm-menubar'."
+  "Open the menu bar if `menu-bar-mode' is on or `x-menu-temorary-visibility' 
is non-nil, otherwise call `tmm-menubar'."
   (interactive "i")
-  (if (and menu-bar-mode
-          (fboundp 'accelerate-menu))
-      (accelerate-menu frame)
+  (if (fboundp 'accelerate-menu)
+      (cond
+       (menu-bar-mode
+       (accelerate-menu frame))
+       (x-menu-temorary-visibility
+       (let ((visible menu-bar-mode)
+             r)
+         (unless visible
+           (menu-bar-mode 1))
+         (setq r (accelerate-menu frame))
+         (unless visible
+           (letrec ((turn-the-mode (lambda ()
+                                     (remove-hook 'deactivate-menubar-hook
+                                                  'turn-off-menu-bar-mode)
+                                     (menu-bar-mode -1))))
+             (add-hook 'deactivate-menubar-hook
+                       turn-the-mode)))
+         r))
+       (t
+       (tmm-menubar)))
     (tmm-menubar)))
 
 

=== modified file 'src/ChangeLog'
--- src/ChangeLog       2012-06-14 04:02:35 +0000
+++ src/ChangeLog       2012-06-19 17:57:06 +0000
@@ -1,3 +1,11 @@
+2012-06-19  Masatake YAMATO  <address@hidden>
+
+       * xmenu.c (popup_deactivate_callback): Run Qdeactivate_menubar_hook.
+
+       * keyboard.c (Qdeactivate_menubar_hook): Define a new hook.
+
+       * keyboard.c (Qdeactivate_menubar_hook): Declare the new hook.
+
 2012-06-14  Paul Eggert  <address@hidden>
 
        * .gdbinit (xgetint): Fix recently-introduced paren typo.

=== modified file 'src/keyboard.c'
--- src/keyboard.c      2012-06-02 19:21:34 +0000
+++ src/keyboard.c      2012-06-19 17:10:11 +0000
@@ -257,6 +257,7 @@
 static Lisp_Object Qdeactivate_mark;
 
 Lisp_Object Qrecompute_lucid_menubar, Qactivate_menubar_hook;
+Lisp_Object Qdeactivate_menubar_hook;
 
 static Lisp_Object Qecho_area_clear_hook;
 
@@ -11535,6 +11536,7 @@
 
   DEFSYM (Qrecompute_lucid_menubar, "recompute-lucid-menubar");
   DEFSYM (Qactivate_menubar_hook, "activate-menubar-hook");
+  DEFSYM (Qdeactivate_menubar_hook, "deactivate-menubar-hook");
 
   DEFSYM (Qpolling_period, "polling-period");
 

=== modified file 'src/keyboard.h'
--- src/keyboard.h      2012-02-10 18:58:48 +0000
+++ src/keyboard.h      2012-06-19 17:08:30 +0000
@@ -212,6 +212,7 @@
 extern Lisp_Object internal_last_event_frame;
 
 extern Lisp_Object Qrecompute_lucid_menubar, Qactivate_menubar_hook;
+extern Lisp_Object Qdeactivate_menubar_hook;
 
 /* This holds a Lisp vector that holds the properties of a single
    menu item while decoding it in parse_menu_item.

=== modified file 'src/xmenu.c'
--- src/xmenu.c 2012-02-10 18:58:48 +0000
+++ src/xmenu.c 2012-06-19 17:07:58 +0000
@@ -686,12 +686,14 @@
 static void
 popup_deactivate_callback (GtkWidget *widget, gpointer client_data)
 {
+  safe_run_hooks (Qdeactivate_menubar_hook);
   popup_activated_flag = 0;
 }
 #else
 static void
 popup_deactivate_callback (Widget widget, LWLIB_ID id, XtPointer client_data)
 {
+  safe_run_hooks (Qdeactivate_menubar_hook);
   popup_activated_flag = 0;
 }
 #endif




reply via email to

[Prev in Thread] Current Thread [Next in Thread]