[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Newby trying to do a macro key binding, I think
From: |
Dirk-Jan C . Binnema |
Subject: |
Re: Newby trying to do a macro key binding, I think |
Date: |
Wed, 18 Nov 2009 08:38:19 +0200 |
User-agent: |
Wanderlust/2.15.6 (Almost Unreal) Emacs/23.1 Mule/6.0 (HANACHIRUSATO) |
Hi,
>>>>> Paul Heinrich Dietrich <paul.heinrich.dietrich@gmail.com> writes:
> How do you write the code for a macro and key binding (I think that's
> how to do it) in your .emacs file so that you can hit a key, say f5, and
> the following command is automatically entered:
> C-x d /me@servername#99:/home/directory/path/
> I've tried a billion variations on a theme, but can't get it to work.
> For example, I tried
> C-x (C-x d /me@servername#99:/home/directory/path/C-x)
Well, if I understand correctly, this should do -- the thing is that you
should not bind the key to something, but the underlying function. You can
find the 'underlying' function by pressing C-h k and then the existing key. In
this case, that would be dired, (or ido-dired, if you use ido).
In the docs (C-h f dir), you'll see that the the function is like:
(dired dirname &optional switches)
So your key binding would then be:
(global-set-key (kbd "<f5>")
(lambda()
(interactive)
(dired "/me@servername#99:/home/directory/path/")))
See the link below for some more details about the magical incantation.
> Next, I'm guessing I want to use a key binding. Let's say I called
> the macro pathfinder. I think I would establish the key binding
> like this:
[...]
> ;(global-set-key [f5] 'pathfinder)
> depending on whether I want to call it with f5 or C-c a. Any help is
> appreciated. Thanks.
One can specify keys in different ways. Using the 'kbd' macro may be the
easiest, because it understands the same format that C-h k uses. So, it would
be something like (maybe it needs the lambda/interactive as above).
(global-set-key (kbd "C-c a") 'pathfinder)
This may be helpful:
http://emacs-fu.blogspot.com/2008/12/binding-keys.html
Best wishes,
Dirk.
--
Dirk-Jan C. Binnema Helsinki, Finland
e:djcb@djcbsoftware.nl w:www.djcbsoftware.nl
pgp: D09C E664 897D 7D39 5047 A178 E96A C7A1 017D DA3C