home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cs.utexas.edu!rutgers!ub!acsu.buffalo.edu!boyd
- From: boyd@acsu.buffalo.edu (Daniel F Boyd)
- Newsgroups: comp.emacs
- Subject: Re: shell command and macro completion
- Message-ID: <Bu36CA.GzJ@acsu.buffalo.edu>
- Date: 5 Sep 92 03:43:21 GMT
- References: <1992Sep3.171417.21110@TorreyPinesCA.ncr.com>
- Sender: nntp@acsu.buffalo.edu
- Organization: State University of New York at Buffalo/Comp Sci
- Lines: 48
- Nntp-Posting-Host: shaula.cs.buffalo.edu
-
- In article <1992Sep3.171417.21110@TorreyPinesCA.ncr.com> garye@TorreyPinesCA.ncr.com (Gary Engebretson 3793) writes:
- > 2. I would like to map 'M-x occur' to a keyboard macro.
-
- Actually, you probably DON'T want a keyboard macro. I assume what you
- really want is, "I wanna press a short key sequence, say 'ESC o' to
- run the 'occur' command."
-
- If so, what you want is to BIND a KEY to the command 'occur'. Like
- this:
-
- (global-set-key "\eo" 'occur)
-
- This binds "ESC o" to the command 'occur'.
-
- See, in Emacs all the common editing functions are really little
- subroutines written in Emacs Lisp, and there is a mechanism which
-
- 1. takes your keystrokes
- 2. looks them up in a keymap, and finds what COMMAND (Lisp subroutine)
- they are 'bound' to
- 3. runs the Lisp subroutine it found in step 2.
-
- Even the common keys like Control-N only perform their function
- because they are bound to commands. There is actually a command
- called 'next-line', and the only reason the cursor goes down when you
- hit Control-N is because Control-N is BOUND to 'next-line'.
- If someone sneaky was to rebind Control-N to something else,
- then Control-N would no longer move the cursor down.
-
- This is in contrast to PC programs like WordPerfect where the
- commands are hardwired to the keys, so that Down-Arrow ALWAYS moves
- the cursor down. This is a little more messy, and the only way to
- write programs that control WordPerfect is to make WordPerfect pretend
- you're pressing keys in a certain order.
-
- In Emacs, you can make a new command directly (by writing in LISP) and
- bind a key to it -- this is how new commands are created. Now,
- sometimes when you're editing, you want to do something specialized --
- and there is no exact command for it -- and you wish you could just
- say, "Watch what I'm doing, and do it over and over again." THEN, you
- use a KEYBOARD MACRO.
-
-
- --
- Daniel F. Boyd -- boyd@cs.buffalo.edu
- ----------------------------------------------------------------------
- "It's not a System called 'X-Windows', it's a window system named 'X',
- after the owl on 'Mister Rogers' Neighborhood'".
-