From 2a1809cf63a5596ccdffe1548d5889082eabc7a3 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 17 Nov 2015 02:10:49 -0500 Subject: [PATCH] Add narf:org-export (and for markdown-mode too) --- modules/lib/defuns-org.el | 11 +++++++++++ modules/module-markdown.el | 39 +++++++++++++++++++++----------------- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/modules/lib/defuns-org.el b/modules/lib/defuns-org.el index aa09048a2..a3b4260ef 100644 --- a/modules/lib/defuns-org.el +++ b/modules/lib/defuns-org.el @@ -226,6 +226,17 @@ COUNT-FOOTNOTES? is non-nil." (t (copy-file link new-path))) (insert (format "[[./%s]]" (abbreviate-file-name new-path)))))) +;;;###autoload (autoload 'narf:org-export "defuns-org" nil t) +(evil-define-command narf:org-export (dest) + (interactive "") + (let ((path (if (string-match-p "^[/~]" dest) + dest + (expand-file-name dest default-directory)))) + (shell-command + (format "/usr/local/bin/pandoc '%s' -o '%s'" + (buffer-file-name) path)) + (message "Done! Exported to: %s" path))) + ;;;###autoload (defun narf/org-remove-link () "Replace an org link by its description or if empty its address" diff --git a/modules/module-markdown.el b/modules/module-markdown.el index c50046234..d3ad2f5a9 100644 --- a/modules/module-markdown.el +++ b/modules/module-markdown.el @@ -11,27 +11,32 @@ :init (add-hook! markdown-mode 'narf|enable-hard-wrap) :config - (bind! :map markdown-mode-map - "" nil - "" nil - "" nil + (add-hook! markdown-mode + (exmap! "preview" 'narf/markdown-preview) + (exmap! "export" 'narf:org-export)) + (bind! (:map markdown-mode-map + "" nil + "" nil + "" nil - "M-*" 'markdown-insert-list-item - "M-b" 'markdown-insert-bold - "M-i" 'markdown-insert-italic - "M-`" 'narf/markdown-insert-del + ;; Assumes you have a markdown renderer plugin in chrome + :nv "M-r" (λ (narf-open-with "Google Chrome")) - (:prefix "," ; - :nv "i" 'markdown-insert-image - :nv "l" 'markdown-insert-link - :nv "L" 'markdown-insert-reference-link-dwim - :nv "b" 'markdown-preview) + "M-*" 'markdown-insert-list-item + "M-b" 'markdown-insert-bold + "M-i" 'markdown-insert-italic + "M-`" 'narf/markdown-insert-del - ;; TODO: Make context sensitive - :n "[p" 'markdown-promote - :n "]p" 'markdown-demote + :nv ",i" 'markdown-insert-image + :nv ",l" 'markdown-insert-link + :nv ",L" 'markdown-insert-reference-link-dwim + :nv ",b" 'markdown-preview - :i "M--" 'markdown-insert-hr)) + ;; TODO: Make context sensitive + :n "[p" 'markdown-promote + :n "]p" 'markdown-demote + + :i "M--" 'markdown-insert-hr))) ;; TODO: Test previewing capability