preview window is scrolling according to cursor position in markdown buffer

This commit is contained in:
Igor Shymko
2014-10-23 02:14:12 +03:00
parent a9e85581f8
commit 0c53ded3dc
2 changed files with 32 additions and 14 deletions

View File

@@ -95,20 +95,31 @@
(mdpm:sent-preview-to mdpm:local-client))
(defun mdpm:sent-preview-to (websocket)
(when markdown-preview-mode
(markdown markdown-output-buffer-name))
(with-current-buffer (get-buffer markdown-output-buffer-name)
(websocket-send-text websocket
(concat
"<div>"
"<span id='style'>"
markdown-preview-style
"</span>"
"<div id='content'>"
(buffer-substring-no-properties (point-min) (point-max))
"</div>"
"</div>")
)))
(let ((mark-position-percent
(number-to-string
(truncate
(* 100
(/
(float (line-number-at-pos))
(count-lines (point-min) (point-max))))))))
(when markdown-preview-mode
(markdown markdown-output-buffer-name))
(with-current-buffer (get-buffer markdown-output-buffer-name)
(websocket-send-text websocket
(concat
"<div>"
"<span id='style'>"
markdown-preview-style
"</span>"
"<span id='position-percentage'>"
mark-position-percent
"</span>"
"<div id='content'>"
(buffer-substring-no-properties (point-min) (point-max))
"</div>"
"</div>")
))))
(defun mdpm:start ()
(mdpm:start-websocket-server)