From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: JD Smith Newsgroups: gmane.emacs.devel Subject: Re: Popup-menu signals quit when Aborted Date: Sat, 1 Feb 2020 11:41:40 -0500 Message-ID: References: <97CB42CE-5971-4EA5-B96C-6FA7620DDB74@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 13.0 \(3608.40.2.2.4\)) Content-Type: multipart/alternative; boundary="Apple-Mail=_D9C65C4A-7278-47DC-A808-570626F15329" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="1362"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Feb 01 17:43:11 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ixvrR-0000E8-Lx for ged-emacs-devel@m.gmane-mx.org; Sat, 01 Feb 2020 17:43:09 +0100 Original-Received: from localhost ([::1]:47700 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixvrQ-0007AB-OM for ged-emacs-devel@m.gmane-mx.org; Sat, 01 Feb 2020 11:43:08 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37527) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixvq5-000603-Rz for emacs-devel@gnu.org; Sat, 01 Feb 2020 11:41:47 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ixvq4-0008SQ-GX for emacs-devel@gnu.org; Sat, 01 Feb 2020 11:41:45 -0500 Original-Received: from mail-yw1-xc30.google.com ([2607:f8b0:4864:20::c30]:46237) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ixvq4-0008Pz-BG for emacs-devel@gnu.org; Sat, 01 Feb 2020 11:41:44 -0500 Original-Received: by mail-yw1-xc30.google.com with SMTP id z141so7795874ywd.13 for ; Sat, 01 Feb 2020 08:41:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:mime-version:subject:date:references:to:in-reply-to:message-id; bh=T4mTdG75o9sz4QPf+/WCopaiiipGfKsKceKwgGMXNfI=; b=tN7fJ54Q0e1kXNGXC2Y5hPlDvWtsi1/IsVOlSnH5lSXTONTg9eVtHCPjGaljPrENkP 2+2eZR8bTuds1CT6WC3wsjVnR6bULfpxwerOJvNq5DIxNOtKGpprSs8vvmO8EjHWjIdm Rrzdr/vp/c55JyleVTrQL2X0L8Bx475H8KSSQ7CFQ/8d77LwKXtV7RqDMfVaWhfFvXhm 1+nHQrZmt5YICDTyQCJJ9CkH/1CETSLxvhMoJuBDXuyi4zJDoEi3qqOqEDXO0RltEhNT IPiYUW4mCyuAIbHy+s81AAVAjt5GEzccN7NCRrfW4O600lpV9GdWCKTZPNZirF/3V2Un /RFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:mime-version:subject:date:references:to :in-reply-to:message-id; bh=T4mTdG75o9sz4QPf+/WCopaiiipGfKsKceKwgGMXNfI=; b=e0io+BVsc7vLfZ+ex5dlHgnqsbhPqmsgzeIxdSPfggn5aN/4uYzqwUFDIYfzTRg8ZK 1hVxYp2R0ta2KF1D+H0471xMivH8EOBV1WwesPfBBW2+8qdyP3EOIqxuR4htllvtsyfQ 2BPukvW+sWsfNy5vFow9YimNIjfU6U1KTTd3/RdlKI21WSbGuBpRdv31SqtUE/+fb8hQ itmCzfmVJlFppT1/exblGVdnh8FtxoeQKsO2oZFHiQznt4ebbLrZYb9JXpwVShiLAkRT V/UHL0AMdlfKzXbYtPiuGc2q5klbT1XI+YeeyBmhBRps0fVpYpQ9rBcEuzANgu69+8LC vgDA== X-Gm-Message-State: APjAAAUiK8ZU5dBtJ6yvnFHEEdYun6HR5b8zGtfehyH2B+B9mFRnboHt vPJBrBCZRq7iAEVToS3DzTad3Lly6/Q= X-Google-Smtp-Source: APXvYqxkzkzx3fd6nOPLD6vligQLQeD7GBzUjAOmd48/aTKSC+gigHFNRbVg8xbIGFMht4If+h5HoA== X-Received: by 2002:a25:8385:: with SMTP id t5mr12645007ybk.380.1580575303223; Sat, 01 Feb 2020 08:41:43 -0800 (PST) Original-Received: from [192.168.0.102] (cblmdm134-228-15-233.buckeyecom.net. [134.228.15.233]) by smtp.gmail.com with ESMTPSA id a202sm5455666ywe.8.2020.02.01.08.41.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 01 Feb 2020 08:41:42 -0800 (PST) In-Reply-To: X-Mailer: Apple Mail (2.3608.40.2.2.4) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::c30 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:244813 Archived-At: --Apple-Mail=_D9C65C4A-7278-47DC-A808-570626F15329 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Feb 1, 2020, at 10:55 AM, Stefan Monnier = wrote: >=20 >> `x-popup-menu` is setup to handle mouse events specially when = =E2=80=9Caborting=E2=80=9D the >> menu by clicking off of it: >>=20 >>> If the user gets rid of the menu without making a valid choice, for >>> instance by clicking the mouse away from a valid choice or by typing >>> keyboard input, then this normally results in a quit and >>> =E2=80=98x-popup-menu=E2=80=99 does not return. But if POSITION is a = mouse button >>> event (indicating that the user invoked the menu with the mouse) = then >>> no quit occurs and =E2=80=98x-popup-menu=E2=80=99 returns nil. >=20 > I wasn't aware (or if I was, I forgot about it in the mean time) of > this oddity. >=20 >> This seems sensible. >=20 > I'm glad you find it so, because I can't figure out the underlying = logic > of this oddity. Can you explain why you think it's sensible? It seems sensible to me that if a mouse-event generates a popup menu, = and it is =E2=80=9Cgotten rid of=E2=80=9D by the user by clicking off = the menu, that this should NOT signal a quit and ring the bell as if = some kind of error has occurred. This is what `x-popup-menu` appears to = implement, but its higher-level interface `popup-menu` inhibits this = sensible feature by =E2=80=9Cnormalizing=E2=80=9D positions. =20 I encountered this using minions mode. Its popup menu for minor modes = is very useful, but sometimes you just want to take a quick look at what = modes are set, and not alter anything. But clicking off the menu to get = rid of it signals =E2=80=98quit and rings the bell. Reading the note = above in `x-popup-menu` I considered passing a mouse event would be a = reliable fix. But since `popup-menu` strips event information, the only = remaining possibility is to trap the quit: (condition-case nil (popup-menu map) (quit nil))) This seems rather heavy-handed. You can try a simple example (click off = the menu): (let ((menu-bar (make-sparse-keymap "Dismiss Menu"))) (define-key menu-bar [testing] '(menu-item "Nothing" nil)) (popup-menu menu-bar)) --Apple-Mail=_D9C65C4A-7278-47DC-A808-570626F15329 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

On Feb 1, 2020, at 10:55 AM, Stefan Monnier <monnier@iro.umontreal.ca> wrote:

`x-popup-menu` is setup = to handle mouse events specially when =E2=80=9Caborting=E2=80=9D the
menu by clicking off of it:

If the user gets rid of = the menu without making a valid choice, for
instance by = clicking the mouse away from a valid choice or by typing
keyboard input, then this normally results in a quit and
=E2=80=98x-popup-menu=E2=80=99 does not return. But if = POSITION is a mouse button
event (indicating that the user = invoked the menu with the mouse) then
no quit occurs and = =E2=80=98x-popup-menu=E2=80=99 returns nil.

I wasn't aware (or = if I was, I forgot about it in the mean time) of
this = oddity.

This seems sensible.

I'm glad you find it so, because I can't figure out the = underlying logic
of this oddity.  Can you explain why = you think it's sensible?

It seems sensible to me = that if a mouse-event generates a popup menu, and it is =E2=80=9Cgotten = rid of=E2=80=9D by the user by clicking off the menu, that this should = NOT signal a quit and ring the bell as if some kind of error has = occurred.  This is what `x-popup-menu` appears to implement, but = its higher-level interface `popup-menu` inhibits this sensible feature = by =E2=80=9Cnormalizing=E2=80=9D positions.  

I encountered this using = minions mode.  Its popup menu for minor modes is very useful, but = sometimes you just want to take a quick look at what modes are set, and = not alter anything. But clicking off the menu to get rid of it signals = =E2=80=98quit and rings the bell.  Reading the note above in = `x-popup-menu` I considered passing a mouse event would be a reliable = fix.  But since `popup-menu` strips event information, the only = remaining possibility is to trap the quit:

(condition-case nil
        (popup-menu map)
      (quit nil)))

This seems rather heavy-handed. =  You can try a simple example (click off the menu):

(let = ((menu-bar (make-sparse-keymap "Dismiss Menu")))
  (define-key menu-bar [testing] '(menu-item "Nothing" = nil))
  (popup-menu menu-bar))

= --Apple-Mail=_D9C65C4A-7278-47DC-A808-570626F15329--