Article View: gnu.emacs.help
Article #1843Re: auto loading of mode for different file extensions
From: Kevin Gallagher
Date: Sat, 21 Nov 1992 19:16
Date: Sat, 21 Nov 1992 19:16
38 lines
2226 bytes
2226 bytes
In article <1992Nov21.012111.29570@sarah.albany.edu> jjo619@thor.albany.edu (John O'neill) writes:
>How do you force emacs to autoload a major (or minor) mode for a given
>file extension. My proglem is that I edit fortran files that use .F
>as the extension (then goes through a preprocessor) and I want fortran-mode.
>Thanks in advance,
>John O'Neill
To quote from the GNU Emacs Lisp Reference Manual, Edition 1.03, Section
20.1.3 entitled "How Emacs Chooses a Major Mode Automatically", the variable
auto-mode-alist is described:
This variable contains an association list of file name
patterns...and corresponding major mode functions. Usually,
the file name patters test for suffixes...
Here is an example of how to prepend several pattern pairs to an
existing auto-mode-alist. (You might use this sort of expression in
your '.emacs' file.)
(setq auto-mode-alist
(append
'(("/\\.[^/]*$" . fundamental-mode) ; Filename starts with a dot.
("[^\\./]*$" . fundamental-mode) ; Filename has no dot.
("\\.C$" . c++-mode ))
auto-mode-alist))
So, this example shows that the following should do what you want:
(setq auto-mode-alist
(append
'(("\\.F$" . fortran-mode)) ; Filename ends in ".F"
auto-mode-alist))
--
----------------------------------------------------------------------------
Kevin Gallagher kgallagh@digi.lonestar.org OR ...!uunet!digi!kgallagh
DSC Communications Corporation Addr: MS 152, 1000 Coit Rd, Plano, TX 75075
----------------------------------------------------------------------------
Technical Details
Message-ID:
<1992Nov21.191644.2843@digi.lonestar.org>Path:
arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!sun-barr!news2me.EBay.Sun.COM!cronkite.Central.Sun.COM!texsun!digi!kgallaghReferences:
<1992Nov21.012111.29570@sarah.albany.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!sun-barr!news2me.EBay.Sun.COM!cronkite.Central.Sun.COM!texsun!digi!kgallagh From: kgallagh@digi.lonestar.org (Kevin Gallagher) Newsgroups: gnu.emacs.help Subject: Re: auto loading of mode for different file extensions Message-ID: <1992Nov21.191644.2843@digi.lonestar.org> Date: 21 Nov 92 19:16:44 GMT References: <1992Nov21.012111.29570@sarah.albany.edu> Organization: DSC Communications Corp, Plano, TX Lines: 38