From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tyler Smith Newsgroups: gmane.emacs.help Subject: Re: Emacs . How can I associate *.cu files as cc mode as a default ? Date: 19 Sep 2007 15:47:19 GMT Organization: Sedgeboy Inc. Message-ID: References: <1190160650.850759.138290@50g2000hsm.googlegroups.com> <1190164199.912592.37280@r29g2000hsg.googlegroups.com> <1190165135.154174.99310@g4g2000hsf.googlegroups.com> <1190167469.762189.227620@n39g2000hsh.googlegroups.com> NNTP-Posting-Host: lo.gmane.org X-Trace: sea.gmane.org 1190220128 24257 80.91.229.12 (19 Sep 2007 16:42:08 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 19 Sep 2007 16:42:08 +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 18:41:58 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 1IY2bm-0003bP-U6 for geh-help-gnu-emacs@m.gmane.org; Wed, 19 Sep 2007 18:41:03 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IY2bl-0000Ja-68 for geh-help-gnu-emacs@m.gmane.org; Wed, 19 Sep 2007 12:41:01 -0400 Original-Path: shelby.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!nx01.iad01.newshosting.com!newshosting.com!post01.iad01!news.aliant.net!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: slrn/0.9.8.1pl1 (Debian) Original-Lines: 40 Original-NNTP-Posting-Host: 142.177.120.167 Original-X-Complaints-To: abuse@aliant.net Original-Xref: shelby.stanford.edu gnu.emacs.help:152175 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:47684 Archived-At: On 2007-09-19, Richard G Riley wrote: >> On Sep 18, 10:01 pm, Tyler Smith wrote: >>> It should be (c-mode), not (cc-mode). The following works for >>> me: >>> >>> (defun my-find-file-hook() >>> (let ((fn (buffer-file-name))) >>> (when (string-match "\\.cu$" fn) >>> (c-mode)))) >>> (add-hook 'find-file-hooks 'my-find-file-hook) > > See the other reply. It is a better way: > > (add-to-list 'auto-mode-alist '("\\.cu$" . c-mode)) > > find-file-hooks is obsolete in newer versions of emacs. Thanks for the correction. I see now that I had a few 'auto-mode-alist lines in my .emacs serving this purpose, but I didn't really understand them. Reading the manual, I see that find-file-hooks is now obsolete - will find-file-hook be obsolete also? What should I replace the following code with: (defun my-find-file-hook() (let ((fn (buffer-file-name))) (when (string-match "latex2rtf" fn) (set-variable 'tab-width 4)))) (add-hook 'find-file-hook 'my-find-file-hook) I use this because a project I'm working on uses a tab-width of 4 for formatting their c code. I take it that's not ideal, but it's not my decision. Anyways, all the files are in a directory called latex2rtf, so this hook does what I need. What is the preferred way to accomplish this? Thanks, Tyler