Skip to content

Instantly share code, notes, and snippets.

@milkypostman
Created October 27, 2011 20:10
Show Gist options
  • Save milkypostman/1320727 to your computer and use it in GitHub Desktop.
Save milkypostman/1320727 to your computer and use it in GitHub Desktop.
markdown-mode additional functions.
(defun markdown-copy-html ()
"process file with multimarkdown and save it accordingly"
(interactive)
(save-window-excursion
(flet ((markdown-output-standalone-p () t))
(markdown))
(kill-ring-save (point-min) (point-max))))
(defun markdown-copy-rtf ()
"render and copy as RTF"
(interactive)
(save-window-excursion
(flet ((markdown-output-standalone-p () t))
(let ((markdown-command (concat markdown-command " -s -t rtf")))
(message (prin1-to-string (markdown-output-standalone-p)))
(markdown)
(shell-command-on-region (point-min) (point-max) "pbcopy")))))
(defun markdown-copy-paste-safari ()
"process file with multimarkdown, copy it to the clipboard, and
paste in safari's selected textarea"
(interactive)
(markdown-copy-html)
(do-applescript "tell application \"Safari\"
activate
tell application \"System Events\" to keystroke \"a\" using {command down}
tell application \"System Events\" to keystroke \"v\" using {command down}
end tell"))
(eval-after-load 'markdown-mode
'(progn
(define-key markdown-mode-map (kbd "C-c r") 'markdown-copy-rtf)
(define-key markdown-mode-map (kbd "C-c c") 'markdown-copy-html)
(define-key markdown-mode-map (kbd "C-c s") 'markdown-copy-paste-safari)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment