From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dirk-Jan C. Binnema Newsgroups: gmane.emacs.help Subject: Re: Newby trying to do a macro key binding, I think Date: Wed, 18 Nov 2009 08:38:19 +0200 Organization: DJCBSoftware Message-ID: <87skccxrqc.wl%djcb@djcbsoftware.nl> References: <26401079.post@talk.nabble.com> Reply-To: djcb@djcbsoftware.nl NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII X-Trace: ger.gmane.org 1258564264 8343 80.91.229.12 (18 Nov 2009 17:11:04 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 18 Nov 2009 17:11:04 +0000 (UTC) Cc: Help-gnu-emacs@gnu.org To: Paul Heinrich Dietrich Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Nov 18 18:10:57 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NAo3T-0005cy-Ff for geh-help-gnu-emacs@m.gmane.org; Wed, 18 Nov 2009 18:10:56 +0100 Original-Received: from localhost ([127.0.0.1]:37733 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NAo3S-0005ya-QS for geh-help-gnu-emacs@m.gmane.org; Wed, 18 Nov 2009 12:10:54 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NAnv1-0005R5-Od for help-gnu-emacs@gnu.org; Wed, 18 Nov 2009 12:02:11 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NAnuu-0005ND-60 for Help-gnu-emacs@gnu.org; Wed, 18 Nov 2009 12:02:09 -0500 Original-Received: from [199.232.76.173] (port=32791 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NAnut-0005N8-VR for Help-gnu-emacs@gnu.org; Wed, 18 Nov 2009 12:02:04 -0500 Original-Received: from gw03.mail.saunalahti.fi ([195.197.172.111]:39416) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NAnut-0002Lx-7g for Help-gnu-emacs@gnu.org; Wed, 18 Nov 2009 12:02:03 -0500 Original-Received: from djcbsoftware.nl (a88-112-254-208.elisa-laajakaista.fi [88.112.254.208]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by gw03.mail.saunalahti.fi (Postfix) with ESMTP id 65E212169CF; Wed, 18 Nov 2009 19:01:55 +0200 (EET) Original-Received: from cthulhu.mindcrime.djcbsoftware.nl (localhost [127.0.0.1]) by djcbsoftware.nl (Postfix) with ESMTP id 6193839C09E; Wed, 18 Nov 2009 08:38:19 +0200 (EET) In-Reply-To: <26401079.post@talk.nabble.com> Mail-Reply-To: djcb@djcbsoftware.nl User-Agent: Wanderlust/2.15.6 (Almost Unreal) Emacs/23.1 Mule/6.0 (HANACHIRUSATO) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:69883 Archived-At: Hi, >>>>> Paul Heinrich Dietrich 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 "") (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