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: Mike H
Subject: Re: Emacs . How can I associate *.cu files as cc mode as a default ?
Date: Wed, 19 Sep 2007 01:09:59 -0000
User-agent: G2/1.0

On Sep 18, 8:28 pm, Tyler Smith <tyler.sm...@mail.mcgill.ca> wrote:
> On 2007-09-19, Mike H <hsp...@gmail.com> wrote:
>
> > Emacs . How can I associate *.cu files as cc mode as a default ?
> > cc mode is automatically triggered when I open *.c, *.cpp files.
> > However, I would like to add the new file type :)
>
> You can do this with find-file-hooks. This is code that runs anytime
> you find (open) a file. In this case, you want to check and see if the
> file you've found ends with .cu, and if so, to use cc-mode. This
> function will do that:
>
> (defun my-find-file-hook()
>   (let ((fn (buffer-file-name)))
>     (when (string-match "\\.cu$" fn)
>       (cc-mode))))
>
> You have to tell Emacs to run this function every time you open a new
> file, so you add the hook:
>
> (add-hook 'find-file-hooks 'my-find-file-hook)
>
> Put both forms in your .emacs, and the next time you open emacs you'll
> be all ready to go. (you can also load them into a running emacs using
> C-x C-e to execute the previous command in a lisp-mode buffer, such as
> scratch or .emacs).
>
> HTH,
>
> Tyler


Thank you !  I really appreciate it !



reply via email to

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