home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: gnu.emacs.help
- Path: sparky!uunet!sun-barr!cs.utexas.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!usit.uio.NO!h.b.furuseth
- From: h.b.furuseth@usit.uio.NO
- Subject: Re: More intelligent default mode selection?
- Message-ID: <9207212044.AAdurin01072@durin.uio.no>
- Sender: sjohnson@cis.ohio-state.edu (steven joseph johnson)
- Organization: Gatewayed from the GNU Project mailing list help-gnu-emacs@prep.ai.mit.edu
- References: h.b.furuseth@usit.uio.NO
- Date: Wed, 22 Jul 1992 00:44:02 GMT
- Lines: 30
-
- The regexps matching filenames in auto-mode-alist need not be just
- suffixes. To get all files under "pl" directories in perl-mode:
-
- (nconc auto-mode-alist '(("/pl/" . perl-mode)))
-
- Put the directories at the *end* of auto-mode-alist, otherwise they
- would override normal filename suffixes.
-
-
- Or you might like something like this:
-
- (defun default-mode ()
- (maybe-perl-mode 'text-mode))
-
- (defun maybe-perl-mode (&optional default)
- (cond ((save-excursion
- (save-restriction
- (widen)
- (goto-char (point-min))
- (looking-at "#! */[!-~]*/perl"))) ; Perl script
- (perl-mode))
- (default (funcall default))))
-
- (setq default-major-mode 'default-mode
- find-file-hooks (append find-file-hooks '(maybe-perl-mode)))
-
-
- Regards,
-
- Hallvard
-