11

This question already has an answer here:

I would like emacs to switch to gnuplot-mode when I open a file ending in .g or .gnuplot.

I tried

;; gnuplot mode-name
(add-to-list 'gnuplot-mode '("\\.g\\'" . gnuplot-mode))

or

;; gnuplot mode-name
(add-to-list 'gnuplot '("\\.g\\'" . gnuplot))

Neither works. How do I make Emacs behave this way?

marked as duplicate by ChillarAnand, Kaushal Modi, npostavs, Drew, Constantine Nov 6 '15 at 16:39

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Where is the duplicated (original) question? – Daniel Pérez Jun 16 '17 at 14:26
11

The full syntax for specifying file extensions for gnuplot-mode is:

(add-to-list 'auto-mode-alist '("\\.g\\'" . gnuplot-mode))

The other point to verify is that you are using Bruce Ravel's recent (year 2012) implementation of gnuplot-mode. This is a separate MELPA package that requires gnuplot version 4.4 and higher.

Lastly avoid gnuplot-mode files that come pre-packaged with gnuplot itself. They have not been kept compatible with newer emacs versions.

  • 7
    You can make that a bit more concise by using add-to-list. Also relevant: C-h i g (elisp) Auto Major Mode. – Kaushal Modi Nov 5 '15 at 23:50
  • 2
    @kaushalmodi: since add-to-list is probably the canonical idiom, could you add that as a separate answer for future users? – Dan Nov 6 '15 at 13:04

Not the answer you're looking for? Browse other questions tagged or ask your own question.