* make buffer be c++ mode?
@ 2015-05-23 21:30 Jai Dayal
2015-05-23 22:14 ` John Mastro
2015-05-24 1:20 ` Dale Snell
0 siblings, 2 replies; 5+ messages in thread
From: Jai Dayal @ 2015-05-23 21:30 UTC (permalink / raw)
To: help-gnu-emacs
Hi,
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.
Thanks
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: make buffer be c++ mode?
2015-05-23 21:30 make buffer be c++ mode? Jai Dayal
@ 2015-05-23 22:14 ` John Mastro
2015-05-24 1:20 ` Dale Snell
1 sibling, 0 replies; 5+ messages in thread
From: John Mastro @ 2015-05-23 22:14 UTC (permalink / raw)
To: Jai Dayal, help-gnu-emacs
Jai Dayal <dayalsoap@gmail.com> wrote:
> 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.
M-x c++-mode RET should do the trick.
--
john
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: make buffer be c++ mode?
2015-05-23 21:30 make buffer be c++ mode? Jai Dayal
2015-05-23 22:14 ` John Mastro
@ 2015-05-24 1:20 ` Dale Snell
1 sibling, 0 replies; 5+ messages in thread
From: Dale Snell @ 2015-05-24 1:20 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 1424 bytes --]
On Sat, 23 May 2015 17:30:57 -0400, in message
CAMJ-YiSzJjOBwUfWvCrexzihW5zV8qJyKzKPyi4Ss8u1PR1dGg@mail.gmail.com, Jai
Dayal wrote:
> Hi,
>
> 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.
>
> Thanks
For one-off editing of just one file, John's suggestion is fine.
If you're going to be editing .cu files on more than an occasional
basis, something along the line of Emanuel's suggestion is a good
idea.
On the third hand, if you're going to be editing this one
file once in a while, stick a file-local variable in it. You can
do this one of two ways. One: make the following the first line
of your program:
// -*- mode: c++; -*-
Other settings can be added, thus:
// -*- mode: c++; fill-column: 72; <and so on...> -*-
(The "-*-" strings are required for this method.)
Two: stick it at the end of the file, thusly:
// Local variables:
// mode: c++
// <another setting, if you want>
// <yet another setting>
// End:
Note that in all cases, the local variable statements are entered
as comments, so that the compiler won't see them.
Hope this helps, and have fun!
--Dale
--
In Xanadu did Kubla Khan a stately pleasure dome decree
But only if the NFL to a franchise would agree.
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <mailman.3550.1432416681.904.help-gnu-emacs@gnu.org>]
* Re: make buffer be c++ mode?
[not found] <mailman.3550.1432416681.904.help-gnu-emacs@gnu.org>
@ 2015-05-23 23:27 ` Emanuel Berg
2015-05-24 8:49 ` tomas
0 siblings, 1 reply; 5+ messages in thread
From: Emanuel Berg @ 2015-05-23 23:27 UTC (permalink / raw)
To: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: make buffer be c++ mode?
2015-05-23 23:27 ` Emanuel Berg
@ 2015-05-24 8:49 ` tomas
0 siblings, 0 replies; 5+ messages in thread
From: tomas @ 2015-05-24 8:49 UTC (permalink / raw)
To: Emanuel Berg; +Cc: help-gnu-emacs
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Sun, May 24, 2015 at 01:27:30AM +0200, Emanuel Berg wrote:
> 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.
Good idea -- I'd tend to go with Dale's approach in the same thread,
because it's more "standard" ("principle of least astonishment").
The -*- mode:foo -*- "cookie" at the start of the file (or a corresponding
block at the end) are "the usual way" of achieving this.
> 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:
Yep, this would be the more "permanent" solutions.
- -- t
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
iEYEARECAAYFAlVhkLMACgkQBcgs9XrR2kZWxQCeJVrAHNlBb++9RC9XVKpztZWa
OpkAnis5orLGalUm6FOtLx+cISWv1ORM
=uypC
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-05-24 8:49 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-23 21:30 make buffer be c++ mode? Jai Dayal
2015-05-23 22:14 ` John Mastro
2015-05-24 1:20 ` Dale Snell
[not found] <mailman.3550.1432416681.904.help-gnu-emacs@gnu.org>
2015-05-23 23:27 ` Emanuel Berg
2015-05-24 8:49 ` tomas
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.