all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Newby trying to do a macro key binding, I think
@ 2009-11-18  1:41 Paul Heinrich Dietrich
  2009-11-18  6:38 ` Dirk-Jan C. Binnema
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Paul Heinrich Dietrich @ 2009-11-18  1:41 UTC (permalink / raw)
  To: Help-gnu-emacs


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)

and I forget the routine now, but did something with kbd and names and
managed to get the code into my .emacs file.  The first problem is that the
main part of it (/me@servername#99:/home/directory/path/) wouldn't appear
because as I created the macro, Emacs tried to suggest a path that was
wildly different, so I had to backspace about 15 times and then type it, but
when I get the macro code into the .emacs file, all I see are a lot of
backspace backspace backspace...and no path.

No biggee, so I tried putting quotes around it, ?\ in front of it, etc.

What did I do wrong?  Go easy, I'm in the earliest learning stages of Emacs.

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 "\C-c a") 'pathfinder)

or

;(global-set-key [f5] 'pathfinder)

depending on whether I want to call it with f5 or C-c a.  Any help is
appreciated.  Thanks.
-- 
View this message in context: http://old.nabble.com/Newby-trying-to-do-a-macro-key-binding%2C-I-think-tp26401079p26401079.html
Sent from the Emacs - Help mailing list archive at Nabble.com.





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

* Re: Newby trying to do a macro key binding, I think
  2009-11-18  1:41 Paul Heinrich Dietrich
@ 2009-11-18  6:38 ` Dirk-Jan C. Binnema
  2009-11-18 18:14 ` Paul Heinrich Dietrich
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Dirk-Jan C. Binnema @ 2009-11-18  6:38 UTC (permalink / raw)
  To: Paul Heinrich Dietrich; +Cc: Help-gnu-emacs

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




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

* Re: Newby trying to do a macro key binding, I think
       [not found] <mailman.10952.1258524409.2239.help-gnu-emacs@gnu.org>
@ 2009-11-18  9:11 ` harven
  0 siblings, 0 replies; 7+ messages in thread
From: harven @ 2009-11-18  9:11 UTC (permalink / raw)
  To: help-gnu-emacs

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/

If you want to put it in your .emacs file, it is probably faster
to write a bit of elisp code.

(global-set-key (kbd "<f5>") (lambda () (interactive)
         (dired "/me@servername#99:/home/directory/path/")))

If you never wrote elisp code, take the first line for granted, it binds
the key f5 to the instructions that come next. C-x d calls the command dired.
When you want to know what command is bound to the shortcut C-x d, just type

                            C-h k C-x d 

You will get the name and syntax of the command together with a few informations
that, hopefully, are sufficient to write the code you need.

