home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / emacs / 3510 < prev    next >
Encoding:
Text File  |  1992-11-10  |  3.0 KB  |  85 lines

  1. Newsgroups: comp.emacs
  2. Path: sparky!uunet!boulder!colorado.edu!ejh
  3. From: ejh@khonshu.colorado.edu (Edward J. Hartnett)
  4. Subject: Re: setting mode hook to call two minor modes, how?
  5. In-Reply-To: ejh@khonshu.colorado.edu's message of 10 Nov 92 11:47:32
  6. Message-ID: <EJH.92Nov10132809@khonshu.colorado.edu>
  7. Sender: news@colorado.edu (The Daily Planet)
  8. Nntp-Posting-Host: khonshu.colorado.edu
  9. Organization: CIRES, University of Colorado
  10. References: <EJH.92Nov10114732@khonshu.colorado.edu>
  11. Date: 10 Nov 92 13:28:09
  12. Lines: 71
  13.  
  14. In article <EJH.92Nov10114732@khonshu.colorado.edu> ejh@khonshu.colorado.edu (Edward J. Hartnett) writes:
  15.  
  16.    I'm using GNU EMACS 18.57 on a Sun running SunOS4.1.1
  17.  
  18.    I'm trying to do a little lisp work in emacs, but my lisp is quite
  19.    rusty. One thing that I want to do is call two minor modes from the
  20.    fortran mode hook. Here's what I have in my .emacs now:
  21.  
  22.    (setq fortran-mode-hook '(lambda () (abbrev-mode 1)))
  23.  
  24.    I know there's a way to add the auto-fill mode, but how? (I'm trying
  25.    to get the auto-fill mode to automatically continue a line that runs
  26.    beyond column 72).
  27.  
  28.    Any help or ideas would be appreciated.
  29.  
  30.    --
  31.    Edward Hartnett            ejh@khonshu.colorado.edu
  32.  
  33.  
  34. Well, I posted this a while ago and then went back and reread my elisp
  35. manual chapter 11, section 2, Lambda Expressions, and it made a lot
  36. more sense than the last time I read it, and I see that the answer to
  37. the above question is now obvious to me. I'll cancel the original
  38. article and, as a pennance, and with the thought that there might be a
  39. few other beginning elisp programs out there who are interested,
  40. here's the answer. But since I just figured this out, there's a good
  41. chance my explanation is wrong.
  42.  
  43. (setq fortran-mode-hook '(lambda () 
  44.     (abbrev-mode 1) (auto-fill-mode 1)))
  45.  
  46. The reason is that a lambda expression consists of the following:
  47. (lambda (ARG-VARIABLES...)
  48.  [DOCUMENTATION STRING]
  49.  [INTERACTIVE-DECLARATION]
  50. BODY-FORMS...)
  51.  
  52. This means that the whole thing is a list, with the special symbol
  53. lambda as the car of the list, the next element is another list, which
  54. will contain the arguments to the function, then there's two optional
  55. list items, the documentation string, which tells what the function
  56. does, and the interactive declaration, which allows the funtion to ask
  57. the user to input the arguments in a friendly way. The rest of the
  58. list are lists which are themselves function calls. So to add another
  59. function to the fortran hook, I add another element to the list, and
  60. the element I add is the list (auto-fill-mode 1) which turns on
  61. auto-fill mode. 
  62.  
  63. What I don't quite understand is why some functions (like the one
  64. called by fortran-mode-hook) are lambda expressions, and others, like
  65. auto-fill-mode don't. I guess either one or the other is not really a
  66. function? Any expert care to clarify?
  67.  
  68. PS - while looking into the fortran.el for more clues I found that in
  69. this newest version abbrev-mode is supposed to be turned on by default
  70. anyway, so I shouldn't need it in my fortran-mode-hook anyway.
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82. --
  83. Edward Hartnett            ejh@khonshu.colorado.edu
  84.  
  85.