9

I want to use Emacs as an enhanced way to view the source of a page (say http://example.com). Is there some easy way to download the page directly from Emacs, maybe even through C-x C-f?

I remember doing this somehow in the past (maybe thanks to TRAMP?), but not how, and I can't reproduce it any more.

  • You mean something more clever than just wget and then viewing that right? Perhaps w3m in emacs gives some kind of option? – Edgar Aroutiounian Sep 25 '14 at 18:04
  • @EdgarAroutiounian: Not necessarily more clever so much as more integrated. For some reason, I think there's a more immediate way to do it. – Tikhon Jelvis Sep 25 '14 at 18:08
8

Here's a really quick and dirty solution:

(defun my-view-source (url)
  (interactive "MURL: ")
  (switch-to-buffer (url-retrieve url (lambda (_)))))

url-retrieve is built-in to Emacs; there are also alternatives such as request.el.

5

The w3 mode can do this with the w3-source-document-at-point command which by default is bound to s.

You could also use M-! and invoke curl.

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.