GNU bug report logs - #64699
Invalid key definition for keymap-set-after

Previous Next

Package: emacs;

Reported by: uzibalqa <uzibalqa <at> proton.me>

Date: Tue, 18 Jul 2023 10:01:02 UTC

Severity: normal

Done: Po Lu <luangruo <at> yahoo.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 64699 in the body.
You can then email your comments to 64699 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#64699; Package emacs. (Tue, 18 Jul 2023 10:01:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to uzibalqa <uzibalqa <at> proton.me>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 18 Jul 2023 10:01:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: uzibalqa <uzibalqa <at> proton.me>
To: "bug-gnu-emacs <at> gnu.org" <bug-gnu-emacs <at> gnu.org>
Subject: Invalid key definition for keymap-set-after
Date: Tue, 18 Jul 2023 10:00:06 +0000

It is recommended that 'keymap-set-after' is used instead of 'define-key-after'.

But replacing

  (defvar mcp-kdf (make-sparse-keymap "MCP"))
  (define-key-after global-map
    [menu-bar mcp-topm] (cons "MCP" mcp-kdf) 'tools)

with 

  (defvar mcp-kdf (make-sparse-keymap "MCP"))
  (keymap-set-after global-map
    [menu-bar mcp-topm] (cons "MCP" mcp-kdf) 'tools)

gives the following error

(error "[menu-bar mcp-topm] is not a valid key definition;...")
  signal(error ("[menu-bar mcp-topm] is not a valid key definition;..."))
  error("%S is not a valid key definition; see `key-valid-p..." [menu-bar mcp-topm])
  keymap--check([menu-bar mcp-topm])
  keymap-set-after((keymap #^[nil nil keymap 
#^^[3 0 set-mark-command move-beginning-of-line backward-char mode-specific-command-prefix delete-char move-end-of-line forward-char keyboard-quit help-command indent-for-tab-command electric-newline-and-maybe-indent kill-line recenter-top-bottom newline next-line open-line previous-line quoted-insert isearch-backward isearch-forward transpose-chars universal-argument scroll-up-command kill-region Control-X-prefix yank suspend-frame ESC-prefix toggle-input-method abort-recursive-edit nil undo self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command ...] #^^[1 0 #^^[2 0 
#^^[3 0 set-mark-command move-beginning-of-line backward-char mode-specific-command-prefix delete-char move-end-of-line forward-char keyboard-quit help-command indent-for-tab-command electric-newline-and-maybe-indent kill-line recenter-top-bottom newline next-line open-line previous-line quoted-insert isearch-backward isearch-forward transpose-chars universal-argument scroll-up-command kill-region Control-X-prefix yank suspend-frame ESC-prefix toggle-input-method abort-recursive-edit nil undo self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command ...] self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command] self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command] self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command ...] (67108908 . text-scale-decrease) (67108910 . text-scale-increase) (f5 . modus-themes-toggle) (paste . clipboard-yank) (copy . clipboard-kill-ring-save) (cut . clipboard-kill-region) (f18 . clipboard-yank) (f16 . clipboard-kill-ring-save) (f20 . clipboard-kill-region) (C-wheel-down . mouse-wheel-text-scale) (C-wheel-up . mouse-wheel-text-scale) (C-mouse-5 . mouse-wheel-text-scale) (C-mouse-4 . mouse-wheel-text-scale) (C-M-wheel-down . mouse-wheel-global-text-scale) (C-M-wheel-up . mouse-wheel-global-text-scale) (C-M-mouse-5 . mouse-wheel-global-text-scale) (C-M-mouse-4 . mouse-wheel-global-text-scale) (M-wheel-right . mwheel-scroll) (M-wheel-left . mwheel-scroll) (M-wheel-down . mwheel-scroll) (M-wheel-up . mwheel-scroll) (M-mouse-7 . mwheel-scroll) (M-mouse-6 . mwheel-scroll) (M-mouse-5 . mwheel-scroll) (M-mouse-4 . mwheel-scroll) (S-wheel-right . mwheel-scroll) (S-wheel-left . mwheel-scroll) (S-wheel-down . mwheel-scroll) (S-wheel-up . mwheel-scroll) (S-mouse-7 . mwheel-scroll) (S-mouse-6 . mwheel-scroll) (S-mouse-5 . mwheel-scroll) (S-mouse-4 . mwheel-scroll) (wheel-right . mwheel-scroll) (wheel-left . mwheel-scroll) (wheel-down . mwheel-scroll) ...) [menu-bar mcp-topm] ("MCP" keymap "MCP") tools)
  mcp-menubar()
  eval-buffer(#<buffer  *load*-661928> nil "/home/hagbard/Opstk/bin/gungadin-1.0/typex/oktant/..." nil t)  ; Reading at buffer position 10068
  load-with-code-conversion("/home/hagbard/Opstk/bin/gungadin-1.0/typex/oktant/..." "/home/hagbard/Opstk/bin/gungadin-1.0/typex/oktant/..." nil t)
  require(mcp)








Reply sent to Po Lu <luangruo <at> yahoo.com>:
You have taken responsibility. (Tue, 18 Jul 2023 10:30:02 GMT) Full text and rfc822 format available.

Notification sent to uzibalqa <uzibalqa <at> proton.me>:
bug acknowledged by developer. (Tue, 18 Jul 2023 10:30:03 GMT) Full text and rfc822 format available.

Message #10 received at 64699-done <at> debbugs.gnu.org (full text, mbox):

From: Po Lu <luangruo <at> yahoo.com>
To: uzibalqa <uzibalqa <at> proton.me>
Cc: 64699-done <at> debbugs.gnu.org
Subject: Re: bug#64699: Invalid key definition for keymap-set-after
Date: Tue, 18 Jul 2023 18:29:08 +0800
uzibalqa <uzibalqa <at> proton.me> writes:

> It is recommended that 'keymap-set-after' is used instead of 'define-key-after'.
>
> But replacing
>
>   (defvar mcp-kdf (make-sparse-keymap "MCP"))
>   (define-key-after global-map
>     [menu-bar mcp-topm] (cons "MCP" mcp-kdf) 'tools)
>
> with 
>
>   (defvar mcp-kdf (make-sparse-keymap "MCP"))
>   (keymap-set-after global-map
>     [menu-bar mcp-topm] (cons "MCP" mcp-kdf) 'tools)
>
> gives the following error
>
> (error "[menu-bar mcp-topm] is not a valid key definition;...")
>   signal(error ("[menu-bar mcp-topm] is not a valid key definition;..."))
>   error("%S is not a valid key definition; see `key-valid-p..." [menu-bar mcp-topm])
>   keymap--check([menu-bar mcp-topm])
>   keymap-set-after((keymap #^[nil nil keymap 
> #^^[3 0 set-mark-command move-beginning-of-line backward-char mode-specific-command-prefix delete-char move-end-of-line forward-char keyboard-quit help-command indent-for-tab-command electric-newline-and-maybe-indent kill-line recenter-top-bottom newline next-line open-line previous-line quoted-insert isearch-backward isearch-forward transpose-chars universal-argument scroll-up-command kill-region Control-X-prefix yank suspend-frame ESC-prefix toggle-input-method abort-recursive-edit nil undo self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command ...] #^^[1 0 #^^[2 0 
> #^^[3 0 set-mark-command move-beginning-of-line backward-char mode-specific-command-prefix delete-char move-end-of-line forward-char keyboard-quit help-command indent-for-tab-command electric-newline-and-maybe-indent kill-line recenter-top-bottom newline next-line open-line previous-line quoted-insert isearch-backward isearch-forward transpose-chars universal-argument scroll-up-command kill-region Control-X-prefix yank suspend-frame ESC-prefix toggle-input-method abort-recursive-edit nil undo self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command ...] self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command] self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command] self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command ...] (67108908 . text-scale-decrease) (67108910 . text-scale-increase) (f5 . modus-themes-toggle) (paste . clipboard-yank) (copy . clipboard-kill-ring-save) (cut . clipboard-kill-region) (f18 . clipboard-yank) (f16 . clipboard-kill-ring-save) (f20 . clipboard-kill-region) (C-wheel-down . mouse-wheel-text-scale) (C-wheel-up . mouse-wheel-text-scale) (C-mouse-5 . mouse-wheel-text-scale) (C-mouse-4 . mouse-wheel-text-scale) (C-M-wheel-down . mouse-wheel-global-text-scale) (C-M-wheel-up . mouse-wheel-global-text-scale) (C-M-mouse-5 . mouse-wheel-global-text-scale) (C-M-mouse-4 . mouse-wheel-global-text-scale) (M-wheel-right . mwheel-scroll) (M-wheel-left . mwheel-scroll) (M-wheel-down . mwheel-scroll) (M-wheel-up . mwheel-scroll) (M-mouse-7 . mwheel-scroll) (M-mouse-6 . mwheel-scroll) (M-mouse-5 . mwheel-scroll) (M-mouse-4 . mwheel-scroll) (S-wheel-right . mwheel-scroll) (S-wheel-left . mwheel-scroll) (S-wheel-down . mwheel-scroll) (S-wheel-up . mwheel-scroll) (S-mouse-7 . mwheel-scroll) (S-mouse-6 . mwheel-scroll) (S-mouse-5 . mwheel-scroll) (S-mouse-4 . mwheel-scroll) (wheel-right . mwheel-scroll) (wheel-left . mwheel-scroll) (wheel-down . mwheel-scroll) ...) [menu-bar mcp-topm] ("MCP" keymap "MCP") tools)
>   mcp-menubar()
>   eval-buffer(#<buffer  *load*-661928> nil "/home/hagbard/Opstk/bin/gungadin-1.0/typex/oktant/..." nil t)  ; Reading at buffer position 10068
>   load-with-code-conversion("/home/hagbard/Opstk/bin/gungadin-1.0/typex/oktant/..." "/home/hagbard/Opstk/bin/gungadin-1.0/typex/oktant/..." nil t)
>   require(mcp)

The documentation does not mention or imply that `keymap-set-after'
accepts the same key sequence format as `define-key-after'.  And indeed
it does not.

Closing.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64699; Package emacs. (Tue, 18 Jul 2023 12:15:02 GMT) Full text and rfc822 format available.

Message #13 received at 64699 <at> debbugs.gnu.org (full text, mbox):

From: Robert Pluim <rpluim <at> gmail.com>
To: 64699 <at> debbugs.gnu.org
Cc: luangruo <at> yahoo.com, uzibalqa <at> proton.me
Subject: Re: bug#64699: Invalid key definition for keymap-set-after
Date: Tue, 18 Jul 2023 14:13:53 +0200
>>>>> On Tue, 18 Jul 2023 18:29:08 +0800, Po Lu via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org> said:

    Po Lu> The documentation does not mention or imply that `keymap-set-after'
    Po Lu> accepts the same key sequence format as `define-key-after'.  And indeed
    Po Lu> it does not.

To be fair, we could probably do with some words about non-key events,
explaining that you need to write stuff like "<menu-bar> <mcp-topm>"

Robert
-- 




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64699; Package emacs. (Tue, 18 Jul 2023 12:35:02 GMT) Full text and rfc822 format available.

Message #16 received at 64699 <at> debbugs.gnu.org (full text, mbox):

From: Christopher Dimech <dimech <at> gmx.com>
To: Robert Pluim <rpluim <at> gmail.com>
Cc: luangruo <at> yahoo.com, 64699 <at> debbugs.gnu.org, uzibalqa <at> proton.me
Subject: Re: bug#64699: Invalid key definition for keymap-set-after
Date: Tue, 18 Jul 2023 14:34:41 +0200
> Sent: Wednesday, July 19, 2023 at 12:13 AM
> From: "Robert Pluim" <rpluim <at> gmail.com>
> To: 64699 <at> debbugs.gnu.org
> Cc: luangruo <at> yahoo.com, uzibalqa <at> proton.me
> Subject: bug#64699: Invalid key definition for keymap-set-after
>
> >>>>> On Tue, 18 Jul 2023 18:29:08 +0800, Po Lu via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org> said:
>
>     Po Lu> The documentation does not mention or imply that `keymap-set-after'
>     Po Lu> accepts the same key sequence format as `define-key-after'.  And indeed
>     Po Lu> it does not.
>
> To be fair, we could probably do with some words about non-key events,
> explaining that you need to write stuff like "<menu-bar> <mcp-topm>" - Robert

Indeed, we should.  Vectors for menu items has a rather sketchy description,
requiring references that point to things all over the manual.






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64699; Package emacs. (Tue, 18 Jul 2023 12:38:02 GMT) Full text and rfc822 format available.

Message #19 received at 64699-done <at> debbugs.gnu.org (full text, mbox):

From: uzibalqa <uzibalqa <at> proton.me>
To: Po Lu <luangruo <at> yahoo.com>
Cc: 64699-done <at> debbugs.gnu.org
Subject: Re: bug#64699: Invalid key definition for keymap-set-after
Date: Tue, 18 Jul 2023 12:37:33 +0000

------- Original Message -------
On Tuesday, July 18th, 2023 at 10:29 PM, Po Lu <luangruo <at> yahoo.com> wrote:


> uzibalqa uzibalqa <at> proton.me writes:
> 
> > It is recommended that 'keymap-set-after' is used instead of 'define-key-after'.
> > 
> > But replacing
> > 
> > (defvar mcp-kdf (make-sparse-keymap "MCP"))
> > (define-key-after global-map
> > [menu-bar mcp-topm] (cons "MCP" mcp-kdf) 'tools)
> > 
> > with
> > 
> > (defvar mcp-kdf (make-sparse-keymap "MCP"))
> > (keymap-set-after global-map
> > [menu-bar mcp-topm] (cons "MCP" mcp-kdf) 'tools)
> > 
> > gives the following error
> > 
> > (error "[menu-bar mcp-topm] is not a valid key definition;...")
> > signal(error ("[menu-bar mcp-topm] is not a valid key definition;..."))
> > error("%S is not a valid key definition; see `key-valid-p..." [menu-bar mcp-topm])
> > keymap--check([menu-bar mcp-topm])
> > keymap-set-after((keymap #^[nil nil keymap
> > #^^[3 0 set-mark-command move-beginning-of-line backward-char mode-specific-command-prefix delete-char move-end-of-line forward-char keyboard-quit help-command indent-for-tab-command electric-newline-and-maybe-indent kill-line recenter-top-bottom newline next-line open-line previous-line quoted-insert isearch-backward isearch-forward transpose-chars universal-argument scroll-up-command kill-region Control-X-prefix yank suspend-frame ESC-prefix toggle-input-method abort-recursive-edit nil undo self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command ...] #^^[1 0 #^^[2 0
> > #^^[3 0 set-mark-command move-beginning-of-line backward-char mode-specific-command-prefix delete-char move-end-of-line forward-char keyboard-quit help-command indent-for-tab-command electric-newline-and-maybe-indent kill-line recenter-top-bottom newline next-line open-line previous-line quoted-insert isearch-backward isearch-forward transpose-chars universal-argument scroll-up-command kill-region Control-X-prefix yank suspend-frame ESC-prefix toggle-input-method abort-recursive-edit nil undo self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command ...] self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command] self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command] self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command self-insert-command ...] (67108908 . text-scale-decrease) (67108910 . text-scale-increase) (f5 . modus-themes-toggle) (paste . clipboard-yank) (copy . clipboard-kill-ring-save) (cut . clipboard-kill-region) (f18 . clipboard-yank) (f16 . clipboard-kill-ring-save) (f20 . clipboard-kill-region) (C-wheel-down . mouse-wheel-text-scale) (C-wheel-up . mouse-wheel-text-scale) (C-mouse-5 . mouse-wheel-text-scale) (C-mouse-4 . mouse-wheel-text-scale) (C-M-wheel-down . mouse-wheel-global-text-scale) (C-M-wheel-up . mouse-wheel-global-text-scale) (C-M-mouse-5 . mouse-wheel-global-text-scale) (C-M-mouse-4 . mouse-wheel-global-text-scale) (M-wheel-right . mwheel-scroll) (M-wheel-left . mwheel-scroll) (M-wheel-down . mwheel-scroll) (M-wheel-up . mwheel-scroll) (M-mouse-7 . mwheel-scroll) (M-mouse-6 . mwheel-scroll) (M-mouse-5 . mwheel-scroll) (M-mouse-4 . mwheel-scroll) (S-wheel-right . mwheel-scroll) (S-wheel-left . mwheel-scroll) (S-wheel-down . mwheel-scroll) (S-wheel-up . mwheel-scroll) (S-mouse-7 . mwheel-scroll) (S-mouse-6 . mwheel-scroll) (S-mouse-5 . mwheel-scroll) (S-mouse-4 . mwheel-scroll) (wheel-right . mwheel-scroll) (wheel-left . mwheel-scroll) (wheel-down . mwheel-scroll) ...) [menu-bar mcp-topm] ("MCP" keymap "MCP") tools)
> > mcp-menubar()
> > eval-buffer(#<buffer load-661928> nil "/home/hagbard/Opstk/bin/gungadin-1.0/typex/oktant/..." nil t) ; Reading at buffer position 10068
> > load-with-code-conversion("/home/hagbard/Opstk/bin/gungadin-1.0/typex/oktant/..." "/home/hagbard/Opstk/bin/gungadin-1.0/typex/oktant/..." nil t)
> > require(mcp)
> 
> 
> The documentation does not mention or imply that `keymap-set-after' accepts the same key sequence format as` define-key-after'. And indeed
> it does not.

How is it supposed to be used then.  You request people to change but do net help them 
move forward.  What declaration would `keymap-set-after' use ?

 
> Closing.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64699; Package emacs. (Tue, 18 Jul 2023 12:44:01 GMT) Full text and rfc822 format available.

Message #22 received at 64699-done <at> debbugs.gnu.org (full text, mbox):

From: Po Lu <luangruo <at> yahoo.com>
To: uzibalqa <uzibalqa <at> proton.me>
Cc: 64699-done <at> debbugs.gnu.org
Subject: Re: bug#64699: Invalid key definition for keymap-set-after
Date: Tue, 18 Jul 2023 20:42:56 +0800
uzibalqa <uzibalqa <at> proton.me> writes:

> How is it supposed to be used then.  You request people to change but
> do net help them move forward.  What declaration would
> `keymap-set-after' use ?

See the doc string of keymap-set-after, which mentions keymap-set...?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64699; Package emacs. (Tue, 18 Jul 2023 13:05:02 GMT) Full text and rfc822 format available.

Message #25 received at 64699-done <at> debbugs.gnu.org (full text, mbox):

From: uzibalqa <uzibalqa <at> proton.me>
To: Po Lu <luangruo <at> yahoo.com>
Cc: 64699-done <at> debbugs.gnu.org
Subject: Re: bug#64699: Invalid key definition for keymap-set-after
Date: Tue, 18 Jul 2023 13:03:57 +0000
------- Original Message -------
On Wednesday, July 19th, 2023 at 12:42 AM, Po Lu <luangruo <at> yahoo.com> wrote:


> uzibalqa uzibalqa <at> proton.me writes:
> 
> > How is it supposed to be used then. You request people to change but
> > do net help them move forward. What declaration would
> > `keymap-set-after' use ?
> 
> 
> See the doc string of keymap-set-after, which mentions keymap-set...?

Be sensible now.  You expect me to figure it out myself notwithstanding the
fact surrounding the difficulty composing new functions for the specific task
of making menus.  There is no way to successfully decipher anything from the 
docstring that is practical to the task.  It does not even mention menus.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 16 Aug 2023 11:24:16 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 35 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.