bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#26421: 25.1; Handling of prefix arg in menus


From: Drew Adams
Subject: bug#26421: 25.1; Handling of prefix arg in menus
Date: Sun, 9 Apr 2017 11:04:44 -0700 (PDT)

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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]