all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* menu indications of key bindings for remapped commands
@ 2007-01-10 22:24 Drew Adams
  2007-01-10 23:37 ` Stefan Monnier
  2007-01-11  9:42 ` Kim F. Storm
  0 siblings, 2 replies; 13+ messages in thread
From: Drew Adams @ 2007-01-10 22:24 UTC (permalink / raw)


What is the reason that a remapped command in a menu item has its key
binding listed as, for example, "(<remap> <switch-to-buffer>)"? Is it
because it would be impossible or difficult to pick up one of the final keys
that it is actually bound to - e.g. "(C-x b)"?

I assume this is not an oversight or a bug - I'm just curious as to why this
appears this way. It is not especially useful for users to see this, IMO.

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

* Re: menu indications of key bindings for remapped commands
  2007-01-10 22:24 menu indications of key bindings for remapped commands Drew Adams
@ 2007-01-10 23:37 ` Stefan Monnier
  2007-01-13  5:49   ` Drew Adams
  2007-01-11  9:42 ` Kim F. Storm
  1 sibling, 1 reply; 13+ messages in thread
From: Stefan Monnier @ 2007-01-10 23:37 UTC (permalink / raw)
  Cc: Emacs-Devel

> What is the reason that a remapped command in a menu item has its key
> binding listed as, for example, "(<remap> <switch-to-buffer>)"? Is it
> because it would be impossible or difficult to pick up one of the final keys
> that it is actually bound to - e.g. "(C-x b)"?

It's a bug.
Could you give a test case?


        Stefan

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

* Re: menu indications of key bindings for remapped commands
  2007-01-10 22:24 menu indications of key bindings for remapped commands Drew Adams
  2007-01-10 23:37 ` Stefan Monnier
@ 2007-01-11  9:42 ` Kim F. Storm
  1 sibling, 0 replies; 13+ messages in thread
From: Kim F. Storm @ 2007-01-11  9:42 UTC (permalink / raw)
  Cc: Emacs-Devel

"Drew Adams" <drew.adams@oracle.com> writes:

> What is the reason that a remapped command in a menu item has its key
> binding listed as, for example, "(<remap> <switch-to-buffer>)"? Is it
> because it would be impossible or difficult to pick up one of the final keys
> that it is actually bound to - e.g. "(C-x b)"?
>
> I assume this is not an oversight or a bug - I'm just curious as to why this
> appears this way. It is not especially useful for users to see this, IMO.

I don't see it.  And I have several remapped commands (from ido-mode).

Can you please give a specific example/recipe of this.

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

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

* RE: menu indications of key bindings for remapped commands
       [not found] <EIENLHALHGIMHGDOLMIMMEEFCOAA.drew.adams@oracle.com>
@ 2007-01-11 18:15 ` Drew Adams
  2007-01-11 21:29   ` Kim F. Storm
  0 siblings, 1 reply; 13+ messages in thread
From: Drew Adams @ 2007-01-11 18:15 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 128 bytes --]

The GIF file got rejected as a "bad attachment". Is the mailing list now
screening attachment file types?

Trying again as PNG.

[-- Attachment #2: menu-w-remapped-keys.png --]
[-- Type: image/png, Size: 10790 bytes --]

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

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

* menu indications of key bindings for remapped commands
@ 2007-01-11 18:32 Drew Adams
  2007-01-11 21:33 ` Kim F. Storm
  0 siblings, 1 reply; 13+ messages in thread
From: Drew Adams @ 2007-01-11 18:32 UTC (permalink / raw)


I guess this whole message got rejected when the GIF attachment was deemed
"bad". Here it is again, without the attachment (see PNG sent separately).

From: Drew Adams Sent: Thursday, January 11, 2007 10:05 AM

> > What is the reason that a remapped command in a menu item has its key
> > binding listed as, for example, "(<remap> <switch-to-buffer>)"? Is it
> > because it would be impossible or difficult to pick up one of
> > the final keys that it is actually bound to - e.g. "(C-x b)"?
> >
> > I assume this is not an oversight or a bug - I'm just curious
> > as to why this appears this way. It is not especially useful for
> > users to see this, IMO.
>
> I don't see it.  And I have several remapped commands (from ido-mode).

See attached image.

> Can you please give a specific example/recipe of this.

The code is here: http://www.emacswiki.org/cgi-bin/wiki/icicles-mode.el.

The relevant code creating the first menu item is this:

(setq icicle-mode-map (make-sparse-keymap))
(unless icicle-menu-map
  (setq icicle-menu-map (make-sparse-keymap "Icicles"))
  (define-key icicle-mode-map [menu-bar icicles]
              (cons "Icicles" icicle-menu-map)))
