unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#26421: 25.1; Handling of prefix arg in menus
@ 2017-04-09 18:04 Drew Adams
  2017-04-09 18:14 ` Drew Adams
  0 siblings, 1 reply; 2+ messages in thread
From: Drew Adams @ 2017-04-09 18:04 UTC (permalink / raw)
  To: 26421

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''





^ permalink raw reply	[flat|nested] 2+ messages in thread

* bug#26421: 25.1; Handling of prefix arg in menus
  2017-04-09 18:04 bug#26421: 25.1; Handling of prefix arg in menus Drew Adams
@ 2017-04-09 18:14 ` Drew Adams
  0 siblings, 0 replies; 2+ messages in thread
From: Drew Adams @ 2017-04-09 18:14 UTC (permalink / raw)
  To: 26421

> * 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.

I should have added that for the value is nil also for plain `C-u',
that is, `C-u' not followed by anything.  But 4 is the value for
plain `C-u C-u' etc.

IOW:

If `C-u' is followed by another key then the value is 4.
If `C-u' is not followed by another key then the value is nil.





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-04-09 18:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-09 18:04 bug#26421: 25.1; Handling of prefix arg in menus Drew Adams
2017-04-09 18:14 ` Drew Adams

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).