From mboxrd@z Thu Jan  1 00:00:00 1970
Path: news.gmane.org!.POSTED!not-for-mail
From: Drew Adams <drew.adams@oracle.com>
Newsgroups: gmane.emacs.bugs
Subject: bug#26421: 25.1; Handling of prefix arg in menus
Date: Sun, 9 Apr 2017 11:04:44 -0700 (PDT)
Message-ID: <38c2c69b-7911-40dc-9eaf-b9ea644d2800@default>
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Trace: blaine.gmane.org 1491762129 12295 195.159.176.226 (9 Apr 2017 18:22:09 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Sun, 9 Apr 2017 18:22:09 +0000 (UTC)
To: 26421@debbugs.gnu.org
Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Apr 09 20:22:03 2017
Return-path: <bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org>
Envelope-to: geb-bug-gnu-emacs@m.gmane.org
Original-Received: from lists.gnu.org ([208.118.235.17])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org>)
	id 1cxHTO-0002MP-MI
	for geb-bug-gnu-emacs@m.gmane.org; Sun, 09 Apr 2017 20:22:03 +0200
Original-Received: from localhost ([::1]:59322 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org>)
	id 1cxHE3-0006NS-NU
	for geb-bug-gnu-emacs@m.gmane.org; Sun, 09 Apr 2017 14:06:11 -0400
Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47473)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1cxHDy-0006NL-Cm
	for bug-gnu-emacs@gnu.org; Sun, 09 Apr 2017 14:06:07 -0400
Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1cxHDv-0004lC-8n
	for bug-gnu-emacs@gnu.org; Sun, 09 Apr 2017 14:06:06 -0400
Original-Received: from debbugs.gnu.org ([208.118.235.43]:41838)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <Debian-debbugs@debbugs.gnu.org>)
	id 1cxHDv-0004l6-4u
	for bug-gnu-emacs@gnu.org; Sun, 09 Apr 2017 14:06:03 -0400
Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2)
	(envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1cxHDu-0003H2-Op
	for bug-gnu-emacs@gnu.org; Sun, 09 Apr 2017 14:06:02 -0400
X-Loop: help-debbugs@gnu.org
Resent-From: Drew Adams <drew.adams@oracle.com>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@gnu.org
Resent-Date: Sun, 09 Apr 2017 18:06:02 +0000
Resent-Message-ID: <handler.26421.B.149176110312506@debbugs.gnu.org>
Resent-Sender: help-debbugs@gnu.org
X-GNU-PR-Message: report 26421
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
X-Debbugs-Original-To: bug-gnu-emacs@gnu.org
Original-Received: via spool by submit@debbugs.gnu.org id=B.149176110312506
	(code B ref -1); Sun, 09 Apr 2017 18:06:02 +0000
Original-Received: (at submit) by debbugs.gnu.org; 9 Apr 2017 18:05:03 +0000
Original-Received: from localhost ([127.0.0.1]:40035 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces@debbugs.gnu.org>)
	id 1cxHCw-0003Fa-Ke
	for submit@debbugs.gnu.org; Sun, 09 Apr 2017 14:05:02 -0400
Original-Received: from eggs.gnu.org ([208.118.235.92]:56442)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <drew.adams@oracle.com>) id 1cxHCu-0003F5-9T
	for submit@debbugs.gnu.org; Sun, 09 Apr 2017 14:05:01 -0400
Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <drew.adams@oracle.com>) id 1cxHCo-0004Ld-99
	for submit@debbugs.gnu.org; Sun, 09 Apr 2017 14:04:55 -0400
Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:34421)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <drew.adams@oracle.com>)
	id 1cxHCo-0004LZ-6S
	for submit@debbugs.gnu.org; Sun, 09 Apr 2017 14:04:54 -0400
Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47413)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <drew.adams@oracle.com>) id 1cxHCn-0006Gq-1H
	for bug-gnu-emacs@gnu.org; Sun, 09 Apr 2017 14:04:54 -0400
Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <drew.adams@oracle.com>) id 1cxHCj-0004Ke-TK
	for bug-gnu-emacs@gnu.org; Sun, 09 Apr 2017 14:04:53 -0400
