[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: make buffer be c++ mode?
From: |
Emanuel Berg |
Subject: |
Re: make buffer be c++ mode? |
Date: |
Sun, 24 May 2015 01:27:30 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) |
Jai Dayal <dayalsoap@gmail.com> writes:
> I have a file that I've opened with a .cu extension.
> It's C++ code written for Cuda. How do I force Emacs
> to display the buffer as if it were C mode? I just
> want to do it just for this buffer.
If you want this for this particular file and none
other, do like this:
(setq magic-mode-alist '(("/\\* cpp \\*/" . c++-mode)))
Then write
/* cpp */
first line in your .cu file.
If you want this for any file with a .cu extension,
you can do it like this - here I paste my code, you
insert your data (.cu and c++-mode) the same way:
(let ((extras '(
("\\.gpi" . gnuplot-mode)
("\\.\\(glsl\\|oil\\|ssc\\|dfy\\)" . c-mode)
("\\.lua" . lua-mode)
("\\.\\(service\\|list\\|theme\\|mailrc\\|sed\\|inc\\)" . conf-mode)
("\\.pic" . nroff-mode)
("\\.xr" .
conf-xdefaults-mode)
("inputrc" .
conf-colon-mode)
("KILL" .
emacs-lisp-mode)
("\\.service" . emacs)
)))
(setq auto-mode-alist (append extras auto-mode-alist)) )
As you see, I put a lot of files with goofy extensions
into either C mode or configuration mode. The reason
isn't those files are "really" C, rather C has a very
basic syntax which is reused (or closely so) in a lot
of languages. If you were to do that stuff every day
(God forbid) then you'd want I proper mode, here it is
just to make it look good and perhaps get some
indentation as a quick fix the few times you do it.
--
underground experts united
http://user.it.uu.se/~embe8573