home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / emacs / 3036 < prev    next >
Encoding:
Internet Message Format  |  1992-09-07  |  2.5 KB

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