10

Is there some way to download and show a file from a URI/URL?

I now I can use wget and then open the downloaded file and I guess I could even try to write myself a small function to do this.

But most likely someone did before me so is there a function/package that will let me get a file from the internets (would be great if it did not save the file somewhere first) and open it in a new buffer?

Gracjan Polak
  • 1,082
  • 6
  • 21
Random Dev
  • 203
  • 3
  • 7

3 Answers3

17
M-x url-handler-mode
C-x C-f http://emacs.stackexchange.com/questions/21180/is-there-a-way-to-show-open-a-file-from-a-uri-url

This opens the HTML file of this stackexchange question in your Emacs.

Michael Albinus
  • 6,647
  • 14
  • 20
  • 1
    yes nice - is there a way to combine this into a single command so I don't have to change the mode of some random buffer first? – Random Dev Mar 23 '16 at 11:51
  • 4
    `url-handler-mode` is a *global minor mode*, not a major mode. Just put `(url-handler-mode 1)` into your init file. – phils Mar 23 '16 at 12:06
3

If you want the file "rendered", you can use the web browser eww - just do M-x eww RET url RET

asjo
  • 1,037
  • 8
  • 12
2

You can turn URLs in a buffer into clickable buttons with Emacs goto-address-mode minor mode. If the URL represents a web page, then you can get Emacs to browse that page by clicking on the URL button.

Turn this mode on/off with: M-x goto-address-mode

This works with Emacs running in Graphics mode and in terminal mode. A special key map is activated when point is over the URL button. The C-c RET key sequence is bound to goto-address-at-point which makes Emacs browse the web page.

It's also possible to add key binding to that special map. In my system I added keys to navigate to the next or previous URL and to copy he content of the file identified by the URL into a local temporary file and then visit it. To do that add a function to the goto-address-mode-hook that maps commands into the goto-address-highlight-keymap.

PRouleau
  • 744
  • 3
  • 10