From: Drew Adams <drew.adams@oracle.com>
To: 26421@debbugs.gnu.org
Subject: bug#26421: 25.1; Handling of prefix arg in menus
Date: Sun, 9 Apr 2017 11:04:44 -0700 (PDT) [thread overview]
Message-ID: <38c2c69b-7911-40dc-9eaf-b9ea644d2800@default> (raw)
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
:visible
(progn
(message "PP: %S"
(and current-prefix-arg
(prefix-numeric-value current-prefix-arg)))
(and current-prefix-arg
(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
:visible
(progn
(message "PP: %S"
(and current-prefix-arg
(prefix-numeric-value current-prefix-arg)))
(and current-prefix-arg
(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=-O2
-static -g3''
next reply other threads:[~2017-04-09 18:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-09 18:04 Drew Adams [this message]
2017-04-09 18:14 ` bug#26421: 25.1; Handling of prefix arg in menus Drew Adams
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=38c2c69b-7911-40dc-9eaf-b9ea644d2800@default \
--to=drew.adams@oracle.com \
--cc=26421@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.