Auto-load gfm-mode

4

I have installed markdown-mode.el as described here. How do I get Emacs (specifically, Aquamacs) to load gfm-mode rather than markdown-mode for .markdown files? In case it's important, the relevant section(s) of my ~/.emacs currently look(s) like this:

(add-to-list 'load-path "~/.emacs.d/")

; Some irrelevant (I think) other stuff

(autoload 'markdown-mode "markdown-mode.el" "Major mode for editing Markdown files" t)
(add-to-list 'auto-mode-alist '("\\.text\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.mdown\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.mdt\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))

I'm extremely noobish with Emacs in general, so I'd appreciate step-by-step instructions.

Ptharien's Flame

Posted 2013-02-16T06:00:31.483

Reputation: 143

Answers

5

Try replacing the lines you posted with these:

(add-to-list 'load-path "~/.emacs.d/")

;;; Markdown mode
(autoload 'gfm-mode "markdown-mode.el" "Major mode for editing Markdown files" t)
(setq auto-mode-alist (cons '("\\.text$" . gfm-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.md$" . gfm-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.mdown$" . gfm-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.mdt$" . gfm-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.markdown$" . gfm-mode) auto-mode-alist))

The important thing is to add 'gfm-mode before "markdown-mode.el" in the autoload command.

terdon

Posted 2013-02-16T06:00:31.483

Reputation: 45 216

That just does the same thing as my current .emacs. I wanted it to load gfm-mode rather than markdown-mode. – Ptharien's Flame – 2013-02-17T00:35:30.723

1@Ptharien'sFlame, sorry, I misunderstood your question. It should work now. – terdon – 2013-02-17T22:47:22.067

That doesn't work at all, unless something else entirely is wrong: I get fill-mode when I shouldn't, and syntax highlighting in code fences is not active. – Ptharien's Flame – 2013-02-18T00:46:21.007

1@Ptharien'sFlame, that I can't help you with. Perhaps the mode is not what you expect. Does emacs say it is in gfm-mode in the status bar? If yes, then the mode has been successfully loaded. – terdon – 2013-02-18T01:03:39.240

It does say it's in gfm-mode, but it behaves like it's in standard markdown-mode. I guess you answered my question as stated. – Ptharien's Flame – 2013-02-18T01:54:07.860