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

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

Re: Retrieve a web page into buffer and insert some text into it.


From: ken
Subject: Re: Retrieve a web page into buffer and insert some text into it.
Date: Wed, 28 Jul 2010 19:46:37 -0400
User-agent: Thunderbird 2.0.0.24 (X11/20100721)

Lennart suggested I use a different defun, url-copy-file.  I tried that
instead, but it didn't work.  But then I went back to my original code,
moved a single parenthesis and... it worked... mostly.  Here's the code:

------------------------ start ---------------------------
load url.el

(defun www-edit-web-page (url)
  "Retrieve web page and load into new buffer for editing.
Automatically insert after <body> tag URL, appropriately html-tagged URL."
  (interactive "sLoad URL: ")
  (with-temp-buffer (url-retrieve url 'edit-web-page)))


(defun edit-web-page (status)
      "Switch to the buffer returned by `url-retreive'.
    The buffer should contain the web page sent by the server."
      (switch-to-buffer (current-buffer))
    (goto-char 0)
    (re-search-forward "<body.*>" nil t) ;go to end of <body ...> tag.
    ;insert URL into page
    (insert "\n<p>From: <a href=\"" url "\">" url "</a>\n </p>\n\n"))

------------------------ ende ---------------------------

This properly fetches the web page and loads it into a new, unsaved
buffer (exactly what I want), but the last line in the second defun
doesn't execute.  The error messages are telling me that edit-web-page
doesn't know the value of "url".  So how do I pass this variable-- with
its assignment from www-edit-web-page to edit-web-page?  (I have a
guess, but i'm more a C/bash/blah/blah/blah guy, so elisp is a bit
mysterious.)





reply via email to

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