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: Tyler Smith
Subject: Re: Emacs . How can I associate *.cu files as cc mode as a default ?
Date: 19 Sep 2007 15:47:19 GMT
User-agent: slrn/0.9.8.1pl1 (Debian)

On 2007-09-19, Richard G Riley <rileyrgdev@googlemail.com> wrote:
>> On Sep 18, 10:01 pm, Tyler Smith <tyler.sm...@mail.mcgill.ca> 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


reply via email to

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