2

I swear there used to be something like this.

I'm writing a lot of Markdown with embedded code. I would like to have EMACS treat code in GitHum fenced code according to the default mode for that type of code. That is, if I write:

...and this excellent piece of code computes a function significant to number theory:

```python
def even(x):
    return (x % 2) == 0
```

I would like the code within the fences to be treated as Python while the code outside the fences is Markdown.

2

For markdown, I would strongly recommend using polymode.

Currently, polymode is distributed with a special mode that will allow you to edit these regions with the appropriate major mode.

If you're also using use-package you can enable it with:

(use-package polymode
  :ensure t
  :defer t)

(use-package poly-markdown
  :ensure polymode
  :defer t
  :mode ("\\.md" . poly-markdown-mode))

There's also some more details available in this answer:

https://emacs.stackexchange.com/a/27695/2653

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.