`markdown-mmm-auto-modes` defines pairs of language and mode names
where the mode name is different from the language name
This commit is contained in:
parent
7caa91bf6c
commit
7fc758e3c2
|
@ -67,13 +67,14 @@ markdown buffer in Chrome. Please refer to =chrome= layer documentation for more
|
|||
information.
|
||||
|
||||
** Automatic MMM-Mode Generation
|
||||
To generate MMM-Modes for languages where the language name directly relates to
|
||||
the Emacs mode name, set the value of the variable =markdown-mmm-auto-modes= to
|
||||
a list of the languages:
|
||||
To generate MMM-Modes for languages set the value of the variable
|
||||
=markdown-mmm-auto-modes= to a list of the languages. For languages where the
|
||||
mode name directly relates to the language name, use a string. Otherwise, use a
|
||||
list of `("language" "mode")`:
|
||||
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
dotspacemacs-configuration-layers '(
|
||||
(markdown :variables markdown-mmm-auto-modes '("c" "c++" "python" "scala"))
|
||||
(markdown :variables markdown-mmm-auto-modes '("c" "c++" "python" "scala" ("elisp" "emacs-lisp"))
|
||||
#+END_SRC
|
||||
|
||||
* Usage
|
||||
|
|
|
@ -15,6 +15,5 @@
|
|||
"Possibe values are `eww' (built-in browser) or `vmd' (installed with `npm').")
|
||||
|
||||
(defvar markdown-mmm-auto-modes
|
||||
'("c" "c++" "css" "java" "javascript" "python" "ruby" "rust" "scala")
|
||||
"Automatically add mmm class for languages where its name and mode name are
|
||||
directly related")
|
||||
'("c" "c++" "css" "java" "javascript" "python" "ruby" "rust" "scala" ("html" "web") ("elisp" "emacs-lisp") ("ess" "R"))
|
||||
"List of language names or lists of language and mode names for which to generate mmm classes.")
|
||||
|
|
|
@ -44,11 +44,13 @@
|
|||
(add-hook 'markdown-mode-hook 'smartparens-mode))
|
||||
|
||||
;; from Jason Blevins http://jblevins.org/log/mmm
|
||||
(defun markdown/mmm-auto-class (lang &optional submode)
|
||||
(let ((class (intern (concat "markdown-" lang)))
|
||||
(submode (or submode (intern (concat lang "-mode"))))
|
||||
(front (concat "^```" lang "[\n\r]+"))
|
||||
(back "^```$"))
|
||||
(defun markdown/mmm-auto-class (lang)
|
||||
(let* ((l (if (listp lang) (car lang) lang))
|
||||
(s (if (listp lang) (cadr lang) lang))
|
||||
(class (intern (concat "markdown-" l)))
|
||||
(submode (intern (concat s "-mode")))
|
||||
(front (concat "^```" l "[\n\r]+"))
|
||||
(back "^```$"))
|
||||
(mmm-add-classes (list (list class
|
||||
:submode submode
|
||||
:front front
|
||||
|
@ -182,14 +184,8 @@ Will work on both org-mode and any mode that accepts plain html."
|
|||
:init (add-hook 'markdown-mode-hook 'spacemacs/activate-mmm-mode)
|
||||
:config
|
||||
(progn
|
||||
;; Automatically add mmm class for languages where its name and mode
|
||||
;; name are directly related
|
||||
;; Automatically add mmm class for languages
|
||||
(mapc 'markdown/mmm-auto-class markdown-mmm-auto-modes)
|
||||
|
||||
;; Otherwise define these manually
|
||||
(markdown/mmm-auto-class "html" 'web-mode)
|
||||
(markdown/mmm-auto-class "elisp" 'emacs-lisp-mode)
|
||||
(markdown/mmm-auto-class "ess" 'R-mode)
|
||||
(setq mmm-global-mode t))))
|
||||
|
||||
(defun markdown/init-vmd-mode ()
|
||||
|
|
Loading…
Reference in New Issue