unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* visiting remote files on webserver
@ 2014-08-17 12:58 lee
  2014-08-17 16:24 ` saint
  0 siblings, 1 reply; 10+ messages in thread
From: lee @ 2014-08-17 12:58 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,

isn't something like the following already available by default:


(defun my-curl-find-file ()
  "Use curl to retrieve something and create a buffer to display what
was retrieved.

What to use as source and the name of a new buffer to insert the
output of curl into are being read from the minibuffer."
  (interactive)
  (let ((source (read-from-minibuffer "Retrieve: "))
	(dest-buffer-name (read-from-minibuffer "Into buffer: ")))
    (unless (or (string-equal "" source)
		(string-equal "" dest-buffer-name))
      (switch-to-buffer dest-buffer-name)
      (call-process "curl" nil t t "-sS" source))))


Since I couldn't find anything like that as part of emacs, I came up
with the above.  It works fine, though it seems unlikely that this isn't
already implemented.


-- 
Knowledge is volatile and fluid.  Software is power.



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: visiting remote files on webserver
  2014-08-17 12:58 visiting remote files on webserver lee
@ 2014-08-17 16:24 ` saint
  2014-08-17 20:45   ` lee
  0 siblings, 1 reply; 10+ messages in thread
From: saint @ 2014-08-17 16:24 UTC (permalink / raw)
  To: lee; +Cc: help-gnu-emacs

lee writes:
 > Hi,
 > 
 > isn't something like the following already available by default:
 > 
 > 
 > (defun my-curl-find-file ()
 >   "Use curl to retrieve something and create a buffer to display what
 > was retrieved.

What about:

(find-file "/scp:user@machie:/path/to/file")

it is possible to use it interactively

C-x C-f /scp:user@machine:/path/to/file

-- 
 /\           ___                                    Ubuntu: ancient
/___/\_|_|\_|__|___Gian Uberto Lauri_____               African word
  //--\| | \|  |   Integralista GNUslamico            meaning "I can
\/                 coltivatore diretto di software       not install
     già sistemista a tempo (altrui) perso...                Debian"

Warning: gnome-config-daemon considered more dangerous than GOTO



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: visiting remote files on webserver
  2014-08-17 16:24 ` saint
@ 2014-08-17 20:45   ` lee
  2014-08-18  0:26     ` Eric Abrahamsen
  0 siblings, 1 reply; 10+ messages in thread
From: lee @ 2014-08-17 20:45 UTC (permalink / raw)
  To: help-gnu-emacs

saint@eng.it writes:

