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: Stefan Monnier
Subject: Re: Emacs . How can I associate *.cu files as cc mode as a default ?
Date: Wed, 19 Sep 2007 15:46:27 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/23.0.50 (gnu/linux)

> Reading the manual, I see that find-file-hooks is now obsolete - will
> find-file-hook be obsolete also?

No: find-file-hooks is obsolete only because it was renamed to find-file-hook.

> 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)

You can keep it as-is.  Although I'd use (setq tab-width 4) instead of
set-variable (set-variable is meant for interactive use, not that it matters
in this case).

Actually I'd probably do it that way instead:

   (defun my-latex2rtf-c-mode ()
     (c-mode)
     (setq tab-width 4))

   (add-to-list 'auto-mode-alist
                '("/latex2rtf/.*\\.c\\'" . my-latex2rtf-c-mode))

Not sure if it's better.


        Stefan


reply via email to

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