From: ken <gebser@mousecar.com>
To: help-gnu-emacs@gnu.org
Subject: Re: visiting remote files on webserver
Date: Fri, 22 Aug 2014 08:19:45 -0400 [thread overview]
Message-ID: <53F73561.2030706@mousecar.com> (raw)
In-Reply-To: <871ts91vwn.fsf@yun.yagibdah.de>
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
prev parent reply other threads:[~2014-08-22 12:19 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53F73561.2030706@mousecar.com \
--to=gebser@mousecar.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.