markdown-mode icon indicating copy to clipboard operation
markdown-mode copied to clipboard

live-preview position & widget webkit

Open mclearc opened this issue 3 years ago • 1 comments

Live preview always scrolls back to top on reload.

Expected Behavior

Updating the end of a markdown file in live-preview-mode should keep the live preview at the bottom as well.

Actual Behavior

the live preview reloads at the top of the document

Steps to Reproduce

I use the following function to generate live previews in emacs of markdown files:

  (defun cpm--markdown-live-preview-window-xwidget (file)
    "Preview file with xwidget browser"
    (xwidget-webkit-browse-url (concat "file://" file))
    (let ((buf (xwidget-buffer (xwidget-webkit-current-session))))
      (when (buffer-live-p buf)
        (and (eq buf (current-buffer)) (quit-window))
        (pop-to-buffer buf))))

  (setq markdown-live-preview-window-function 'cpm--markdown-live-preview-window-xwidget)

Running live preview with this gives the above described scrolling behavior

Backtrace

no backtrace since there is no actual error.

Software Versions

markdown 2.5-dev emacs 28.0.5 (macOS Catalina 10.15.7 built using homebrew and emac-plus)

mclearc avatar Jul 02 '21 20:07 mclearc

We're currently looking into this in a PR in markdown-xwidget here: https://github.com/cfclrk/markdown-xwidget/pull/8

tl;dr: So far, we're solving this problem with javascript in the browser. If anyone has ideas about how this could be addressed from elisp, that would be super cool.

cfclrk avatar Nov 03 '22 10:11 cfclrk