I will open this as a separate PR if you accept the changes:

;;;;;;;;;;;;; Will be added to snakemake-mode.el

;;; Embedded language syntax-highlighting

(defun snakemake-mode-setup-mmm ()
  "Call this function in your startup-file to automatically highlight embedded R-code.

You must have the R-strings either within a R(''' ''') function call or a code block delimited with '''#r and '''."

  (if (require 'mmm-mode nil 'noerror)
      (progn (require 'mmm-mode)
             (setq mmm-global-mode 'maybe)

             (mmm-add-classes
              '((snakemake-R-call-double
                 :submode R-mode
                 :front ".*R\(\"\"\""
                 :back ".*\"\"\"\)")))

             (mmm-add-classes
              '((snakemake-R-call-regular
                 :submode R-mode
                 :front ".*R\('''"
                 :back ".*'''\)")))

             (mmm-add-classes
              '((snakemake-R-string-double
                 :submode R-mode
                 :front ".*\"\"\" * # *[rR]"
                 :back ".*\"\"\"")))

             (mmm-add-classes
              '((snakemake-R-string-regular
                 :submode R-mode
                 :front ".*''' * # *[rR]"
                 :back ".*'''")))

             (mmm-add-mode-ext-class 'snakemake-mode nil 'snakemake-R-call-double)
             (mmm-add-mode-ext-class 'snakemake-mode nil 'snakemake-R-call-regular)
             (mmm-add-mode-ext-class 'snakemake-mode nil 'snakemake-R-string-double)
             (mmm-add-mode-ext-class 'snakemake-mode nil 'snakemake-R-string-regular))
    (error "You need to install mmm-mode")))

(snakemake-mode-setup-mmm)

I guess this should be documented, but it would be strange to document this when most of the package is not documented (in any README/FAQ file). Most users probably do not read the code.


You are receiving this because you commented.
Reply to this email directly or view it on GitHub