help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: visiting remote files on webserver


From: ken
Subject: Re: visiting remote files on webserver
Date: Fri, 22 Aug 2014 08:19:45 -0400
User-agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.4.0

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]