2

I am reading the following blog on setting up Emacs to use pandoc in such away that C-c C-p will open the document in my browser.

It says:

Restart Emacs, and open a markdown file (for example test.md). Then select Options->Customize Emacs->Specific Option, enter markdown-command.

enter pandoc -f markdown -t html -s --mathjax --highlight-style=pygments in the "Markdown Command" field and select "Apply and save".

Then when you are editing your markdown file in Emacs, try C-c C-c p, the generated html will show up in your default browser.

What would be the Elisp entry in .emacs?

I am using Emacs 24.5.

  • Not sure what you mean by "lsip entry", but maybe you are looking for this: (setq markdown-command "pandoc -f markdown -t html -s --mathjax --highlight-style pygments")? – itsjeyd May 6 '15 at 14:21
  • This value should be saved in your custom-file you should see it there, and like @itsjeyd said, just use a setq, or even setq-default in your init. – Jordon Biondo May 6 '15 at 18:43
  • @itsjeyd lisp is the programming language emacs uses and lsip is a typo. – dustin May 6 '15 at 21:36
  • Unfortunately the referred site has been removed. This is the page from archive.org: web.archive.org/web/20140215043007/http://jgmaox.wordpress.com/… – gsl May 8 '15 at 15:58
5

Here's the Elisp code for setting markdown-command in your init-file:

(setq markdown-command 
      "pandoc -f markdown -t html -s --mathjax --highlight-style=pygments")

You should check whether markdown-command is a buffer-local variable. Do C-h v markdown-command RET and look for a line that says:

Automatically becomes buffer-local when set.

If markdown-command is in fact buffer-local, you'll need to replace setq with setq-default in the code above.


To set up a custom key binding for the command that is bound to C-c C-c p, add the following code to your init-file:

(define-key markdown-mode-map (kbd "C-c C-p") #'command)

If you don't know what C-c C-c p is bound to, do C-h k C-c C-c p from a markdown-mode buffer to find out.

| improve this answer | |
  • I have been out of town so I will give this a try either today or tomorrow. – dustin May 9 '15 at 16:44
  • The define-key line produces: ne-key markdown-mode-map (kbd "C-c C-p") (function command)) eval-buffer(#<buffer *load*> nil "/home/dustin/.emacs" nil t) ; Reading at buffer position 915 load-with-code-conversion("/home/dustin/.emacs" "/home/dustin/.emacs" t t) load("~/.emacs" t t) more stuff that is too long to fit – dustin May 10 '15 at 3:12
  • The define key part is superfluous I found and not needed. Also, an equal sign needs to be -style=pygments. – dustin May 10 '15 at 4:07
  • @dustin Added the missing =. No idea how it got lost! ;) – itsjeyd May 10 '15 at 9:39

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.