Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!usc!cs.utexas.edu!uunet!yale!Duchier-Denys From: Duchier-Denys@cs.yale.edu (Denys Duchier) Newsgroups: comp.emacs Subject: Re: Lisp Programming: Substring Searches, etc. Keywords: lisp substring searches case statements Message-ID: <65891@yale-celray.yale.UUCP> Date: 9 Jul 89 18:07:16 GMT References: <397@lxn.eds.com> Sender: root@yale.UUCP Reply-To: Duchier-Denys@cs.yale.edu (Denys Duchier) Organization: Computer Science, Yale University, New Haven, CT 06520-2158 Lines: 28 In-reply-to: chris@lxn.eds.com (Christopher D. Orr) (defun extract-file-extension (filename) (and (string-match ".+\\.\\(.*\\)$" filename) (substring filename (match-beginning 1) (match-end 1)))) after setting file-ext to the proper file extension you could do something like this: (cond ((string-equal file-ext "c") ...) ((string-equal file-ext "h") ...) ... (t ...)) Perhaps it would be best to define a function like the following (defun act-according-to-extension () (let ((file-ext (extract-file-extension buffer-file-name))) (cond ((string-equal file-ext "c") ...) ((string-equal file-ext "h") ...) ... (t ...)))) and then do (setq find-file-hooks (cons 'act-according-to-extension find-file-hooks)) You should look up the documentation for find-file-hooks and auto-mode-alist --Denys