Start C++ syntax highlighting for .cu (CUDA) files - emacs

I use Emacs as an editor. Of late whenever I use CUDA files (which usually have extensions .cu) I have to manually do M-x c++-mode to turn on syntax highlighting and other yasnippet features.
How do I do I ensure that all .cu files when started in EMACS automatically borrow all the C++ mode features. In other words .cu extension becomes an alias for .cpp extension.
( I know there is a CUDA mode for EMACS, (not inbuilt) but when I installed this mode it does not turn on many of the useful features present in the C++-mode of emacs )

Putting this into your .emacs should do the trick:
(add-to-list 'auto-mode-alist '("\\.cu\\'" . c++-mode))

Just in case people have missed it; there's a slightly more official cuda-mode available: http://www.emacswiki.org/emacs/CudaMode
You need to put it somewhere in your load-path; for example on my Mac, I put the code in $HOME/Library/emacs/cuda-mode.el and added the following lines to my .emacs file.
(add-to-list 'load-path "~/Library/emacs")
(autoload 'cuda-mode "cuda-mode.el")
(add-to-list 'auto-mode-alist '("\\.cu\\'" . cuda-mode))

Related

Emacs lua-mode (File mode specification error)

I get the following error
File mode specification error: (error "Unknown rx form `group-n'")
when I try to edit a .lua file in emacs. I use GNU Emacs 23.3.1, and I have the following in my .emacs file:
(autoload 'lua-mode "lua-mode" "Lua editing mode." t)
(add-to-list 'auto-mode-alist '("\\.lua$" . lua-mode))
(add-to-list 'interpreter-mode-alist '("lua" . lua-mode))
I installed lua-mode from http://immerrr.github.com/lua-mode/.
I have tried to run emacs with the --debug-init option, but it did not enter the debugger, instead the .lua file opens in text-mode and not lua-mode..
(See also Emacs lua-mode issue: (void-function interactively-called-p))
Your Emacs is complaining because it knows nothing about group-n symbol used in rx macro in one of the recent commits, and that is probably because that symbol was only introduced in Emacs 24.2 and your one is a bit older.
I must admit, when coding that I thought that rx package was much more mature and didn't even bother looking up its changes in Emacs news. So, there are two options here:
either you update your Emacs to 24.2
or you could downgrade to older revision and wait while I have the chance to rewrite that piece of code.
UPD: the issue is fixed in upstream, the code is compatible with Emacs23 again.

EMACS mumamo/nxhtml mode is overriding js2-mode for js files

How do you choose which files mumamo loads on? It is now the default for all files despite what I have in my .emacs file.
I'd like to use js2-mode when it's a js file, mumamo if it's html/php/etc.
I suggest that you contact the author, Lennart Borgman, directly. He is usually quite helpful.
It worked for me when I added the following lines in my .emacs:
;; js2-mode configuration
(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
;; because nxhtml-mode forces loading .js files with javascript-mode
(defalias 'javascript-mode 'js2-mode)

Plugin in Emacs

I'm trying to install lua-mode into emacs for windows but nothing seems to be working. I've set my HOME environment variable. I've added init.el and lua-mode.el to the HOME\.emacs.d directory. Then I've added the following code to init.el:
(autoload 'lua-mode "lua-mode" "Lua editing mode." t)
(add-to-list 'auto-mode-alist '("\\.lua$" . lua-mode))
(add-to-list 'interpreter-mode-alist '("lua" . lua-mode))
(add-hook 'lua-mode-hook 'turn-on-font-lock)
Nothing is working when I start up emacs and load a .lua file. The major mode is always set to fundamental and there are no other options to change to. What can I do to get this working?
It's possible that your init.el is never read, because you also have a .emacs file (or .emacs.el) in your $HOME directory. You can choose between those three alternatives for Emacs' init file, but only one of them will be read. Traditionally, that's .emacs but some operating systems have problems with that filename syntax.
Also, make sure that you placed init.el in your actual home directory, not a directory called "HOME" or something.
See here for further details on Emacs init files and here for more info on home directories.
If you're not keen on using the init.el variant, here are instruction that should make lua-mode work for you using .emacs:
Start a new Emacs
Type C-x C-f ~/.emacs <ENTER> (C-x means press CTRL, hold it, press x, release - same for C-f)
Insert the following lines:
(add-to-list 'load-path "/path/to/lua-mode-dir")
(autoload 'lua-mode "lua-mode" "Lua editing mode." t)
(add-to-list 'auto-mode-alist '("\\.lua$" . lua-mode))
(add-to-list 'interpreter-mode-alist '("lua" . lua-mode))
(add-hook 'lua-mode-hook 'turn-on-font-lock)
Type C-x C-s to save the buffer to file
Type C-x C-c to close Emacs
Note that in step 3 you have to adjust "/path/to/lua-mode-dir" with the actual path to the directory where you saved the file lua-mode.el on your hard disk.
maybe you need something like (require 'lua-mode) or something like that? Also make sure that the lua-mode file is in a directory in your load-path variable. Something like this before anything else:
(add-to-list 'load-path "/home/dervin/.emacs.d/site-lisp/")
or wherever, and then the require-
The lines look OK. This can depend on a number of things:
The init.el file is not loaded at startup. In face, this is a non-standard name when it comes to Emacs. Emacs tries to load the files ~/.emacs, ~/emacs.el, and ~/.emacs.d/init.el in order, and will load the first one found. To verify that you file has loaded, you could add (message "Loading my init.el") inside it and check the *Messages* buffer.
The directory where you stored the file lua-mode.el is not in the load path. In fact, the ~/.emacs.d directory is not part of the standard load path.

Can't activate 'remember' in org-mode

I can't get 'remember' to work in org-mode of emacs.
I'm on snow leopard.
I added
(global-set-key (kbd "C-M-r") 'org-remember)
to my .emacs file but when I try to use that shortcut it says:
Wrong type argument: commandp, remember
So I added
(org-remember-insinuate)
and when I start emacs it says:
symbol's function definition is void org-remember-insinuate
Ideas?
GNU Emacs 22.1.1
Checking the obvious stuff...
Have you ensured that org-remember was loaded? i.e. by adding this to your .emacs:
(require 'org-remember)
And, while you're at it, have you ensured that remember can load properly also?
(require 'remember)
remember is a separate package from org, which you'll have to download. Check out the wiki page.
You'll want to ensure that the org and remember packages are in your load path before you require the libraries, with something like:
(add-to-list 'load-path "/path/to/orgdir/lisp")
(add-to-list 'load-path "/path/to/remember")
(require 'remember)
(require 'org-remember)
Note: Emacs 22 comes with org-mode, but not a recent version. You need the more recent version in order to get the org-remember package.

Can't make Yasnippets work in Emacs, help!

I can't make Yasnippets work (normal version).
When I start Emacs it says:
error: Error ~/.emacs.d/plugins/yasnippet-0.6.1c/snippets/ not a directory
I added this to my .emacs file:
(add-to-list 'load-path
"~/.emacs.d/plugins/yasnippet-0.6.1c")
(require 'yasnippet) ;; not yasnippet-bundle
(yas/initialize)
(yas/load-directory "~/.emacs.d/plugins/yasnippet-0.6.1c/snippets/")
and my yasnippets files are placed in the following folders:
D:\Program Files\emacs-23.1\site-lisp\plugins\yasnippet-0.6.1c
and the snippets:
D:\Program Files\emacs-23.1\site-lisp\plugins\yasnippet-0.6.1c\snippets
All others plugins work so I'm sure its the right load-path
Help!
Perhaps you could write the whole path, instead of a relative one, like this:
add-to-list 'load-path
"D:/Program Files/emacs-23.1/site-lisp/plugins/yasnippet-0.6.1c")
(require 'yasnippet) ;; not yasnippet-bundle
(yas/initialize)
(yas/load-directory "D:/Program Files/emacs-23.1/site-lisp/plugins/yasnippet-0.6.1c/snippets")
Notice the forward slashes, and please make sure that emacs doesn't mind the spaces... Windows is less forgiving than Linux with these kinds of paths. Also, make sure your emacs install reads that dir. Usually, you should put an emacs dir where your .emacs is (in Windows), that makes it more clear. It
Another thing: 1) maybe you're trying your snippet in the wrong mode. Make sure there is a snippet for the mode you're in.
See here as well, lots of info here: GNU Emacs for Windows