* keyboard macro
@ 2013-10-21 16:35 Christof Spitz
2013-10-21 17:26 ` Stefan Monnier
` (3 more replies)
0 siblings, 4 replies; 13+ messages in thread
From: Christof Spitz @ 2013-10-21 16:35 UTC (permalink / raw)
To: help-gnu-emacs
Hello,
I have to write special characters for transliteration of a non-european
language (devanagari) in Emacs. These include characters like ā,ī,ū,ś,ṣ etc.
Basically this has become easy since Emacs supports Unicode. The question is how
to enter those special characters easily. In Windows, I use a scripting program
called "AutoHotKey". I defined macros so that, for example, when I write "..a"
it will insert "ā" etc. In Emacs, I was not able to define such macros. I have
to use the "function keys" such as f5, or Ctrl or Alt (Meta), so that I have to
enter f5-a to produce ā, for example. That makes the typewriting slow. If I
define a macro instead, it needs to finish the string "..a" with a space to
"trigger" the insert, but this is not what I want.
So my question: Is there a way to define a macro/keyboard function that will
insert a certain character at the point when I write "..x" (not followed by a
space)?
Or should I better look for a Linux scripting program that works similar to
AutoHotKey in Windows?
Thanks for any hints,
Christof
--
Christof Spitz
Opitzstr. 6a
22301 Hamburg
phone +49 40 38636135
mobile +49 172 9008988
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: keyboard macro
2013-10-21 16:35 keyboard macro Christof Spitz
@ 2013-10-21 17:26 ` Stefan Monnier
[not found] ` <mailman.4410.1382376390.10748.help-gnu-emacs@gnu.org>
` (2 subsequent siblings)
3 siblings, 0 replies; 13+ messages in thread
From: Stefan Monnier @ 2013-10-21 17:26 UTC (permalink / raw)
To: help-gnu-emacs
> So my question: Is there a way to define a macro/keyboard function that will
> insert a certain character at the point when I write "..x" (not followed by a
> space)?
Not exactly, tho you could cook one up. E.g. (guaranteed 100% untested):
(defvar my-magic-rewrites
'(
("..a" . "ā")
))
(defvar my-last-chars nil)
(defun my-p-s-i-h ()
(unless (eq last-command this-command)
(setq my-last-chars ""))
(setq my-last-chars (concat my-last-chars (string last-command-event)))
(let ((rewrite (assoc my-last-chars my-magic-rewrites)))
(when rewrite
(delete-char (- (length (car rewrite))))
(insert (cdr rewrite)))))
(add-hook 'post-self-insert-hook #'my-p-s-i-h)
But I recommend you try instead M-x describe-input-method RET devana TAB
Stefan
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: keyboard macro
[not found] ` <mailman.4410.1382376390.10748.help-gnu-emacs@gnu.org>
@ 2013-10-21 17:39 ` Rustom Mody
0 siblings, 0 replies; 13+ messages in thread
From: Rustom Mody @ 2013-10-21 17:39 UTC (permalink / raw)
To: help-gnu-emacs
On Monday, October 21, 2013 10:56:02 PM UTC+5:30, Stefan Monnier wrote:
>
> But I recommend you try instead M-x describe-input-method RET devana TAB
I only see itrans inscript kyoto and aiba -- all of which enter devanagari with some variations in the latin (ASCII-keys) used to enter. ie none of them have outputs as latin-with-diacritics. latin-1-prefix (or postfix) seems more appropriate however it does not seem to have macrons
As for my suggestion, I cannot say I really understand it especially all the parameters. David de la Harpe Golden showed it to me in some other context and I just tailored it to make it work for you.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: keyboard macro
2013-10-21 16:35 keyboard macro Christof Spitz
2013-10-21 17:26 ` Stefan Monnier
[not found] ` <mailman.4410.1382376390.10748.help-gnu-emacs@gnu.org>
@ 2013-10-21 18:17 ` Yuri Khan
2013-10-21 18:25 ` Yuri Khan
[not found] ` <mailman.4414.1382379457.10748.help-gnu-emacs@gnu.org>
3 siblings, 1 reply; 13+ messages in thread
From: Yuri Khan @ 2013-10-21 18:17 UTC (permalink / raw)
To: Christof Spitz; +Cc: help-gnu-emacs@gnu.org
On Mon, Oct 21, 2013 at 11:35 PM, Christof Spitz <cs@lotsawa.de> wrote:
> I have to write special characters for transliteration of a non-european
> language (devanagari) in Emacs. These include characters like ā,ī,ū,ś,ṣ etc.
> Basically this has become easy since Emacs supports Unicode. The question is how
> to enter those special characters easily. In Windows, I use a scripting program
> called "AutoHotKey". I defined macros so that, for example, when I write "..a"
> it will insert "ā" etc.
It never ceases to amaze me how far people are willing to go just to
avoid using an appropriate OS-level keyboard layout. In your case,
probably, the command “setxkbmap -layout "us,in" -variant ",deva"
-options "grp:caps_toggle,grp_led:caps"” will help a lot.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: keyboard macro
2013-10-21 18:17 ` Yuri Khan
@ 2013-10-21 18:25 ` Yuri Khan
0 siblings, 0 replies; 13+ messages in thread
From: Yuri Khan @ 2013-10-21 18:25 UTC (permalink / raw)
To: Christof Spitz; +Cc: help-gnu-emacs@gnu.org
On Tue, Oct 22, 2013 at 1:17 AM, Yuri Khan <yuri.v.khan@gmail.com> wrote:
> On Mon, Oct 21, 2013 at 11:35 PM, Christof Spitz <cs@lotsawa.de> wrote:
>
>> I have to write special characters for transliteration of a non-european
>> language (devanagari) in Emacs. These include characters like ā,ī,ū,ś,ṣ etc.
>
> It never ceases to amaze me how far people are willing to go just to
> avoid using an appropriate OS-level keyboard layout. In your case,
> probably, the command “setxkbmap -layout "us,in" -variant ",deva"
> -options "grp:caps_toggle,grp_led:caps"” will help a lot.
On second reading, you want a transliteration, not real devanagari. In
that case, you can create your own transliterated layout by cloning
the /usr/share/X11/xkb/symbols/in file and substituting your preferred
code points. (You will also need to add lines to the rules/evdev
file.)
Alternatively, hack the Latin-based layout of your choice to include
the diacritics you need, either as dead keys or as combining
characters.
^ permalink raw reply [flat|nested] 13+ messages in thread
* X keyboard settings (was keyboard macro)
[not found] ` <mailman.4414.1382379457.10748.help-gnu-emacs@gnu.org>
@ 2013-10-22 3:48 ` Rustom Mody
2013-10-22 4:11 ` Yuri Khan
` (6 more replies)
0 siblings, 7 replies; 13+ messages in thread
From: Rustom Mody @ 2013-10-22 3:48 UTC (permalink / raw)
To: help-gnu-emacs
On Monday, October 21, 2013 11:47:30 PM UTC+5:30, Yuri Khan wrote:
> On Mon, Oct 21, 2013 at 11:35 PM, Christof Spitz wrote:
>
> > I have to write special characters for transliteration of a non-european
> > language (devanagari) in Emacs.
> It never ceases to amaze me how far people are willing to go just to
> avoid using an appropriate OS-level keyboard layout. In your case,
> probably, the command “setxkbmap -layout "us,in" -variant ",deva"
> -options "grp:caps_toggle,grp_led:caps"” will help a lot.
Hey its great to hear of this!
Ive been trying to put together something for the new gnu apl that has just been released.
The author gives an xmodmap that works for apl but makes emacs close to unusable -- Alt-x becomes an Apl char. However all my attempts at wrapping my head round xmodmap have failed so far.
Can setxkbmap replace xmodmap?
So far I found xkeycaps which seems to be such a replacement. When I use it and try to save the map it segfaults :-(
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: X keyboard settings (was keyboard macro)
2013-10-22 3:48 ` X keyboard settings (was keyboard macro) Rustom Mody
@ 2013-10-22 4:11 ` Yuri Khan
2013-10-22 5:58 ` Joost Kremers
` (5 subsequent siblings)
6 siblings, 0 replies; 13+ messages in thread
From: Yuri Khan @ 2013-10-22 4:11 UTC (permalink / raw)
To: Rustom Mody; +Cc: help-gnu-emacs@gnu.org
On Tue, Oct 22, 2013 at 10:48 AM, Rustom Mody <rustompmody@gmail.com> wrote:
> On Monday, October 21, 2013 11:47:30 PM UTC+5:30, Yuri Khan wrote:
>> probably, the command “setxkbmap -layout "us,in" -variant ",deva"
>> -options "grp:caps_toggle,grp_led:caps"” will help a lot.
>
> Hey its great to hear of this!
> Ive been trying to put together something for the new gnu apl that has just been released.
> The author gives an xmodmap that works for apl but makes emacs close to unusable -- Alt-x becomes an Apl char. However all my attempts at wrapping my head round xmodmap have failed so far.
> Can setxkbmap replace xmodmap?
As far as I understand, xmodmap and setxkbmap are equivalent in power.
They both are ways to feed your settings to the XKB extension, just
use different input formats.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: X keyboard settings (was keyboard macro)
2013-10-22 3:48 ` X keyboard settings (was keyboard macro) Rustom Mody
2013-10-22 4:11 ` Yuri Khan
@ 2013-10-22 5:58 ` Joost Kremers
2013-10-22 11:59 ` Jürgen Sauermann
` (4 subsequent siblings)
6 siblings, 0 replies; 13+ messages in thread
From: Joost Kremers @ 2013-10-22 5:58 UTC (permalink / raw)
To: help-gnu-emacs
Rustom Mody wrote:
> The author gives an xmodmap that works for apl but makes emacs close
> to unusable -- Alt-x becomes an Apl char. However all my attempts at
> wrapping my head round xmodmap have failed so far.
Most desktop environments and window managers provide some graphical
front end to set up xkb options. Makes the whole thing a point-and-click
fest. :-)
> Can setxkbmap replace xmodmap?
AFAIK the two do basically the same thing, the difference being that
xmodmap reads a script while setxkbmap takes command line arguments.
--
Joost Kremers joostkremers@fastmail.fm
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: X keyboard settings (was keyboard macro)
2013-10-22 3:48 ` X keyboard settings (was keyboard macro) Rustom Mody
2013-10-22 4:11 ` Yuri Khan
2013-10-22 5:58 ` Joost Kremers
@ 2013-10-22 11:59 ` Jürgen Sauermann
2013-10-22 13:02 ` Stefan Monnier
` (3 subsequent siblings)
6 siblings, 0 replies; 13+ messages in thread
From: Jürgen Sauermann @ 2013-10-22 11:59 UTC (permalink / raw)
To: help-gnu-emacs
Rustom Mody <rustompmody <at> gmail.com> writes:
>
> On Monday, October 21, 2013 11:47:30 PM UTC+5:30, Yuri Khan wrote:
> > On Mon, Oct 21, 2013 at 11:35 PM, Christof Spitz wrote:
> >
> > > I have to write special characters for transliteration of a non-european
> > > language (devanagari) in Emacs.
>
> > It never ceases to amaze me how far people are willing to go just to
> > avoid using an appropriate OS-level keyboard layout. In your case,
> > probably, the command “setxkbmap -layout "us,in" -variant ",deva"
> > -options "grp:caps_toggle,grp_led:caps"” will help a lot.
>
> Hey its great to hear of this!
> Ive been trying to put together something for the new gnu apl that has
just been released.
> The author gives an xmodmap that works for apl but makes emacs close to
unusable -- Alt-x becomes an Apl char.
> However all my attempts at wrapping my head round xmodmap have failed so far.
> Can setxkbmap replace xmodmap?
>
> So far I found xkeycaps which seems to be such a replacement. When I use
it and try to save the map it segfaults
>
>
Hi,
I have seen this segfault with setxkbmap happening when the keycodes are
do not fit in one byte (which is the case for all Unicode APL characters).
⍝ Jürgen
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: X keyboard settings (was keyboard macro)
2013-10-22 3:48 ` X keyboard settings (was keyboard macro) Rustom Mody
` (2 preceding siblings ...)
2013-10-22 11:59 ` Jürgen Sauermann
@ 2013-10-22 13:02 ` Stefan Monnier
[not found] ` <mailman.4532.1382529319.10748.help-gnu-emacs@gnu.org>
` (2 subsequent siblings)
6 siblings, 0 replies; 13+ messages in thread
From: Stefan Monnier @ 2013-10-22 13:02 UTC (permalink / raw)
To: help-gnu-emacs
> Hey its great to hear of this! Ive been trying to put together
> something for the new gnu apl that has just been released. The author
> gives an xmodmap that works for apl but makes emacs close to
> unusable -- Alt-x becomes an Apl char. However all my attempts at
> wrapping my head round xmodmap have failed so far. Can setxkbmap
> replace xmodmap?
Note that while I agree with Yuri (it's generally better to use an
OS-wide keyboard setting that gives you the same key-strokes in all
applications), in the case of apl-mode, you probably want to use
a different keyboard setting. So for apl-mode, it makes a lot of sense
to use an Emacs input method rather than an X11 input method.
Stefan
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: X keyboard settings (was keyboard macro)
[not found] ` <mailman.4532.1382529319.10748.help-gnu-emacs@gnu.org>
@ 2013-10-24 1:02 ` Rustom Mody
0 siblings, 0 replies; 13+ messages in thread
From: Rustom Mody @ 2013-10-24 1:02 UTC (permalink / raw)
To: help-gnu-emacs
On Tuesday, October 22, 2013 5:29:45 PM UTC+5:30, Jürgen Sauermann wrote:
> I have seen this segfault with setxkbmap happening when the keycodes are
> do not fit in one byte (which is the case for all Unicode APL characters).
>
> ⍝ Jürgen
Great to see the author of gnu apl out here!
My question is really quite simple and someone familiar with xmodmap (or moral equivalents) should be able to solve it very easily:
1. X seems to have 8 modifiers which are mappable
2. Most keyboards have a large number of keys used typically as modifiers
eg AltGr (right alt) right-win; also 'menu' which can be used as a dead key
[Yeah this is not very portable as the laptop on which I am writing this does not have the usual scroll lock and numlock etc. I dont think portability of keyboard usage is the issue right now.
3. I believe though not sure that emacs has the capability to deal with 'hyper' 'super' etc.
So its only a question of taking one of these unused modifer keysyms and doing some xmodmap or setxkbmap magic to send these.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: X keyboard settings (was keyboard macro)
2013-10-22 3:48 ` X keyboard settings (was keyboard macro) Rustom Mody
` (4 preceding siblings ...)
[not found] ` <mailman.4532.1382529319.10748.help-gnu-emacs@gnu.org>
@ 2013-10-24 12:35 ` Jürgen Sauermann
[not found] ` <mailman.4607.1382618163.10748.help-gnu-emacs@gnu.org>
6 siblings, 0 replies; 13+ messages in thread
From: Jürgen Sauermann @ 2013-10-24 12:35 UTC (permalink / raw)
To: help-gnu-emacs
Rustom Mody <rustompmody <at> gmail.com> writes:
>
> On Monday, October 21, 2013 11:47:30 PM UTC+5:30, Yuri Khan wrote:
> > On Mon, Oct 21, 2013 at 11:35 PM, Christof Spitz wrote:
> >
> > > I have to write special characters for transliteration of a non-european
> > > language (devanagari) in Emacs.
>
> > It never ceases to amaze me how far people are willing to go just to
> > avoid using an appropriate OS-level keyboard layout. In your case,
> > probably, the command “setxkbmap -layout "us,in" -variant ",deva"
> > -options "grp:caps_toggle,grp_led:caps"” will help a lot.
>
> Hey its great to hear of this!
> Ive been trying to put together something for the new gnu apl that has
just been released.
> The author gives an xmodmap that works for apl but makes emacs close to
unusable -- Alt-x becomes an Apl char.
> However all my attempts at wrapping my head round xmodmap have failed so far.
> Can setxkbmap replace xmodmap?
>
> So far I found xkeycaps which seems to be such a replacement. When I use
it and try to save the map it segfaults
>
>
Hi,
given Yuri's equivalence of xmodmap and setxkbdmap, and the segfault on
setxkbdmap, the way to go seems to be xmodmap.
xmodmap is actually fairly simple. Every key on your keyboard sends
a keycode between 1 and 255. You can use the program xev to show the
keycodes sent by the different keys.
For each keycode there is a line in the file given to xmodmap that
starts with "keycode = " followed by the keycode in question.
After the keycode come 0 to 8 values that are sent; which one is
determined by the state of the "modifier Keys", typically Shift,
Ctrl, and Alt. If no value is given for a particular state then nothing
is sent (i believe).
If you interpret the values as an 8x255 matrix then the first column is
the number (Unicode if the encoding is set to unicode) sent for each
key without modifier, the second column is the number sent when SHIFT
is down, third column when alt is down, fourth column when SHIFT and ALT
are down. I believe that columns 5 to 8 are the numbers like for 1 to 4
when the CTRL key is also down (have not tried that, though).
In this context, SHIFT, ALT, and CTRL means those keys that you have
decided (in the xmodmap file) to be SHIFT, ALT, and CTRL.
Now suppose you want to move all APL keys from the the ALT plane to the
CTRL plane. There are basically two different ways:
1. You exchange the ALT and CTRL keys in the xmodmap file,
leaving all other keys intact, or
2. You insert some more columns (by writing NoSymbol entries)
before the APL chars thius moving them from the ALT plane
(column) to the CTRL plane.
If emacs uses xmodmap (I dont know that) then method 1. moves the
ALT keys used by emacs to the CTRL plane (which is probably not what
you want); in theat case you are better off moving only those "APL keys"
that conflict with emacs to either SHIFT+ALT or CTRL or whatever.
If emacs uses the keycodes directly (bypassing the xmodmap settings) then
method 1 is less work to do.
⍝ Jürgen
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: X keyboard settings (was keyboard macro)
[not found] ` <mailman.4607.1382618163.10748.help-gnu-emacs@gnu.org>
@ 2013-10-24 17:36 ` Rustom Mody
0 siblings, 0 replies; 13+ messages in thread
From: Rustom Mody @ 2013-10-24 17:36 UTC (permalink / raw)
To: help-gnu-emacs
I think the the X oriented way (xmodmap xkb setxkbmap etc) is not bearing any fruit. The 8x255 matrix is easy to visualize/handle. Its the modifier keys that are giving me too much hell.
SO for now I'll just use some normal key (say scrolllock or insert)
capture it in emacs (not X) to toggle a flag
use that to 'multiply' a keyboard layout by 2
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2013-10-24 17:36 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-21 16:35 keyboard macro Christof Spitz
2013-10-21 17:26 ` Stefan Monnier
[not found] ` <mailman.4410.1382376390.10748.help-gnu-emacs@gnu.org>
2013-10-21 17:39 ` Rustom Mody
2013-10-21 18:17 ` Yuri Khan
2013-10-21 18:25 ` Yuri Khan
[not found] ` <mailman.4414.1382379457.10748.help-gnu-emacs@gnu.org>
2013-10-22 3:48 ` X keyboard settings (was keyboard macro) Rustom Mody
2013-10-22 4:11 ` Yuri Khan
2013-10-22 5:58 ` Joost Kremers
2013-10-22 11:59 ` Jürgen Sauermann
2013-10-22 13:02 ` Stefan Monnier
[not found] ` <mailman.4532.1382529319.10748.help-gnu-emacs@gnu.org>
2013-10-24 1:02 ` Rustom Mody
2013-10-24 12:35 ` Jürgen Sauermann
[not found] ` <mailman.4607.1382618163.10748.help-gnu-emacs@gnu.org>
2013-10-24 17:36 ` Rustom Mody
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).