From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mike H Newsgroups: gmane.emacs.help Subject: Re: Emacs . How can I associate *.cu files as cc mode as a default ? Date: Wed, 19 Sep 2007 01:09:59 -0000 Organization: http://groups.google.com Message-ID: <1190164199.912592.37280@r29g2000hsg.googlegroups.com> References: <1190160650.850759.138290@50g2000hsm.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Trace: sea.gmane.org 1190166158 20923 80.91.229.12 (19 Sep 2007 01:42:38 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 19 Sep 2007 01:42:38 +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 03:42:37 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 1IXoaH-0005y0-Jb for geh-help-gnu-emacs@m.gmane.org; Wed, 19 Sep 2007 03:42:33 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IXoaF-0004C2-PD for geh-help-gnu-emacs@m.gmane.org; Tue, 18 Sep 2007 21:42:31 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!r29g2000hsg.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 34 Original-NNTP-Posting-Host: 143.215.206.122 Original-X-Trace: posting.google.com 1190164200 7638 127.0.0.1 (19 Sep 2007 01:10:00 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Wed, 19 Sep 2007 01:10:00 +0000 (UTC) In-Reply-To: User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.5) Gecko/20041215 Firefox/1.0 Red Hat/1.0-12.EL4,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: r29g2000hsg.googlegroups.com; posting-host=143.215.206.122; posting-account=ps2QrAMAAAA6_jCuRt2JEIpn5Otqf_w0 Original-Xref: shelby.stanford.edu gnu.emacs.help:152161 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:47670 Archived-At: On Sep 18, 8:28 pm, Tyler Smith wrote: > On 2007-09-19, Mike H wrote: > > > Emacs . How can I associate *.cu files as cc mode as a default ? > > cc mode is automatically triggered when I open *.c, *.cpp files. > > However, I would like to add the new file type :) > > You can do this with find-file-hooks. This is code that runs anytime > you find (open) a file. In this case, you want to check and see if the > file you've found ends with .cu, and if so, to use cc-mode. 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) > > Put both forms in your .emacs, and the next time you open emacs you'll > be all ready to go. (you can also load them into a running emacs using > C-x C-e to execute the previous command in a lisp-mode buffer, such as > scratch or .emacs). > > HTH, > > Tyler Thank you ! I really appreciate it !