Original-Received: from aserp1040.oracle.com ([141.146.126.69]:26622)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <drew.adams@oracle.com>)
	id 1cxHCj-0004Jg-JS
	for bug-gnu-emacs@gnu.org; Sun, 09 Apr 2017 14:04:49 -0400
Original-Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71])
	by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with
	ESMTP id v39I4kP1018418
	(version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK)
	for <bug-gnu-emacs@gnu.org>; Sun, 9 Apr 2017 18:04:46 GMT
Original-Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72])
	by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id v39I4jmD022304
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256
	verify=OK) for <bug-gnu-emacs@gnu.org>; Sun, 9 Apr 2017 18:04:46 GMT
Original-Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16])
	by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id v39I4jYE020134
	for <bug-gnu-emacs@gnu.org>; Sun, 9 Apr 2017 18:04:45 GMT
X-Priority: 3
X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1  (1003210) [OL
	12.0.6753.5000 (x86)]
X-Source-IP: userv0021.oracle.com [156.151.31.71]
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
	[fuzzy]
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-BeenThere: debbugs-submit@debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 208.118.235.43
X-BeenThere: bug-gnu-emacs@gnu.org
List-Id: "Bug reports for GNU Emacs,
	the Swiss army knife of text editors" <bug-gnu-emacs.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-gnu-emacs>,
	<mailto:bug-gnu-emacs-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/bug-gnu-emacs/>
List-Post: <mailto:bug-gnu-emacs@gnu.org>
List-Help: <mailto:bug-gnu-emacs-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-gnu-emacs>,
	<mailto:bug-gnu-emacs-request@gnu.org?subject=subscribe>
Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org
Original-Sender: "bug-gnu-emacs"
	<bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org>
Xref: news.gmane.org gmane.emacs.bugs:131415
Archived-At: <http://permalink.gmane.org/gmane.emacs.bugs/131415>

emacs -Q

Evaluate this code:

(defvar menu-bar-foo-menu (make-sparse-keymap "Foo"))
(define-key global-map [menu-bar foo] (cons "Foo" menu-bar-foo-menu))

(define-key menu-bar-foo-menu [toto]
  '(menu-item "Toto" forward-char
=09      :visible
=09      (progn
=09=09(message "PP: %S"
=09=09=09 (and current-prefix-arg
=09=09=09      (prefix-numeric-value current-prefix-arg)))
=09=09(and current-prefix-arg
=09=09     (prefix-numeric-value current-prefix-arg)))))

(defvar bar-menu (make-sparse-keymap "Bar"))
(define-key menu-bar-foo-menu [bar] (cons "Bar" bar-menu))

(define-key bar-menu [foobar]
  '(menu-item "XXX" forward-char
=09      :visible
=09      (progn
=09=09(message "PP: %S"
=09=09=09 (and current-prefix-arg
=09=09=09      (prefix-numeric-value current-prefix-arg)))
=09=09(and current-prefix-arg
=09=09     (prefix-numeric-value current-prefix-arg)))))

Open *Messages* in another frame, so you can see messages there.

In the original frame, access menu Foo and submenu Bar, using (1) no
prefix arg, (2) a prefix arg introduced using `C-u', and (3) a prefix
arg introduced in another way, such as `M-2'.

The actual prefix arg you give is not employed in the :visible code
(same thing for :enable).  Instead:

* For no prefix arg given, or for any prefix arg given other than by
  using explicit `C-u', the value used by :visible is nil.

* For a prefix arg given using explicit `C-u', the value used by
  :visible is 4.

That is, in the former case you see always "PP: nil" output, and for the
latter you see always "PP: 4" output.

This means that you cannot use the prefix arg in a menu-item test.
This should not be the case.  (This problem is not new.)


In GNU Emacs 25.1.1 (x86_64-w64-mingw32)
 of 2016-11-15
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
 `configure --without-dbus --without-compress-install 'CFLAGS=3D-O2
 -static -g3''