home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / gnu / emacs / help / 4893 < prev    next >
Encoding:
Text File  |  1992-11-21  |  2.1 KB  |  49 lines

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!sun-barr!news2me.EBay.Sun.COM!cronkite.Central.Sun.COM!texsun!digi!kgallagh
  2. From: kgallagh@digi.lonestar.org (Kevin Gallagher)
  3. Newsgroups: gnu.emacs.help
  4. Subject: Re: auto loading of mode for different file extensions
  5. Message-ID: <1992Nov21.191644.2843@digi.lonestar.org>
  6. Date: 21 Nov 92 19:16:44 GMT
  7. References: <1992Nov21.012111.29570@sarah.albany.edu>
  8. Organization: DSC Communications Corp, Plano, TX
  9. Lines: 38
  10.  
  11. In article <1992Nov21.012111.29570@sarah.albany.edu> jjo619@thor.albany.edu (John O'neill) writes:
  12. >How do you force emacs to autoload a major (or minor) mode for a given
  13. >file extension.  My proglem is that I edit fortran files that use .F
  14. >as the extension (then goes through a preprocessor) and I want fortran-mode.
  15. >Thanks in advance,
  16. >John O'Neill 
  17.  
  18. To quote from the GNU Emacs Lisp Reference Manual, Edition 1.03, Section
  19. 20.1.3 entitled "How Emacs Chooses a Major Mode Automatically", the variable
  20. auto-mode-alist is described:
  21.  
  22.         This variable contains an association list of file name 
  23.         patterns...and corresponding major mode functions.  Usually,
  24.         the file name patters test for suffixes...
  25.  
  26.         Here is an example of how to prepend several pattern pairs to an
  27.         existing auto-mode-alist.  (You might use this sort of expression in
  28.         your '.emacs' file.)
  29.  
  30.           (setq auto-mode-alist
  31.             (append
  32.              '(("/\\.[^/]*$" . fundamental-mode) ; Filename starts with a dot.
  33.                ("[^\\./]*$" . fundamental-mode)  ; Filename has no dot.
  34.                ("\\.C$" . c++-mode ))
  35.              auto-mode-alist))
  36.  
  37. So, this example shows that the following should do what you want:
  38.  
  39.           (setq auto-mode-alist
  40.             (append
  41.              '(("\\.F$" . fortran-mode)) ; Filename ends in ".F"
  42.              auto-mode-alist))
  43.  
  44. -- 
  45. ----------------------------------------------------------------------------
  46. Kevin Gallagher        kgallagh@digi.lonestar.org OR ...!uunet!digi!kgallagh
  47. DSC Communications Corporation   Addr: MS 152, 1000 Coit Rd, Plano, TX 75075
  48. ----------------------------------------------------------------------------
  49.