send preview when markdown mode buffer is active

This commit is contained in:
Igor Shymko 2014-10-27 13:11:21 +02:00
parent 79d1f32769
commit 8c086640b8
1 changed files with 3 additions and 2 deletions

View File

@ -97,7 +97,8 @@
(setq mdpm:local-client nil))))))
(defun mdpm:send-preview ()
(mdpm:send-preview-to mdpm:local-client))
(when (bound-and-true-p markdown-preview-mode)
(mdpm:send-preview-to mdpm:local-client)))
(defun mdpm:send-preview-to (websocket)
(let ((mark-position-percent
@ -105,7 +106,7 @@
(truncate
(* 100
(/
(float (- (line-number-at-pos) (count-screen-lines (window-start) (point))))
(float (- (line-number-at-pos) (/ (count-screen-lines (window-start) (point)) 2)))
(count-lines (point-min) (point-max))))))))
(when markdown-preview-mode
(markdown markdown-output-buffer-name))