> lee writes:
>  > Hi,
>  > 
>  > isn't something like the following already available by default:
>  > 
>  > 
>  > (defun my-curl-find-file ()
>  >   "Use curl to retrieve something and create a buffer to display what
>  > was retrieved.
>
> What about:
>
> (find-file "/scp:user@machie:/path/to/file")
>
> it is possible to use it interactively
>
> C-x C-f /scp:user@machine:/path/to/file

That requires to be able to log in to the remote host.  In this
particular case, I wanted to get a script from some web server I don't
have any special access to.  I could have downloaded and saved and
visited it, but why not load it directly into a buffer.


-- 
Knowledge is volatile and fluid.  Software is power.



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: visiting remote files on webserver
  2014-08-17 20:45   ` lee
@ 2014-08-18  0:26     ` Eric Abrahamsen
  2014-08-18 18:30       ` lee
  0 siblings, 1 reply; 10+ messages in thread
From: Eric Abrahamsen @ 2014-08-18  0:26 UTC (permalink / raw)
  To: help-gnu-emacs

lee <lee@yun.yagibdah.de> writes:

> saint@eng.it writes:
>
>> lee writes:
>>  > Hi,
>>  > 
>>  > isn't something like the following already available by default:
>>  > 
>>  > 
>>  > (defun my-curl-find-file ()
>>  >   "Use curl to retrieve something and create a buffer to display what
>>  > was retrieved.
>>
>> What about:
>>
>> (find-file "/scp:user@machie:/path/to/file")
>>
>> it is possible to use it interactively
>>
>> C-x C-f /scp:user@machine:/path/to/file
>
> That requires to be able to log in to the remote host.  In this
> particular case, I wanted to get a script from some web server I don't
> have any special access to.  I could have downloaded and saved and
> visited it, but why not load it directly into a buffer.

The url package does this, you could start with url-retrieve and
url-retrieve-synchronously.

E




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: visiting remote files on webserver
  2014-08-18  0:26     ` Eric Abrahamsen
@ 2014-08-18 18:30       ` lee
  2014-08-19  1:45         ` Eric Abrahamsen
  0 siblings, 1 reply; 10+ messages in thread
From: lee @ 2014-08-18 18:30 UTC (permalink / raw)
  To: help-gnu-emacs

Eric Abrahamsen <eric@ericabrahamsen.net> writes:

> lee <lee@yun.yagibdah.de> writes:
>
>> saint@eng.it writes:
>>
>>> lee writes:
>>>  > Hi,
>>>  > 
>>>  > isn't something like the following already available by default:
>>>  > 
>>>  > 
>>>  > (defun my-curl-find-file ()
>>>  >   "Use curl to retrieve something and create a buffer to display what
>>>  > was retrieved.
>>>
>>> What about:
>>>
>>> (find-file "/scp:user@machie:/path/to/file")
>>>
>>> it is possible to use it interactively
>>>
>>> C-x C-f /scp:user@machine:/path/to/file
>>
>> That requires to be able to log in to the remote host.  In this
>> particular case, I wanted to get a script from some web server I don't
>> have any special access to.  I could have downloaded and saved and
>> visited it, but why not load it directly into a buffer.
>
> The url package does this, you could start with url-retrieve and
> url-retrieve-synchronously.

Hm, yes, I thought it did, and there are a number of url-.* functions
available, like url-handler-mode.  There aren't any to retrieve an url,
though.

Is the url package part of emacs, or do I need to install it?


-- 
GNU Emacs 24.4.50.2 (x86_64-unknown-linux-gnu, X toolkit, Xaw3d scroll bars)
 of 2014-08-17 on yun.yagibdah.de



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: visiting remote files on webserver
  2014-08-18 18:30       ` lee
@ 2014-08-19  1:45         ` Eric Abrahamsen
  2014-08-21 19:32           ` lee
  0 siblings, 1 reply; 10+ messages in thread
From: Eric Abrahamsen @ 2014-08-19  1:45 UTC (permalink / raw)
  To: help-gnu-emacs

lee <lee@yun.yagibdah.de> writes:

> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>
>> lee <lee@yun.yagibdah.de> writes:
>>
>>> saint@eng.it writes:
>>>
>>>> lee writes:
>>>>  > Hi,
>>>>  > 
>>>>  > isn't something like the following already available by default:
>>>>  > 
>>>>  > 
>>>>  > (defun my-curl-find-file ()
>>>>  >   "Use curl to retrieve something and create a buffer to display what
>>>>  > was retrieved.
>>>>
>>>> What about:
>>>>
>>>> (find-file "/scp:user@machie:/path/to/file")
>>>>
>>>> it is possible to use it interactively
>>>>
>>>> C-x C-f /scp:user@machine:/path/to/file
>>>
>>> That requires to be able to log in to the remote host.  In this
>>> particular case, I wanted to get a script from some web server I don't
>>> have any special access to.  I could have downloaded and saved and
>>> visited it, but why not load it directly into a buffer.
>>
>> The url package does this, you could start with url-retrieve and
>> url-retrieve-synchronously.
>
> Hm, yes, I thought it did, and there are a number of url-.* functions
> available, like url-handler-mode.  There aren't any to retrieve an url,
> though.
>
> Is the url package part of emacs, or do I need to install it?

I'm using emacs 24.4 (dev version) and it's in lisp/url/url.el.
Everything's autoloaded properly, so url-retrieve is available from
startup. I know nothing about the history of this package -- what's your
emacs version?

Eric




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: visiting remote files on webserver
  2014-08-19  1:45         ` Eric Abrahamsen
@ 2014-08-21 19:32           ` lee
  2014-08-22  1:16             ` Eric Abrahamsen
                               ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: lee @ 2014-08-21 19:32 UTC (permalink / raw)
  To: help-gnu-emacs

Eric Abrahamsen <eric@ericabrahamsen.net> writes:

> lee <lee@yun.yagibdah.de> writes:
>>>> In this particular case, I wanted to get a script from some web
>>>> server I don't have any special access to.  I could have downloaded
>>>> and saved and visited it, but why not load it directly into a
>>>> buffer.
>>>
>>> The url package does this, you could start with url-retrieve and
>>> url-retrieve-synchronously.
>>
>> Hm, yes, I thought it did, and there are a number of url-.* functions
>> available, like url-handler-mode.  There aren't any to retrieve an url,
>> though.
>>
>> Is the url package part of emacs, or do I need to install it?
>
> I'm using emacs 24.4 (dev version) and it's in lisp/url/url.el.

Hm, I have:


[~/inst/emacs/emacs-git/emacs/lisp/url] find . -type f -print0 | xargs -0 grep -i "defun url-retrieve"
./url.el:(defun url-retrieve (url callback &optional cbargs silent inhibit-cookies)
./url.el:(defun url-retrieve-internal (url callback cbargs &optional silent
./url.el:(defun url-retrieve-synchronously (url &optional silent inhibit-cookies)


Yet when I try M-x url-retrieve, there is no such funktion.

> Everything's autoloaded properly, so url-retrieve is available from
> startup. I know nothing about the history of this package -- what's your
> emacs version?

Please see below; I have gnus put version info into the signature for
the emacs.* groups.  I compiled from the git repo from which I updated
only a couple days ago (and it still seems to be a repo I'm not supposed
to use).

I tried (require 'url) in ~/.emacs, and that doesn't make a difference.
I'll have to look into it more closely on the weekend ...  I suppose it
should just be available.

The first mentioning of url-retrieve in git log is in commit
40c5a1bd1b125e9768aa223e80d0ae32e33a184b from Mon Apr 12 20:50:16 2004
+0000, authored by Stefan Monnier.  So it has over 10 years of history.


-- 
GNU Emacs 24.4.50.2 (x86_64-unknown-linux-gnu, X toolkit, Xaw3d scroll bars)
 of 2014-08-17 on yun.yagibdah.de



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: visiting remote files on webserver
  2014-08-21 19:32           ` lee
@ 2014-08-22  1:16             ` Eric Abrahamsen
  2014-08-22  3:30             ` Stefan Monnier
  2014-08-22 12:19             ` ken
  2 siblings, 0 replies; 10+ messages in thread
From: Eric Abrahamsen @ 2014-08-22  1:16 UTC (permalink / raw)
  To: help-gnu-emacs

lee <lee@yun.yagibdah.de> writes:

> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>
>> lee <lee@yun.yagibdah.de> writes:
>>>>> In this particular case, I wanted to get a script from some web
>>>>> server I don't have any special access to.  I could have downloaded
>>>>> and saved and visited it, but why not load it directly into a
>>>>> buffer.
>>>>
>>>> The url package does this, you could start with url-retrieve and
>>>> url-retrieve-synchronously.
>>>
>>> Hm, yes, I thought it did, and there are a number of url-.* functions
>>> available, like url-handler-mode.  There aren't any to retrieve an url,
>>> though.
>>>
>>> Is the url package part of emacs, or do I need to install it?
>>
>> I'm using emacs 24.4 (dev version) and it's in lisp/url/url.el.
>
> Hm, I have:
>
>
> [~/inst/emacs/emacs-git/emacs/lisp/url] find . -type f -print0 | xargs -0 grep -i "defun url-retrieve"
> ./url.el:(defun url-retrieve (url callback &optional cbargs silent inhibit-cookies)
> ./url.el:(defun url-retrieve-internal (url callback cbargs &optional silent
> ./url.el:(defun url-retrieve-synchronously (url &optional silent inhibit-cookies)
>
>
> Yet when I try M-x url-retrieve, there is no such funktion.
>
>> Everything's autoloaded properly, so url-retrieve is available from
>> startup. I know nothing about the history of this package -- what's your
>> emacs version?
>
> Please see below; I have gnus put version info into the signature for
> the emacs.* groups.  I compiled from the git repo from which I updated
> only a couple days ago (and it still seems to be a repo I'm not supposed
> to use).
>
> I tried (require 'url) in ~/.emacs, and that doesn't make a difference.
> I'll have to look into it more closely on the weekend ...  I suppose it
> should just be available.
>
> The first mentioning of url-retrieve in git log is in commit
> 40c5a1bd1b125e9768aa223e80d0ae32e33a184b from Mon Apr 12 20:50:16 2004
> +0000, authored by Stefan Monnier.  So it has over 10 years of history.

Yup, looks pretty weird -- particularly that you can require 'url and it
still doesn't work...




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: visiting remote files on webserver
  2014-08-21 19:32           ` lee
  2014-08-22  1:16             ` Eric Abrahamsen
@ 2014-08-22  3:30             ` Stefan Monnier
  2014-08-22 12:19             ` ken
  2 siblings, 0 replies; 10+ messages in thread
From: Stefan Monnier @ 2014-08-22  3:30 UTC (permalink / raw)
  To: help-gnu-emacs

> Yet when I try M-x url-retrieve, there is no such funktion.

`url-retrieve' is a *function*, not a *command*.


        Stefan




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: visiting remote files on webserver
  2014-08-21 19:32           ` lee
  2014-08-22  1:16             ` Eric Abrahamsen
  2014-08-22  3:30             ` Stefan Monnier
@ 2014-08-22 12:19             ` ken
  2 siblings, 0 replies; 10+ messages in thread
From: ken @ 2014-08-22 12:19 UTC (permalink / raw)
  To: help-gnu-emacs

On 08/21/2014 03:32 PM lee wrote:
> lee<lee@yun.yagibdah.de>  writes:
>>>> >>>>In this particular case, I wanted to get a script from some web
>>>> >>>>server I don't have any special access to.  I could have downloaded
>>>> >>>>and saved and visited it, but why not load it directly into a
>>>> >>>>buffer.

With considerable help from this list years ago I wrote the below.  It 
worked for a long time, until I upgraded emacs.  It did what you want, 
plus a little bit more which can easily be edited out.

=======================================================
;url-fetch-web-page
;From within emacs, download & locally edit a remote web page.
;Copyright (c) 2010, Kenneth Fisler, Cleveland, Ohio, USA.
;This program is free software; you can redistribute it and/or
;modify it under the terms of the GNU General Public License
;as published by the Free Software Foundation; either version 2
;of the License, or (at your option) any later version.
;
;This program is distributed in the hope that it will be useful,
;but WITHOUT ANY WARRANTY; without even the implied warranty of
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;GNU General Public License for more details.
;
;You should have received a copy of the GNU General Public
;License along with this program; if not, write to the Free
;Software Foundation, Inc., 59 Temple Place, Suite 330,
;Boston, MA  02111-1307  USA


;Using the url.el library, so probably need to load it.
(require 'url)

(defun url-fetch-web-page (url)
   "Retrieve minibuffer-specified web page, load into a new
buffer, then call another function for editing."
   (interactive "sLoad URL: ")
   (with-temp-buffer
     (url-retrieve url 'edit-web-page
     (list url 'status))))

(defun edit-web-page (&optional redirect url status)
       "Switch to the buffer returned by `url-retrieve'.
Automatically strip out all C-m characters and then insert after
html body tag the buffer's URL, appropriately html-tagged."
       (switch-to-buffer (current-buffer))
       ;; remove all instances of ^M (found in MS-created files).
       (goto-char 0)
       (perform-replace "
" "" nil nil nil t nil nil nil)
       (let ((case-fold-search t)) ;case-insensitive search
  (goto-char 0)   ;go to top of buffer
  (re-search-forward "<[\t\n ]*BODY[^>]*>" nil t)
  )
      ;insert URL into page
       (insert "\n\n<p>From: <a href=\""
        url "\">" url "</a>\n </p>\n\n"))

=========================================================

hth,
ken



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2014-08-22 12:19 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-17 12:58 visiting remote files on webserver lee
2014-08-17 16:24 ` saint
2014-08-17 20:45   ` lee
2014-08-18  0:26     ` Eric Abrahamsen
2014-08-18 18:30       ` lee
2014-08-19  1:45         ` Eric Abrahamsen
2014-08-21 19:32           ` lee
2014-08-22  1:16             ` Eric Abrahamsen
2014-08-22  3:30             ` Stefan Monnier
2014-08-22 12:19             ` ken

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).