>
> 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)
>
> and I forget the routine now, but did something with kbd and names and
> managed to get the code into my .emacs file.  The first problem is that the
> main part of it (/me@servername#99:/home/directory/path/) wouldn't appear
> because as I created the macro, Emacs tried to suggest a path that was
> wildly different, so I had to backspace about 15 times and then type it, but
> when I get the macro code into the .emacs file, all I see are a lot of
> backspace backspace backspace...and no path.
>
> No biggee, so I tried putting quotes around it, ?\ in front of it, etc.
>
> What did I do wrong?  Go easy, I'm in the earliest learning stages of Emacs.

If something goes wrong, you can edit the current macro with
                      M-x edit-kbd-macro RET
You can then change the path (erase the backspace lines, whatever) 
and get it right.

> 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 "\C-c a") 'pathfinder)
>
> or
>
> ;(global-set-key [f5] 'pathfinder)
>
> depending on whether I want to call it with f5 or C-c a. 

well, I think it depends on your emacs flavor.
(global-set-key (kbd "C-c a") 'pathfinder)  
(global-set-key (kbd "<f5>")  'pathfinder)  
would have worked for me ( gnu emacs version > 21 ).



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

* Re: Newby trying to do a macro key binding, I think
  2009-11-18  1:41 Paul Heinrich Dietrich
  2009-11-18  6:38 ` Dirk-Jan C. Binnema
@ 2009-11-18 18:14 ` Paul Heinrich Dietrich
       [not found] ` <mailman.10977.1258568059.2239.help-gnu-emacs@gnu.org>
  2009-11-18 19:23 ` Thien-Thi Nguyen
  3 siblings, 0 replies; 7+ messages in thread
From: Paul Heinrich Dietrich @ 2009-11-18 18:14 UTC (permalink / raw)
  To: Help-gnu-emacs


Thanks to you both.  I will get up to speed quickly with Emacs.  Thanks
again.


-- 
View this message in context: http://old.nabble.com/Newby-trying-to-do-a-macro-key-binding%2C-I-think-tp26401079p26412894.html
Sent from the Emacs - Help mailing list archive at Nabble.com.





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

* Re: Newby trying to do a macro key binding, I think
       [not found] ` <mailman.10977.1258568059.2239.help-gnu-emacs@gnu.org>
@ 2009-11-18 18:21   ` David Kastrup
  2009-11-18 23:01     ` Paul Heinrich Dietrich
  0 siblings, 1 reply; 7+ messages in thread
From: David Kastrup @ 2009-11-18 18:21 UTC (permalink / raw)
  To: help-gnu-emacs

Paul Heinrich Dietrich <paul.heinrich.dietrich@gmail.com> writes:

> Thanks to you both.  I will get up to speed quickly with Emacs.

Can I borrow your accelerator when you are done?

-- 
David Kastrup


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

* Re: Newby trying to do a macro key binding, I think
  2009-11-18  1:41 Paul Heinrich Dietrich
                   ` (2 preceding siblings ...)
       [not found] ` <mailman.10977.1258568059.2239.help-gnu-emacs@gnu.org>
@ 2009-11-18 19:23 ` Thien-Thi Nguyen
  3 siblings, 0 replies; 7+ messages in thread
From: Thien-Thi Nguyen @ 2009-11-18 19:23 UTC (permalink / raw)
  To: Help-gnu-emacs

() Paul Heinrich Dietrich <paul.heinrich.dietrich@gmail.com>
() Tue, 17 Nov 2009 17:41:52 -0800 (PST)

   C-x d /me@servername#99:/home/directory/path/

You can try:

  (setenv "rd" "/me@servername#99:/home/directory/path/")
  (global-set-key [f5] [?\C-x ?d ?$ ?r ?d ?\C-m])

Here, "rd" stands for "remote directory".

thi




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

* Re: Newby trying to do a macro key binding, I think
  2009-11-18 18:21   ` David Kastrup
@ 2009-11-18 23:01     ` Paul Heinrich Dietrich
  0 siblings, 0 replies; 7+ messages in thread
From: Paul Heinrich Dietrich @ 2009-11-18 23:01 UTC (permalink / raw)
  To: Help-gnu-emacs


Only if you're used to big blocks. :)


David Kastrup wrote:
> 
> Paul Heinrich Dietrich <paul.heinrich.dietrich@gmail.com> writes:
> 
>> Thanks to you both.  I will get up to speed quickly with Emacs.
> 
> Can I borrow your accelerator when you are done?
> 
> -- 
> David Kastrup
> 
> 

-- 
View this message in context: http://old.nabble.com/Newby-trying-to-do-a-macro-key-binding%2C-I-think-tp26401079p26417399.html
Sent from the Emacs - Help mailing list archive at Nabble.com.





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

end of thread, other threads:[~2009-11-18 23:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.10952.1258524409.2239.help-gnu-emacs@gnu.org>
2009-11-18  9:11 ` Newby trying to do a macro key binding, I think harven
2009-11-18  1:41 Paul Heinrich Dietrich
2009-11-18  6:38 ` Dirk-Jan C. Binnema
2009-11-18 18:14 ` Paul Heinrich Dietrich
     [not found] ` <mailman.10977.1258568059.2239.help-gnu-emacs@gnu.org>
2009-11-18 18:21   ` David Kastrup
2009-11-18 23:01     ` Paul Heinrich Dietrich
2009-11-18 19:23 ` Thien-Thi Nguyen

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.