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 16:15:52 GMT Organization: - Message-ID: <46f14b38$0$3196$8404b019@news.wineasy.se> 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 1190220171 24420 80.91.229.12 (19 Sep 2007 16:42:51 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 19 Sep 2007 16:42:51 +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:42:38 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 1IY2cV-0003tO-FO for geh-help-gnu-emacs@m.gmane.org; Wed, 19 Sep 2007 18:41:47 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IY2cT-00013e-OP for geh-help-gnu-emacs@m.gmane.org; Wed, 19 Sep 2007 12:41:45 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!goblin1!goblin.stu.neva.ru!uio.no!fi.sn.net!newsfeed1.fi.sn.net!news.song.fi!not-for-mail Original-Newsgroups: gnu.emacs.help X-No-Productlinks: yes User-Agent: slrn/0.9.8.1 (Linux) Original-Lines: 33 Original-NNTP-Posting-Host: cube.smaltan.org Original-X-Trace: 1190218552 news.wineasy.se 3196 195.42.215.17:61917 Original-X-Complaints-To: abuse@tdcsong.se Original-Xref: shelby.stanford.edu gnu.emacs.help:152176 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:47685 Archived-At: On 19 Sep 2007 15:47:19 GMT, Tyler Smith wrote: > (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? If you want to do this for all files of that type, then c-mode-hook is a better place to put the function, which doesn't need to check the filename: (add-hook 'c-mode-hook (lambda() (setq c-basic-offset 4))) Alternatively, use file variables to save settings specific to that file in the file itself. Put a comment like this one near the end of the file: /* * Local Variables: * mode:c * c-basic-offset: 4 * End: */ /gordon --