From: Tyler Smith <tyler.smith@mail.mcgill.ca>
To: help-gnu-emacs@gnu.org
Subject: Re: Emacs . How can I associate *.cu files as cc mode as a default ?
Date: 19 Sep 2007 00:28:09 GMT [thread overview]
Message-ID: <slrnff0r96.477.tyler.smith@blackbart.mynetwork> (raw)
In-Reply-To: 1190160650.850759.138290@50g2000hsm.googlegroups.com
On 2007-09-19, Mike H <hspnew@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
next prev parent reply other threads:[~2007-09-19 0:28 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-19 0:10 Emacs . How can I associate *.cu files as cc mode as a default ? Mike H
2007-09-19 0:28 ` Tyler Smith [this message]
2007-09-19 1:09 ` Mike H
2007-09-19 1:25 ` Mike H
2007-09-19 2:01 ` Tyler Smith
2007-09-19 2:04 ` Mike H
2007-09-19 15:13 ` Richard G Riley
2007-09-19 15:47 ` Tyler Smith
2007-09-19 16:15 ` Gordon Beaton
2007-09-19 17:55 ` Tyler Smith
2007-09-19 19:14 ` Lowell Gilbert
2007-09-19 19:46 ` Stefan Monnier
2007-09-20 23:17 ` Tyler Smith
2007-09-19 6:24 ` Gordon Beaton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=slrnff0r96.477.tyler.smith@blackbart.mynetwork \
--to=tyler.smith@mail.mcgill.ca \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).