From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Masatake YAMATO Newsgroups: gmane.emacs.devel Subject: Re: [patch v2] showing menu bar temporarily when f10 is pressed Date: Wed, 20 Jun 2012 15:17:38 +0900 (JST) Organization: Red Hat Japan, Inc. Message-ID: <20120620.151738.1783513864733342718.yamato@redhat.com> References: <20120620.034116.1379090244202488621.yamato@redhat.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1340173078 10856 80.91.229.3 (20 Jun 2012 06:17:58 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 20 Jun 2012 06:17:58 +0000 (UTC) Cc: emacs-devel@gnu.org To: monnier@IRO.UMontreal.CA Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jun 20 08:17:57 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ShEEj-0006gM-Ln for ged-emacs-devel@m.gmane.org; Wed, 20 Jun 2012 08:17:53 +0200 Original-Received: from localhost ([::1]:55550 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ShEEj-0000t1-FS for ged-emacs-devel@m.gmane.org; Wed, 20 Jun 2012 02:17:53 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:50092) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ShEEg-0000sb-1s for emacs-devel@gnu.org; Wed, 20 Jun 2012 02:17:51 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ShEEZ-0000Wg-24 for emacs-devel@gnu.org; Wed, 20 Jun 2012 02:17:49 -0400 Original-Received: from mx1.redhat.com ([209.132.183.28]:55301) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ShEEY-0000W5-Pp for emacs-devel@gnu.org; Wed, 20 Jun 2012 02:17:42 -0400 Original-Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q5K6Hemu018966 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 20 Jun 2012 02:17:40 -0400 Original-Received: from localhost (dhcp-193-19.nrt.redhat.com [10.64.193.19]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q5K6Hcuc004156; Wed, 20 Jun 2012 02:17:39 -0400 In-Reply-To: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:151041 Archived-At: >> + (unless visible >> + (menu-bar-mode 1)) > > Here we have a problem: if you have several frames, some of which have > a menu-bar and some don't, this will add a menu-bar to all of them, and > then (menu-bar-mode -1) will remove it from all the frames. Thank you for reviewing. I've revised my patch to handle the case you pointed out. In the new patch, I deal with only frame local parameter. I don't touch the minor mode. I have still one un solved(TODO) item. > Why do you need the menu-bar? Why not pop up the menu usually bound to > C-mouse-3? To be honest, I didn't know that. I've just tried C-mouse-3; and found some advantages of C-mouse-3 comparing with f10 for KEYBOARD USER. 1. With C-mouse-3, the menu is pop up where mouse pointer is. With f10, the menu is appeared at the top of frame. With f10, the position is predictable. Following the cases user may lost the mouse pointer: * using large display, * editing text with keyboard long time, and/or * turning on mouse-avoidance-mode. In addition it seems that emacs hides the mouse pointer while the user editing text continuously. So with C-moues-3, the user have to search the menu popup'ed. Time taking searching is very short but some user may feel frustration when the menu appeared on somewhere far away from (point). In other hand, with f10, the user can predict the place where menu appears. No mental overload. 2. With C-mouse-3, the contents of menu is chosen based on the window where the mouse pointer is. Consider a frame is splited into two windows. Each window holds different buffer. And different major modes are activated on buffers: Window A -> Buffer B -> Major mode C. Window D -> Buffer D -> Major mode E. Consider the following situation: You are editing text on buffer B, and Mouse pointer is at D. When C-mouse-3 is operated in this situation, a popup menu(P0) which includes a menu entry for major mode E will be appeared. But user may exepct a popup menu(P1) which includes a menu entry for major mode C is appeared. To show P1 in this situation, the user must move the mouse pointer to somewhere Window A. It doesn't take long time to move the mouse pointer to Window A. some user may feel frustration. Moving the mouse cursor to (point) automatically before C-mouse-3 may convers two disadvantage of C-mouse-3 with keyboard operation. This is interesting idea, However, I feel extending [f10] is natural. Masatake YAMATO === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-06-14 14:22:37 +0000 +++ lisp/ChangeLog 2012-06-20 03:28:45 +0000 @@ -1,3 +1,9 @@ +2012-06-19 Masatake YAMATO + + * term/x-win.el (x-menu-bar-temorary-visibility): New custom var. + (x-menu-bar-open): Show menu bar temporarily if `x-menu-bar-temorary-visibility'. + (x-accelerate-menu-with-temporary-visible-menu-bar): New function. + 2012-06-14 Andreas Schwab * 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-20 03:43:31 +0000 @@ -1,4 +1,4 @@ -;;; x-win.el --- parse relevant switches and set up for X -*-coding: iso-2022-7bit;-*- +;;; x-win.el --- parse relevant switches and set up for X -*-coding: iso-2022-7bit; lexical-binding: t; -*- ;; Copyright (C) 1993-1994, 2001-2012 Free Software Foundation, Inc. @@ -1190,6 +1190,15 @@ (const TEXT))) :group 'killing) +(defcustom x-menu-bar-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 @@ -1304,12 +1313,35 @@ (declare-function accelerate-menu "xmenu.c" (&optional frame) t) +(defun x-accelerate-menu-with-temporary-visible-menu-bar (frame) + "Do `accelerate-menu' with temporarily visible menu bar of FRAME." + (let ((old-menu-bar-lines (frame-parameter frame 'menu-bar-lines)) + (old-frame (or frame (selected-frame)))) + (if (menu-bar-positive-p old-menu-bar-lines) + (accelerate-menu frame) + (letrec ((hide (lambda () + (remove-hook 'deactivate-menubar-hook hide) + ;; TODO: How can I handle the case the menu bar visibility is + ;; changed as the effect of menu item choice. + (when (frame-live-p old-frame) + (set-frame-parameter old-frame + 'menu-bar-lines old-menu-bar-lines))))) + (set-frame-parameter old-frame 'menu-bar-lines 1) + (prog1 + (accelerate-menu frame) + (add-hook 'deactivate-menubar-hook hide)))))) + (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-bar-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 + (x-menu-bar-temorary-visibility + (x-accelerate-menu-with-temporary-visible-menu-bar frame)) + (menu-bar-mode + (accelerate-menu frame)) + (t + (tmm-menubar))) (tmm-menubar))) === modified file 'src/ChangeLog' --- src/ChangeLog 2012-06-14 04:02:35 +0000 +++ src/ChangeLog 2012-06-20 03:29:35 +0000 @@ -1,3 +1,11 @@ +2012-06-19 Masatake YAMATO + + * xmenu.c (popup_deactivate_callback): Run Qdeactivate_menubar_hook. + + * keyboard.c (Qdeactivate_menubar_hook): Define a new hook. + + * keyboard.h (Qdeactivate_menubar_hook): Declare the new hook. + 2012-06-14 Paul Eggert * .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