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

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)

Related

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

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))

Emacs load-path scala-mode

I am trying to install ENSIME for emacs. On the first step, when I integrate the ./misc/scala-tool-support/emacs .elc files, the instructions say to
(add-to-list 'load-path "/path/to/some/directory/scala-mode")
Because of the way the directory is structured (where there is no dir scala-mode but all of the .el files are called scala-mode), I am unsure what this exactly specifies. I originally thought it jsut meant to do something like:
(add-to-list 'load-path "~/...../misc/scala-tool-support/emacs/"), but reading further down to the following made me rethink my assumption.
(setq yas/my-directory "/path/to/some/directory/scala-mode/contrib/yasnippet/snippets")
(yas/load-directory yas/my-directory)
Can someone clarify this please?
Thanks much.
The yas/load-directory call has nothing to do with your load-path. Yes, you had it right originally. Is this not working? If so, what error message do you get?
Here is my setup for scala-mode and ensime on Emacs. I'm on OS X.
In the vendor/scala directory, it's just all the .el files from the compiler distribution.
And ensime/dist is bin/ elisp/ and lib/ directories from a github download.
;; Scala Mode
(add-to-list 'load-path "/Users/you/.emacs.d/vendor/scala")
(require 'scala-mode-auto)
(add-to-list 'auto-mode-alist '("\\.scala$" . scala-mode))
(add-to-list 'load-path "/path/to/ensime/dist")
(require 'ensime)
(add-hook 'scala-mode-hook 'ensime-scala-mode-hook)
I've checked the scala-tool-support repo, all of the scala-related snippets for had been included in Yasnippet now. If we use the Yasnippet release version newer than 0.5.7 , the snippets for scala-mode should be included in /path/to/yasnippet/text-mode/scala-mode, so we don't need to set yas/load-directory by ourselves.

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.

Problem installing Auto-Complete plugin in Emacs

I downloaded Auto-Complete from here: http://github.com/m2ym/auto-complete/downloads, I placed all the files from the .zip file in my load-path (C:\...Application Data\.emacs.d\plugins\auto-complete-1.0), and added the following to my .emacs:
;; load auto complete
(add-to-list 'load-path "~/.emacs.d/plugins/auto-complete-1.0")
(require 'auto-complete)
(global-auto-complete-mode t)
but an error message shows up:
.emacs:53:1:Error: Cannot open load file: auto-complete
I use a trailing '/' with directory names (as per file-name-as-directory). e.g.:
(add-to-list 'load-path (file-name-as-directory
(expand-file-name "~/.emacs.d/plugins/auto-complete-1.0")))
I rather doubt that's actually an issue, though.
Are your permissions appropriate for those files and directories?
Are you sure that ~ really expands to C:\...Application Data? Do C-x d ~ RET to be sure.

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