(define-key icicle-menu-map [icicle-buffer]
            '("+ Switch to Buffer..." . icicle-buffer)))

The code that does the remapping for the first menu item is this:

(define-key icicle-mode-map [remap switch-to-buffer]
            'icicle-buffer)

The Icicles menubar menu is available whenever global minor mode
`icicle-mode' is turned on. In that minor mode, `switch-to-buffer' is
remapped to `icicle-buffer'. In the Icicles menu, that binding is indicated
as "(<remap> <switch-to-buffer>)".

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

* Re: menu indications of key bindings for remapped commands
  2007-01-11 18:15 ` Drew Adams
@ 2007-01-11 21:29   ` Kim F. Storm
  2007-01-12  2:06     ` Drew Adams
  0 siblings, 1 reply; 13+ messages in thread
From: Kim F. Storm @ 2007-01-11 21:29 UTC (permalink / raw)
  Cc: Emacs-Devel

"Drew Adams" <drew.adams@oracle.com> writes:

> The GIF file got rejected as a "bad attachment". Is the mailing list now
> screening attachment file types?
>
> Trying again as PNG.
>

That is not a standard menu ...so I cannot judge how the remap stuff
got into it.

If you start emacs -Q, then do M-x ido-mode, and the look at the File
and Buffer menus, it correctly shows the C-x C-f and C-x b bindings
even though the commands are remapped.

Maybe the problem is related to remapping stuff in the global map or
some such.  Please be more specific.

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

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

* Re: menu indications of key bindings for remapped commands
  2007-01-11 18:32 Drew Adams
@ 2007-01-11 21:33 ` Kim F. Storm
  0 siblings, 0 replies; 13+ messages in thread
From: Kim F. Storm @ 2007-01-11 21:33 UTC (permalink / raw)
  Cc: Emacs-Devel

"Drew Adams" <drew.adams@oracle.com> writes:

> (define-key icicle-menu-map [icicle-buffer]
>             '("+ Switch to Buffer..." . icicle-buffer)))

Does it help to use

(define-key icicle-menu-map [icicle-buffer]
            '(menu-item "+ Switch to Buffer..." icicle-buffer)))


-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

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

* RE: menu indications of key bindings for remapped commands
  2007-01-11 21:29   ` Kim F. Storm
@ 2007-01-12  2:06     ` Drew Adams
  0 siblings, 0 replies; 13+ messages in thread
From: Drew Adams @ 2007-01-12  2:06 UTC (permalink / raw)


I think I've discovered what the problem is. IMO, there is a bug in the
definition of menu items.

As Kim pointed out, ido has no such problem. However, ido does not create a
menu item; it simply remaps a command that was already used in a menu item -
e.g., command `switch-to-buffer', used in "Buffers" menu item "Select Named
Buffer... (C-x b)". It is the binding of the command `switch-to-buffer' that
is reflected in that menu item. The menu item calls command
`ido-switch-buffer', but the binding displayed is that of
`switch-to-buffer', not that of `ido-switch-buffer'.

In my case, I create menu items, both in standard menus such as "File" and
in a new menu, "Icicles". But that's not the difference that matters. When I
create a menu item for buffer switching, I use a new command,
`icicle-buffer', which is the target of a command remapping. I have this:

(define-key icicle-mode-map [remap switch-to-buffer]
            'icicle-buffer)

And it is the new command `icicle-buffer', not the remapped command
`switch-to-buffer', that I use to define the menu item:

(define-key icicle-menu-map [icicle-buffer]
            '("+ Switch to Buffer..." . icicle-buffer)))
                                        ^^^^^^^^^^^^^

It is the immediate binding of the command `icicle-buffer', "(<remap>
<switch-to-buffer>)", that is reflected in the menu item. From a user point
of view, it is only the ultimate, user-friendly key binding that is of
interest, that is, the binding of the remapped command, `switch-to-buffer'.
It is that binding, "(C-x b)", that should be displayed in the menu item.
Showing "(<remap> <switch-to-buffer>)" to the user is a bug, IMO.

If I use the remapped command, `switch-to-buffer', in the menu-item
definition, then the correct key binding, "(C-x b)", does indeed show up in
the menu item:

(define-key icicle-menu-map [icicle-buffer]
            '("+ Switch to Buffer..." . switch-to-buffer)))
                                        ^^^^^^^^^^^^^^^^

But it is handy and more readable to use the new command that is the remap
target, `icicle-buffer', not the remapped command, `switch-to-buffer', in
the menu-item definition. A library will typically want to express
everything in terms of its own command, and then have a single remapping
that references the remapped command. And it is possible that the remapped
command has no key binding at runtime - in that case, the menu item should
show no key binding; it should not show (<remap>...). The bottom line is
that the key-binding indication in a menu item should be as helpful as
possible to the user.

So, I see two use cases:

1. (ido use case) Remap a command that was already used to define a menu
item.

2. (icicles use case) Define a new menu item, using a command that is a
remap target. (The remapped command might or might not itself also be
already used to define a different menu item.)

The key binding shown in the menu item should in both cases be user-friendly
(C-x b), that is, regardless of which command is used in the menu-item
definition: remap source or remap target.

In the case of Icicles, the "Buffers" menu item "Select Named Buffer..."
does show the user-friendly binding "(C-x b)", because it is a pre-existing
menu item that was defined using command `switch-to-buffer'. The same key
binding should also be shown for a new menu item that is defined using the
remap target, `icicle-buffer'.

The user should see only the final key binding - what s?he types, which is
always the binding of the remap source (`switch-to-buffer', in this case).
The fix is to treat a remap target the same way: always get and use the
ultimate key binding in the menu item.

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

* RE: menu indications of key bindings for remapped commands
  2007-01-10 23:37 ` Stefan Monnier
@ 2007-01-13  5:49   ` Drew Adams
  2007-01-14  1:56     ` Richard Stallman
  0 siblings, 1 reply; 13+ messages in thread
From: Drew Adams @ 2007-01-13  5:49 UTC (permalink / raw)


> > What is the reason that a remapped command in a menu item has its key
> > binding listed as, for example, "(<remap> <switch-to-buffer>)"? Is it
> > because it would be impossible or difficult to pick up one of
> > the final keys
> > that it is actually bound to - e.g. "(C-x b)"?
>
> It's a bug.
> Could you give a test case?

See my previous mail. Just create a menu using a command that is the
*target* of a command remapping. IOW, remap foo to bar, and then create a
menu item using command bar (not foo). My previous email details the problem
and gives examples.

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

* Re: menu indications of key bindings for remapped commands
  2007-01-13  5:49   ` Drew Adams
@ 2007-01-14  1:56     ` Richard Stallman
  2007-01-22 19:44       ` Drew Adams
  0 siblings, 1 reply; 13+ messages in thread
From: Richard Stallman @ 2007-01-14  1:56 UTC (permalink / raw)
  Cc: emacs-devel

    > Could you give a test case?

    See my previous mail. Just create a menu using a command that is the
    *target* of a command remapping.

That is not a test case, that is a general description.  A test case
is code we can execute and see the failure.  A complete test case has
no place where it says "you fill in these details."

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

* RE: menu indications of key bindings for remapped commands
  2007-01-14  1:56     ` Richard Stallman
@ 2007-01-22 19:44       ` Drew Adams
  2007-05-20 23:54         ` Drew Adams
  0 siblings, 1 reply; 13+ messages in thread
From: Drew Adams @ 2007-01-22 19:44 UTC (permalink / raw)


>     > It's a bug.
>     > Could you give a test case?
>
>     See my previous mail. Just create a menu using a command that is the
>     *target* of a command remapping.
>
> That is not a test case, that is a general description.  A test case
> is code we can execute and see the failure.

Try this in emacs -Q

(defvar bar-mode-map (make-sparse-keymap)
  "Keymap for Bar mode.")
(defvar bar-menu-map (make-sparse-keymap "Bar")
  "Keymap for Bar menu.")

(define-key bar-mode-map [menu-bar bar]
  (cons "Bar" bar-menu-map))
(define-key bar-mode-map [remap switch-to-buffer]
  'bar-buffer)

;; This way, the key binding shows incorrectly in the menu.
(define-key bar-menu-map [bar-buffer]
  '("Bar Buffer..." . bar-buffer))

;; This way, the key binding shows correctly in the menu.
;;(define-key bar-menu-map [bar-buffer]
;;  '("Bar Buffer..." . switch-to-buffer))

(define-minor-mode bar-mode "Bar mode")

M-x bar-mode

You'll see the bad menu item (bad key-binding description) in menu Bar.

Now execute the commented code. The menu item is now as it should be.

--

Interestingly, this apparently has something to do with the minor-mode map,
because similar code using the global map does not have the same problem. It
shows, however, no binding at all in the menu item.

(defvar foo-menu-map (make-sparse-keymap "Foo")
  "Keymap for Foo menu.")

(define-key global-map [menu-bar foo]
  (cons "Foo" foo-menu-map))
(define-key global-map [remap switch-to-buffer]
  'foo-buffer)

;; This way, there is no key binding in the menu.
(define-key foo-menu-map [foo-buffer]
  '("Foo Buffer..." . foo-buffer))

;; This way, the key binding shows correctly in the menu.
;;(define-key foo-menu-map [foo-buffer]
;;  '("Foo Buffer..." . switch-to-buffer))

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

* RE: menu indications of key bindings for remapped commands
  2007-01-22 19:44       ` Drew Adams
@ 2007-05-20 23:54         ` Drew Adams
  2007-05-24 21:22           ` Richard Stallman
  0 siblings, 1 reply; 13+ messages in thread
From: Drew Adams @ 2007-05-20 23:54 UTC (permalink / raw)
  To: emacs-devel

I reported this bug in January, but I have not heard anything since. It is
still a bug, as of a build from March 21. Any news?

> From: Drew Adams Sent: Monday, January 22, 2007 11:44 AM
> >     > It's a bug.
> >     > Could you give a test case?
> >
> >     See my previous mail. Just create a menu using a command that is the
> >     *target* of a command remapping.
> >
> > That is not a test case, that is a general description.  A test case
> > is code we can execute and see the failure.
>
> Try this in emacs -Q
>
> (defvar bar-mode-map (make-sparse-keymap)
>   "Keymap for Bar mode.")
> (defvar bar-menu-map (make-sparse-keymap "Bar")
>   "Keymap for Bar menu.")
>
> (define-key bar-mode-map [menu-bar bar]
>   (cons "Bar" bar-menu-map))
> (define-key bar-mode-map [remap switch-to-buffer]
>   'bar-buffer)
>
> ;; This way, the key binding shows incorrectly in the menu.
> (define-key bar-menu-map [bar-buffer]
>   '("Bar Buffer..." . bar-buffer))
>
> ;; This way, the key binding shows correctly in the menu.
> ;;(define-key bar-menu-map [bar-buffer]
> ;;  '("Bar Buffer..." . switch-to-buffer))
>
> (define-minor-mode bar-mode "Bar mode")
>
> M-x bar-mode
>
> You'll see the bad menu item (bad key-binding description) in menu Bar.
>
> Now execute the commented code. The menu item is now as it should be.
>
> --
>
> Interestingly, this apparently has something to do with the
> minor-mode map,
> because similar code using the global map does not have the same
> problem. It
> shows, however, no binding at all in the menu item.
>
> (defvar foo-menu-map (make-sparse-keymap "Foo")
>   "Keymap for Foo menu.")
>
> (define-key global-map [menu-bar foo]
>   (cons "Foo" foo-menu-map))
> (define-key global-map [remap switch-to-buffer]
>   'foo-buffer)
>
> ;; This way, there is no key binding in the menu.
> (define-key foo-menu-map [foo-buffer]
>   '("Foo Buffer..." . foo-buffer))
>
> ;; This way, the key binding shows correctly in the menu.
> ;;(define-key foo-menu-map [foo-buffer]
> ;;  '("Foo Buffer..." . switch-to-buffer))

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

* Re: menu indications of key bindings for remapped commands
  2007-05-20 23:54         ` Drew Adams
@ 2007-05-24 21:22           ` Richard Stallman
  0 siblings, 0 replies; 13+ messages in thread
From: Richard Stallman @ 2007-05-24 21:22 UTC (permalink / raw)
  To: emacs-devel; +Cc: Drew Adams

Would someone please fix this and ack?

> Try this in emacs -Q
>
> (defvar bar-mode-map (make-sparse-keymap)
>   "Keymap for Bar mode.")
> (defvar bar-menu-map (make-sparse-keymap "Bar")
>   "Keymap for Bar menu.")
>
> (define-key bar-mode-map [menu-bar bar]
>   (cons "Bar" bar-menu-map))
> (define-key bar-mode-map [remap switch-to-buffer]
>   'bar-buffer)
>
> ;; This way, the key binding shows incorrectly in the menu.
> (define-key bar-menu-map [bar-buffer]
>   '("Bar Buffer..." . bar-buffer))
>
> ;; This way, the key binding shows correctly in the menu.
> ;;(define-key bar-menu-map [bar-buffer]
> ;;  '("Bar Buffer..." . switch-to-buffer))
>
> (define-minor-mode bar-mode "Bar mode")
>
> M-x bar-mode
>
> You'll see the bad menu item (bad key-binding description) in menu Bar.
>
> Now execute the commented code. The menu item is now as it should be.

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

end of thread, other threads:[~2007-05-24 21:22 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-10 22:24 menu indications of key bindings for remapped commands Drew Adams
2007-01-10 23:37 ` Stefan Monnier
2007-01-13  5:49   ` Drew Adams
2007-01-14  1:56     ` Richard Stallman
2007-01-22 19:44       ` Drew Adams
2007-05-20 23:54         ` Drew Adams
2007-05-24 21:22           ` Richard Stallman
2007-01-11  9:42 ` Kim F. Storm
     [not found] <EIENLHALHGIMHGDOLMIMMEEFCOAA.drew.adams@oracle.com>
2007-01-11 18:15 ` Drew Adams
2007-01-11 21:29   ` Kim F. Storm
2007-01-12  2:06     ` Drew Adams
  -- strict thread matches above, loose matches on Subject: below --
2007-01-11 18:32 Drew Adams
2007-01-11 21:33 ` Kim F. Storm

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.