[PLUG] Using newly installed emacs mode

Dale Snell ddsnell at frontier.com
Thu May 11 16:18:05 UTC 2017


On Thu, 11 May 2017 06:35:46 -0700 (PDT), in message
alpine.LNX.2.11.1705110629370.18732 at localhost, Rich Shepard wrote:

>    When seeking how to have emacs use a newly installed language mode
> (js2-mode) I'm not using the appropriate web search terms. Results
> are many instances of writing emacs extensions to support languages,
> but not how to get emacs to use the mode when a language file is
> opened for editing.
> 
>    I used 'install-package [RET] js2-mode [RET]' to download, build,
> and install the mode. Tried 'M-x run-js2' but that was not found. I
> assume that I need to add the language to ~/.emacs but find no
> information on how to do this.
> 
>    Would appreciate learning how to make the mode active so I can use
> it now and in the future.

Hi Rich,

The simplest thing is probably to add the file type to
'auto-mode-alist'.  The command will look something like

    (add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode) t)

That's assuming that the mode name is "js2-mode" and the file type
is ".js".

You'll need to add the above to your ~/.emacs file.  Once that's
done, starting Emacs and loading, say, foobar.js will
automatically start js2-mode as well.

Hope this helps.

--Dale

-- 
"Text processing has made it possible to right-justify any idea, even
one which cannot be justified on any other grounds."
		-- J. Finnegan, USC.



More information about the PLUG mailing list