discussion and development of Emacs Snakemake mode
 help / color / mirror / code / Atom feed
From: Endre Bakken Stovner <notifications@github.com>
To: kyleam/snakemake-mode <snakemake-mode@noreply.github.com>
Cc: Kyle Meyer <kyle@kyleam.com>
Subject: Re: Support R syntax highlighting in R("""-blocks (#6)
Date: Sun, 17 Apr 2016 12:04:06 -0700	[thread overview]
Message-ID: <kyleam/snakemake-mode/pull/6/c211084302@github.com> (raw)
In-Reply-To: <kyleam/snakemake-mode/pull/6@github.com>

[-- Attachment #1: Type: text/plain, Size: 2029 bytes --]

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

```elisp
;;;;;;;;;;;;; Will be added to snakemake-mode.el
\f
;;; 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:
https://github.com/kyleam/snakemake-mode/pull/6#issuecomment-211084302

[-- Attachment #2: Type: text/html, Size: 4085 bytes --]

  parent reply	other threads:[~2016-04-17 19:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-13  9:03 Support R syntax highlighting in R("""-blocks (#6) Endre Bakken Stovner
2016-04-13 13:26 ` Endre Bakken Stovner
2016-04-14  5:51 ` Endre Bakken Stovner
2016-04-14  6:09 ` Endre Bakken Stovner
2016-04-17 19:04 ` Endre Bakken Stovner [this message]
2016-04-18  4:22 ` Endre Bakken Stovner
2020-04-17  0:01 ` Kyle Meyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://git.kyleam.com/snakemake-mode

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=kyleam/snakemake-mode/pull/6/c211084302@github.com \
    --to=notifications@github.com \
    --cc=kyle@kyleam.com \
    --cc=reply+0013cd7c1a49bdfaf4d2c31ecf1f61f4874c15b4ddb7e45a92cf00000001132ba02692a169ce08d23506@reply.github.com \
    --cc=snakemake-mode@noreply.github.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.kyleam.com/snakemake-mode/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).