home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / gnu / emacs / help / 3435 < prev    next >
Encoding:
Text File  |  1992-07-21  |  1.2 KB  |  42 lines

  1. Newsgroups: gnu.emacs.help
  2. Path: sparky!uunet!sun-barr!cs.utexas.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!usit.uio.NO!h.b.furuseth
  3. From: h.b.furuseth@usit.uio.NO
  4. Subject: Re: More intelligent default mode selection?
  5. Message-ID: <9207212044.AAdurin01072@durin.uio.no>
  6. Sender: sjohnson@cis.ohio-state.edu (steven joseph johnson)
  7. Organization: Gatewayed from the GNU Project mailing list help-gnu-emacs@prep.ai.mit.edu
  8. References: h.b.furuseth@usit.uio.NO
  9. Date: Wed, 22 Jul 1992 00:44:02 GMT
  10. Lines: 30
  11.  
  12. The regexps matching filenames in auto-mode-alist need not be just
  13. suffixes.  To get all files under "pl" directories in perl-mode:
  14.  
  15.     (nconc auto-mode-alist '(("/pl/" . perl-mode)))
  16.  
  17. Put the directories at the *end* of auto-mode-alist, otherwise they
  18. would override normal filename suffixes.
  19.  
  20.  
  21. Or you might like something like this:
  22.  
  23. (defun default-mode ()
  24.   (maybe-perl-mode 'text-mode))
  25.  
  26. (defun maybe-perl-mode (&optional default)
  27.   (cond ((save-excursion
  28.        (save-restriction
  29.          (widen)
  30.          (goto-char (point-min))
  31.          (looking-at "#! */[!-~]*/perl")))    ; Perl script
  32.      (perl-mode))
  33.     (default (funcall default))))
  34.  
  35. (setq default-major-mode 'default-mode
  36.       find-file-hooks (append find-file-hooks '(maybe-perl-mode)))
  37.  
  38.  
  39. Regards,
  40.  
  41. Hallvard
  42.