help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Emacs . How can I associate *.cu files as cc mode as a default ?


From: Gordon Beaton
Subject: Re: Emacs . How can I associate *.cu files as cc mode as a default ?
Date: 19 Sep 2007 16:15:52 GMT
User-agent: slrn/0.9.8.1 (Linux)

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

--


reply via email to

[Prev in Thread] Current Thread [Next in Thread]