From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: harven Newsgroups: gmane.emacs.help Subject: Re: Newby trying to do a macro key binding, I think Date: Wed, 18 Nov 2009 10:11:48 +0100 Organization: http://groups.google.com Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1258537483 12425 80.91.229.12 (18 Nov 2009 09:44:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 18 Nov 2009 09:44:43 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Nov 18 10:44:36 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 1NAh5W-0007iB-Of for geh-help-gnu-emacs@m.gmane.org; Wed, 18 Nov 2009 10:44:35 +0100 Original-Received: from localhost ([127.0.0.1]:39098 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NAh5W-0002yN-Ad for geh-help-gnu-emacs@m.gmane.org; Wed, 18 Nov 2009 04:44:34 -0500 Original-Path: news.stanford.edu!usenet.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!tiscali!newsfeed1.ip.tiscali.net!proxad.net!feeder1-2.proxad.net!cleanfeed3-a.proxad.net!nnrp10-2.free.fr!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (darwin) Cancel-Lock: sha1:eNAaQdizqisYlnSFl81basmDuHo= Original-Lines: 62 Original-NNTP-Posting-Date: 18 Nov 2009 10:11:48 MET Original-NNTP-Posting-Host: 78.233.232.132 Original-X-Trace: 1258535508 news-2.free.fr 22639 78.233.232.132:54625 Original-X-Complaints-To: abuse@proxad.net Original-Xref: news.stanford.edu gnu.emacs.help:174796 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:69870 Archived-At: 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/ 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 "") (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 "") 'pathfinder) would have worked for me ( gnu emacs version > 21 ).