polymode / poly-R

Polymodes for the R language
52 stars 10 forks source link

Support for Github-flavored markdown mode #21

Open plantarum opened 3 years ago

plantarum commented 3 years ago

There is a polymode defined for gfm-mode, a variant that accommodates fenced code blocks and a few other features. It doesn't appear to be supported by poly-R. I think it would only require two lines of code:

To define the mode we need only:

(define-polymode poly-gfm+r-mode poly-gfm-mode :lighter " PGFM-Rmd"
  :innermodes '(:inherit poly-r-markdown-inline-code-innermode))

And then we need to do the file association:

(setq auto-mode-alist
         (append
          '(("\\.[rR]md\\'" . poly-gfm+r-mode))
          auto-mode-alist))

I'm not sure where this ought to go - maybe there should be a user option that could signal whether to assign poly-gfm+r-mode or poly-markdown+r-mode to Rmd files?

If you have a suggestion as to how to deal with auto-mode-alist, I can put together a pull request.

plantarum commented 3 years ago

We need a couple more lines:

(polymode-register-exporter poly-r-markdown-ess-exporter nil
                            poly-gfm+r-polymode)
(polymode-register-exporter poly-r-markdown-exporter nil
                            poly-gfm+r-polymode)