1

Running emacs 25.2.2.

Here is something (apparently) simple I want to do, but am unable to:

  • I am editing an html document. I want to see the same document in the internal browser in a vertically split window.
  • Now, if I make any changes to my html document and hit a key (may be, save buffer could be the trigger), the browser buffer is updated to reflect the changes.
  • The scrolling between the two buffers is synchronized

I can C-c C-v (browse-url-of-buffer) but that does not help because there is no way of updating the browser buffer. Moreover, the scrolling is not synchronized.

How do I get this done?

  • If you have access to the w3m executable, then there is a complimentary Lisp library that can help you view an html file like a web-browser (within Emacs) -- although, not as fancy as Firefox and so forth. Another library (which I believe is all Lisp and does not require an executable) is called shr -- I've only used it once and am by no means an expert. Although I love to do everything in Emacs, if you are doing any sort of web development, then you will want to do a start-process or the equivalent thereof and use the real browser that your target audience will be using. – lawlist Jul 25 '18 at 4:49
  • In terms of a live-preview (e.g., via the post-command-hook), there will undoubtedly be a significant trade-off in terms of performance in Emacs because the working buffer will need to be rendered every command loop and updated in the target buffer. The slow-down in performance is probably a deal-breaker, but maybe you'll have good luck ... Perhaps after every save would be a better way to do it ... [Personally, I rsync a draft to the shared server and view the live draft version in an external web browser.] – lawlist Jul 25 '18 at 4:54
  • @lawlist Your point about the live preview is well-taken. I have updated the question. – deshmukh Jul 25 '18 at 10:20
2

Live preview of Markdown in Emacs is discussed in the terrific Guide to Markdown Mode for Emacs and also at the Emacs wiki.

The markdown-preview-eww package will use Emacs' build-in eww browser to preview Markdown in a separate pane within Emacs:

Live Markdown preview in Emacs

A few other solutions will auto-refresh external web browsers as one types, notably Impatient Mode and Livedown. If none of those help then see the Guide to Markdown Mode for Emacs or Emacs wiki Markdown guides for alternative options.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.