* creating a sub-menu
@ 2013-03-05 22:39 ken
2013-03-07 14:14 ` Stephen Berman
0 siblings, 1 reply; 8+ messages in thread
From: ken @ 2013-03-05 22:39 UTC (permalink / raw)
To: GNU Emacs List
Trying to create a sub-menu under "Edit". Got part of the way there,
but still missing something.
(define-key menu-bar-edit-menu [insert-xascii-chars]
'(menu-item "Insert non-ASCII characters" xascii
(xascii "\C-xaa" "ä" "ä` (ä)" ("ä"))
(xascii "\C-xaA" "Ä" "Ä` (Ä)" ("Ä"))
(xascii "\C-xao" "ö" "ö` (ö)" ("ö"))
(xascii "\C-xaO" "Ö" "Ö` (Ö)" ("Ö"))
(xascii "\C-xau" "ü" "ü` (ü)" ("ü"))
(xascii "\C-xaU" "Ü" "Ü` (Ü)" ("Ü"))
(xascii "\C-xas" "ß" "ß` (ß)" ("ß"))
(xascii "\C-xa<" "«" "«` («)" ("«"))
(xascii "\C-xa>" "»" "»` (»)" ("»"))))
Above yields error:
Debugger entered--Lisp error: (wrong-type-argument arrayp xascii)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: creating a sub-menu
[not found] <mailman.21496.1362523165.855.help-gnu-emacs@gnu.org>
@ 2013-03-06 1:42 ` Joost Kremers
2013-03-06 11:44 ` ken
[not found] ` <mailman.21539.1362570279.855.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 8+ messages in thread
From: Joost Kremers @ 2013-03-06 1:42 UTC (permalink / raw)
To: help-gnu-emacs
ken wrote:
> Trying to create a sub-menu under "Edit". Got part of the way there,
> but still missing something.
>
> (define-key menu-bar-edit-menu [insert-xascii-chars]
> '(menu-item "Insert non-ASCII characters" xascii
>
> (xascii "\C-xaa" "ä" "ä` (ä)" ("ä"))
> (xascii "\C-xaA" "Ä" "Ä` (Ä)" ("Ä"))
> (xascii "\C-xao" "ö" "ö` (ö)" ("ö"))
> (xascii "\C-xaO" "Ö" "Ö` (Ö)" ("Ö"))
> (xascii "\C-xau" "ü" "ü` (ü)" ("ü"))
> (xascii "\C-xaU" "Ü" "Ü` (Ü)" ("Ü"))
> (xascii "\C-xas" "ß" "ß` (ß)" ("ß"))
> (xascii "\C-xa<" "«" "«` («)" ("«"))
> (xascii "\C-xa>" "»" "»` (»)" ("»"))))
>
> Above yields error:
> Debugger entered--Lisp error: (wrong-type-argument arrayp xascii)
dunno about the error, but if all you want is to easily type German, why
don't you use an input method? `M-x set-input-method latin9-prefix RET'
and you can type "a to get ä, ~s to get ß, ~< to get «, etc.
(info "(emacs) Input Methods") for details.
HTH
--
Joost Kremers joostkremers@fastmail.fm
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: creating a sub-menu
2013-03-06 1:42 ` Joost Kremers
@ 2013-03-06 11:44 ` ken
[not found] ` <mailman.21539.1362570279.855.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 8+ messages in thread
From: ken @ 2013-03-06 11:44 UTC (permalink / raw)
To: Joost Kremers, GNU Emacs List
n 03/05/2013 08:42 PM Joost Kremers wrote:
> ken wrote:
>> Trying to create a sub-menu under "Edit". Got part of the way there,
>> but still missing something.
>>
>> (define-key menu-bar-edit-menu [insert-xascii-chars]
>> '(menu-item "Insert non-ASCII characters" xascii
>>
>> (xascii "\C-xaa" "ä" "ä` (ä)" ("ä"))
>> (xascii "\C-xaA" "Ä" "Ä` (Ä)" ("Ä"))
>> (xascii "\C-xao" "ö" "ö` (ö)" ("ö"))
>> (xascii "\C-xaO" "Ö" "Ö` (Ö)" ("Ö"))
>> (xascii "\C-xau" "ü" "ü` (ü)" ("ü"))
>> (xascii "\C-xaU" "Ü" "Ü` (Ü)" ("Ü"))
>> (xascii "\C-xas" "ß" "ß` (ß)" ("ß"))
>> (xascii "\C-xa<" "«" "«` («)" ("«"))
>> (xascii "\C-xa>" "»" "»` (»)" ("»"))))
>>
>> Above yields error:
>> Debugger entered--Lisp error: (wrong-type-argument arrayp xascii)
>
> dunno about the error, but if all you want is to easily type German, why
> don't you use an input method? `M-x set-input-method latin9-prefix RET'
> and you can type "a to get ä, ~s to get ß, ~< to get «, etc.
>
> (info "(emacs) Input Methods") for details.
>
> HTH
Thanks for your response, Joost. But I already have an easier way than
that to change the input method, one which takes just two mouse
clicks... and then another two mouse clicks to return to my normal input
method. But I want a way so that all I need do is "C-xaa" to get 'ä'--
so I can type this and other characters without breaking the flow of my
typing. I want these listed in the menu also because I might not
remember all the key combos for all the characters. (I'll likely add
more in future.)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: creating a sub-menu
[not found] ` <mailman.21539.1362570279.855.help-gnu-emacs@gnu.org>
@ 2013-03-06 20:55 ` Joost Kremers
0 siblings, 0 replies; 8+ messages in thread
From: Joost Kremers @ 2013-03-06 20:55 UTC (permalink / raw)
To: help-gnu-emacs
ken wrote:
> Thanks for your response, Joost. But I already have an easier way than
> that to change the input method, one which takes just two mouse
> clicks... and then another two mouse clicks to return to my normal input
> method.
That's too much. It's also the wrong input medium. ;-) Toggling the
input method can be done with `C-\', which IMHO is much much easier and
quicker than using the mouse.
> But I want a way so that all I need do is "C-xaa" to get 'ä'--
> so I can type this and other characters without breaking the flow of my
> typing.
Using C-\ will allow you to do just that. (In fact, I don't see any
reason why one would want to disable the input method. When I type
German or Dutch, I just toggle the input method and keep it until I kill
the relevant buffer.)
> I want these listed in the menu also because I might not
> remember all the key combos for all the characters. (I'll likely add
> more in future.)
Well, I can't really help with the menu (I'm not even sure what this
xascii is...) but I do know that this error:
>>> Debugger entered--Lisp error: (wrong-type-argument arrayp xascii)
tells you that Emacs is expecting an array but getting xascii. In this
case the array Emacs is expecting must probably be either a string or a
vector, since a boolean vector or a char table doesn't seem to make
sense in a menu.
Don't know if that helps, though...
--
Joost Kremers joostkremers@fastmail.fm
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: creating a sub-menu
2013-03-05 22:39 creating a sub-menu ken
@ 2013-03-07 14:14 ` Stephen Berman
2013-03-12 7:38 ` ken
0 siblings, 1 reply; 8+ messages in thread
From: Stephen Berman @ 2013-03-07 14:14 UTC (permalink / raw)
To: help-gnu-emacs
On Tue, 05 Mar 2013 17:39:01 -0500 ken <gebser@mousecar.com> wrote:
> Trying to create a sub-menu under "Edit". Got part of the way there, but
> still missing something.
>
> (define-key menu-bar-edit-menu [insert-xascii-chars]
> '(menu-item "Insert non-ASCII characters" xascii
>
> (xascii "\C-xaa" "ä" "ä` (ä)" ("ä"))
> (xascii "\C-xaA" "Ä" "Ä` (Ä)" ("Ä"))
> (xascii "\C-xao" "ö" "ö` (ö)" ("ö"))
> (xascii "\C-xaO" "Ö" "Ö` (Ö)" ("Ö"))
> (xascii "\C-xau" "ü" "ü` (ü)" ("ü"))
> (xascii "\C-xaU" "Ü" "Ü` (Ü)" ("Ü"))
> (xascii "\C-xas" "ß" "ß` (ß)" ("ß"))
> (xascii "\C-xa<" "«" "«` («)" ("«"))
> (xascii "\C-xa>" "»" "»` (»)" ("»"))))
>
> Above yields error:
> Debugger entered--Lisp error: (wrong-type-argument arrayp xascii)
When I evaluate it in a recent Emacs build from the bzr trunk, I get no
error. But instead of adding a submenu to the Edit menu, it just adds
the entry "Insert non-ASCII characters" (when I click on that entry, it
tries to execute the xascii command, and since I have that, I get "Lisp
error: (void-function xascii)"). If you want a submenu, then instead of
a command name, the third item in your menu-item list should be a
(variable whose value is a) keymap defining the menu items of the
submenu, e.g., something like the following:
(defun kg-insert-ä ()
(interactive)
(insert "ä"))
(defun kg-insert-Ä ()
(interactive)
(insert "Ä"))
(defvar xascii-menu
(let ((menu (make-sparse-keymap "Insert non-ASCII characters")))
(define-key menu [kg-insert-Ä]
'(menu-item "Insert `Ä'" kg-insert-Ä :keys "C-x a A"))
(define-key menu [kg-insert-ä]
'(menu-item "Insert `ä'" kg-insert-ä :keys "C-x a a"))
menu))
(define-key menu-bar-edit-menu [xascii-menu]
`(menu-item "Insert non-ASCII characters" ,xascii-menu))
Steve Berman
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: creating a sub-menu
2013-03-07 14:14 ` Stephen Berman
@ 2013-03-12 7:38 ` ken
2013-03-12 22:22 ` Stephen Berman
0 siblings, 1 reply; 8+ messages in thread
From: ken @ 2013-03-12 7:38 UTC (permalink / raw)
To: Stephen Berman, GNU Emacs List
On 03/07/2013 09:14 AM Stephen Berman wrote:
> On Tue, 05 Mar 2013 17:39:01 -0500 ken <gebser@mousecar.com> wrote:
>
>> Trying to create a sub-menu under "Edit". Got part of the way there, but
>> still missing something.
>>
>> (define-key menu-bar-edit-menu [insert-xascii-chars]
>> '(menu-item "Insert non-ASCII characters" xascii
>>
>> (xascii "\C-xaa" "ä" "ä` (ä)" ("ä"))
>> (xascii "\C-xaA" "Ä" "Ä` (Ä)" ("Ä"))
>> (xascii "\C-xao" "ö" "ö` (ö)" ("ö"))
>> (xascii "\C-xaO" "Ö" "Ö` (Ö)" ("Ö"))
>> (xascii "\C-xau" "ü" "ü` (ü)" ("ü"))
>> (xascii "\C-xaU" "Ü" "Ü` (Ü)" ("Ü"))
>> (xascii "\C-xas" "ß" "ß` (ß)" ("ß"))
>> (xascii "\C-xa<" "«" "«` («)" ("«"))
>> (xascii "\C-xa>" "»" "»` (»)" ("»"))))
>>
>> Above yields error:
>> Debugger entered--Lisp error: (wrong-type-argument arrayp xascii)
>
> When I evaluate it in a recent Emacs build from the bzr trunk, I get no
> error. But instead of adding a submenu to the Edit menu, it just adds
> the entry "Insert non-ASCII characters" (when I click on that entry, it
> tries to execute the xascii command, and since I have that, I get "Lisp
> error: (void-function xascii)"). If you want a submenu, then instead of
> a command name, the third item in your menu-item list should be a
> (variable whose value is a) keymap defining the menu items of the
> submenu, e.g., something like the following:
>
> (defun kg-insert-ä ()
> (interactive)
> (insert "ä"))
>
> (defun kg-insert-Ä ()
> (interactive)
> (insert "Ä"))
>
> (defvar xascii-menu
> (let ((menu (make-sparse-keymap "Insert non-ASCII characters")))
> (define-key menu [kg-insert-Ä]
> '(menu-item "Insert `Ä'" kg-insert-Ä :keys "C-x a A"))
> (define-key menu [kg-insert-ä]
> '(menu-item "Insert `ä'" kg-insert-ä :keys "C-x a a"))
> menu))
>
> (define-key menu-bar-edit-menu [xascii-menu]
> `(menu-item "Insert non-ASCII characters" ,xascii-menu))
>
> Steve Berman
Thanks, Steve,
I tried this code and it is definitely progress over mine in that it
displays menu items under the "Insert non-ASCII characters" heading.
However, those non-ASCII characters (e.g., `Ä' and `ä') don't display in
the menu under that heading properly; probably owing to the menu
subsystem of the emacs frame not handling utf-8... or 8-bit characters
of any kind. Secondly, the key combos (e.g., C-xaA and C-xaa) remain
undefined.
But you've advanced the code over what I had and I appreciate that very
much. The bit of explanation you provide is also helpful. Together
with the bits in the Elisp Manual and other sources on the web, the
total picture on adding a sub-menu into an existing menu heading is
starting to come together, though still I'm far from being able to
articulate it the way I want and would need in order to be helpful to
anyone else. So I'll work on it more in whatever spare moments I have.
I'm sure I'll get it eventually.
Thanks again,
ken
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: creating a sub-menu
2013-03-12 7:38 ` ken
@ 2013-03-12 22:22 ` Stephen Berman
2013-03-12 23:09 ` ken
0 siblings, 1 reply; 8+ messages in thread
From: Stephen Berman @ 2013-03-12 22:22 UTC (permalink / raw)
To: ken; +Cc: GNU Emacs List
On Tue, 12 Mar 2013 03:38:09 -0400 ken <gebser@mousecar.com> wrote:
> On 03/07/2013 09:14 AM Stephen Berman wrote:
>
>> [...] If you want a submenu, then instead of
>> a command name, the third item in your menu-item list should be a
>> (variable whose value is a) keymap defining the menu items of the
>> submenu, e.g., something like the following:
>>
>> (defun kg-insert-ä ()
>> (interactive)
>> (insert "ä"))
>>
>> (defun kg-insert-Ä ()
>> (interactive)
>> (insert "Ä"))
>>
>> (defvar xascii-menu
>> (let ((menu (make-sparse-keymap "Insert non-ASCII characters")))
>> (define-key menu [kg-insert-Ä]
>> '(menu-item "Insert `Ä'" kg-insert-Ä :keys "C-x a A"))
>> (define-key menu [kg-insert-ä]
>> '(menu-item "Insert `ä'" kg-insert-ä :keys "C-x a a"))
>> menu))
>>
>> (define-key menu-bar-edit-menu [xascii-menu]
>> `(menu-item "Insert non-ASCII characters" ,xascii-menu))
>>
>> Steve Berman
>
> Thanks, Steve,
>
> I tried this code and it is definitely progress over mine in that it displays
> menu items under the "Insert non-ASCII characters" heading. However, those
> non-ASCII characters (e.g., `Ä' and `ä') don't display in the menu under that
> heading properly; probably owing to the menu subsystem of the emacs frame not
> handling utf-8... or 8-bit characters of any kind.
They display fine in the menu in my Emacs. If you're using a
Unicode-capable Emacs (23 or later), they should display for you too,
unless some setting in your system, or maybe some X setting, is
preventing it.
> Secondly, the key combos
> (e.g., C-xaA and C-xaa) remain undefined.
The use of :keys in a menu item is only for displaying in the menu the
string corresponding to a key binding that you have defined elsewhere,
either using global-set-key, local-set-key, or, if you only want them to
be used in a specific key map, using define-key.
> But you've advanced the code over what I had and I appreciate that very much.
> The bit of explanation you provide is also helpful. Together with the bits in
> the Elisp Manual and other sources on the web, the total picture on adding a
> sub-menu into an existing menu heading is starting to come together, though
> still I'm far from being able to articulate it the way I want and would need
> in order to be helpful to anyone else. So I'll work on it more in whatever
> spare moments I have. I'm sure I'll get it eventually.
Good luck!
Steve Berman
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: creating a sub-menu
2013-03-12 22:22 ` Stephen Berman
@ 2013-03-12 23:09 ` ken
0 siblings, 0 replies; 8+ messages in thread
From: ken @ 2013-03-12 23:09 UTC (permalink / raw)
To: GNU Emacs List
n 03/12/2013 06:22 PM Stephen Berman wrote:
> On Tue, 12 Mar 2013 03:38:09 -0400 ken <gebser@mousecar.com> wrote:
>
>> On 03/07/2013 09:14 AM Stephen Berman wrote:
>>
>>> [...] If you want a submenu, then instead of
>>> a command name, the third item in your menu-item list should be a
>>> (variable whose value is a) keymap defining the menu items of the
>>> submenu, e.g., something like the following:
>>>
>>> (defun kg-insert-ä ()
>>> (interactive)
>>> (insert "ä"))
>>>
>>> (defun kg-insert-Ä ()
>>> (interactive)
>>> (insert "Ä"))
>>>
>>> (defvar xascii-menu
>>> (let ((menu (make-sparse-keymap "Insert non-ASCII characters")))
>>> (define-key menu [kg-insert-Ä]
>>> '(menu-item "Insert `Ä'" kg-insert-Ä :keys "C-x a A"))
>>> (define-key menu [kg-insert-ä]
>>> '(menu-item "Insert `ä'" kg-insert-ä :keys "C-x a a"))
>>> menu))
>>>
>>> (define-key menu-bar-edit-menu [xascii-menu]
>>> `(menu-item "Insert non-ASCII characters" ,xascii-menu))
>>>
>>> Steve Berman
>>
>> Thanks, Steve,
>>
>> I tried this code and it is definitely progress over mine in that it displays
>> menu items under the "Insert non-ASCII characters" heading. However, those
>> non-ASCII characters (e.g., `Ä' and `ä') don't display in the menu under that
>> heading properly; probably owing to the menu subsystem of the emacs frame not
>> handling utf-8... or 8-bit characters of any kind.
>
> They display fine in the menu in my Emacs. If you're using a
> Unicode-capable Emacs (23 or later), they should display for you too,
> unless some setting in your system, or maybe some X setting, is
> preventing it.
Good to know. I'll have to remember that when I eventually get around
to upgrading. Until then I can use the '\xxx' (decimal) representations
of them.
>
>> Secondly, the key combos
>> (e.g., C-xaA and C-xaa) remain undefined.
>
> The use of :keys in a menu item is only for displaying in the menu the
> string corresponding to a key binding that you have defined elsewhere,
> either using global-set-key, local-set-key, or, if you only want them to
> be used in a specific key map, using define-key.
Alright! Didn't know that was needed, but cool, done already a lot...
that's cake.
>
>> But you've advanced the code over what I had and I appreciate that very much.
>> The bit of explanation you provide is also helpful. Together with the bits in
>> the Elisp Manual and other sources on the web, the total picture on adding a
>> sub-menu into an existing menu heading is starting to come together, though
>> still I'm far from being able to articulate it the way I want and would need
>> in order to be helpful to anyone else. So I'll work on it more in whatever
>> spare moments I have. I'm sure I'll get it eventually.
>
> Good luck!
>
> Steve Berman
Thanks again, Steve. Luck be with you too.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2013-03-12 23:09 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-05 22:39 creating a sub-menu ken
2013-03-07 14:14 ` Stephen Berman
2013-03-12 7:38 ` ken
2013-03-12 22:22 ` Stephen Berman
2013-03-12 23:09 ` ken
[not found] <mailman.21496.1362523165.855.help-gnu-emacs@gnu.org>
2013-03-06 1:42 ` Joost Kremers
2013-03-06 11:44 ` ken
[not found] ` <mailman.21539.1362570279.855.help-gnu-emacs@gnu.org>
2013-03-06 20:55 ` Joost Kremers
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).