From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Gordon Beaton Newsgroups: gmane.emacs.help Subject: Re: Emacs . How can I associate *.cu files as cc mode as a default ? Date: 19 Sep 2007 06:24:39 GMT Organization: - Message-ID: <46f0c0a7$0$3197$8404b019@news.wineasy.se> References: <1190160650.850759.138290@50g2000hsm.googlegroups.com> NNTP-Posting-Host: lo.gmane.org X-Trace: sea.gmane.org 1190184035 26670 80.91.229.12 (19 Sep 2007 06:40:35 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 19 Sep 2007 06:40:35 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Sep 19 08:40:34 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IXtEb-0005D6-Jy for geh-help-gnu-emacs@m.gmane.org; Wed, 19 Sep 2007 08:40:29 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IXtEa-0005y4-2S for geh-help-gnu-emacs@m.gmane.org; Wed, 19 Sep 2007 02:40:28 -0400 Original-Path: shelby.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!newsfeed.freenet.de!feed.xsnews.nl!border-2.ams.xsnews.nl!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!nntp.giganews.com!uio.no!fi.sn.net!newsfeed1.fi.sn.net!news.song.fi!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: slrn/0.9.8.1pl1 (Linux) Original-Lines: 21 Original-NNTP-Posting-Host: cube.smaltan.org Original-X-Trace: 1190183079 news.wineasy.se 3197 195.42.215.17:62995 Original-X-Complaints-To: abuse@tdcsong.se Original-Xref: shelby.stanford.edu gnu.emacs.help:152168 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:47677 Archived-At: On 19 Sep 2007 00:28:09 GMT, Tyler Smith wrote: > This function will do that: > > (defun my-find-file-hook() > (let ((fn (buffer-file-name))) > (when (string-match "\\.cu$" fn) > (cc-mode)))) > > You have to tell Emacs to run this function every time you open a new > file, so you add the hook: > > (add-hook 'find-file-hooks 'my-find-file-hook) No need for the function. Just add the extension to auto-mode-alist: (add-to-list 'auto-mode-alist '("\\.cu$" . c-mode)) /gordon --