From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "rgb" Newsgroups: gmane.emacs.help Subject: Re: Forcing a mode Date: 1 Sep 2006 06:43:14 -0700 Organization: http://groups.google.com Message-ID: <1157118194.758477.225190@i3g2000cwc.googlegroups.com> References: <1157031630.512450.23530@h48g2000cwc.googlegroups.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: sea.gmane.org 1157121648 21332 80.91.229.2 (1 Sep 2006 14:40:48 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 1 Sep 2006 14:40:48 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Sep 01 16:40:47 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GJAC9-0002AX-Ur for geh-help-gnu-emacs@m.gmane.org; Fri, 01 Sep 2006 16:40:34 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GJAC9-0005EO-FG for geh-help-gnu-emacs@m.gmane.org; Fri, 01 Sep 2006 10:40:33 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!i3g2000cwc.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 49 Original-NNTP-Posting-Host: 63.91.129.20 Original-X-Trace: posting.google.com 1157118198 27254 127.0.0.1 (1 Sep 2006 13:43:18 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Fri, 1 Sep 2006 13:43:18 +0000 (UTC) User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322),gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: i3g2000cwc.googlegroups.com; posting-host=63.91.129.20; posting-account=C7LM4w0AAAD23IRuMuUUJVCLQTuHhTK8 Original-Xref: shelby.stanford.edu gnu.emacs.help:141485 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:37106 Archived-At: > (Note that Tcl scripts typically begin something like: > > #!/bin/sh > # .... > # \ > exec tclsh "$0" ${1+"$@"} > > so Emacs cannot deduce the mode from the shebang.) On Tandem platforms there are no filename extensions. Moreover, because over 90% of source files I work on are legacy and most Tandem programmers have never heard of Emacs, I can't go around changing source files to add these cookies everywhere I consult. So I had to write something that does just what you want. I ripped redundant/irrelevent stuff out, below. Hopefully I didn't break anything in the meanwhile. Someone interested in the full version should see my emacswiki page. (defadvice set-auto-mode ; RGB 2003 (after my-determine-language last () activate) "If language is fundamental-mode Emacs didn't detect it. Some 1st line language indicators are used to do recognition." (if (eq major-mode 'fundamental-mode) (let ((mode nil)) (save-excursion ; don't trash bookmarks (goto-char (point-min)) (if (looking-at (concat "\\(\\?TACL \\|==\\| *#set\\|\\?SECTION +\\" "(\\S-+\\s-+\\" "(macro\\|routine\\|alias\\|text\\)\\)\\b\\)")) (setq mode 'tacl-mode) (if (looking-at "\\?SECTION +.+,TANDEM\\b") (setq mode 'ddl-mode) (if (looking-at "\\?ANSI\\b") (setq mode 'cobol-mode) (if (looking-at "#[-*#=\n]") (setq mode 'acimake-mode) (if (or (looking-at "\\?pep") (looking-at "[!*] SCHEMA") (looking-at "!FILE CREATED BY GENFWD")) (setq mode 'tal-mode))))))) (if mode (funcall mode)))))