Mercurial > hg > dotemacs
changeset 203:0c58e4b3861d
markdown-preview-buffer: new function
Why isn't this already part of markdown-mode? I hope I don't have to
maintain this function too much.
Oh, and thanks to now-deleted Reddit user who suggested this:
https://old.reddit.com/r/emacs/comments/2x4jtt/render_markdown_in_a_buffer/cowyg9e/
author | Jordi Gutiérrez Hermoso <jordigh@octave.org> |
---|---|
date | Tue, 17 Dec 2019 13:41:04 -0500 |
parents | 0191e8351212 |
children | 444105c995f1 |
files | dotemacs.el |
diffstat | 1 files changed, 19 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/dotemacs.el +++ b/dotemacs.el @@ -50,6 +50,8 @@ (require 'fish-mode) +(require 'eww) + (elpy-enable) ;; I want sql-mode to have a couple of extra bells and whistles. @@ -99,6 +101,23 @@ ;; words (setq-default truncate-lines t) +;; A little function to use eww to view rendered markdown output. +(defun markdown-preview-buffer () + (interactive) + (let* ((buf-this (buffer-name (current-buffer))) + (buf-html (get-buffer-create + (format "*markdown-html (%s)*" buf-this))) + (buf-rendered (format "*%s-rendered*" buf-this)) + (window-orig (selected-window))) + (markdown-other-window (buffer-name buf-html)) + (when (get-buffer buf-rendered) + (kill-buffer buf-rendered)) + (shr-render-buffer buf-html) + (eww-mode) + (rename-buffer buf-rendered) + (kill-buffer buf-html) + (select-window window-orig))) + (server-start) ;; I want tramp to obey the $PATH that is set on the remote host