From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: filebat Mark Newsgroups: gmane.emacs.help Subject: Re: Retrieve a web page into buffer and insert some text into it. Date: Thu, 29 Jul 2010 23:22:28 +0800 Message-ID: References: <4C504E73.6050207@mousecar.com> <4C50C15D.6000808@mousecar.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=0016e64cbfa26b5a01048c884d78 X-Trace: dough.gmane.org 1280418231 29190 80.91.229.12 (29 Jul 2010 15:43:51 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 29 Jul 2010 15:43:51 +0000 (UTC) To: GNU Emacs List , gebser@mousecar.com Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jul 29 17:43:49 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OeVGp-0004jd-Ov for geh-help-gnu-emacs@m.gmane.org; Thu, 29 Jul 2010 17:43:44 +0200 Original-Received: from localhost ([127.0.0.1]:47086 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OeUwu-0002H7-0K for geh-help-gnu-emacs@m.gmane.org; Thu, 29 Jul 2010 11:23:08 -0400 Original-Received: from [140.186.70.92] (port=44828 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OeUwO-0002Gb-Ij for help-gnu-emacs@gnu.org; Thu, 29 Jul 2010 11:22:38 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OeUwI-00062P-K1 for help-gnu-emacs@gnu.org; Thu, 29 Jul 2010 11:22:35 -0400 Original-Received: from mail-pz0-f41.google.com ([209.85.210.41]:38469) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OeUwI-00062C-Am for help-gnu-emacs@gnu.org; Thu, 29 Jul 2010 11:22:30 -0400 Original-Received: by pzk33 with SMTP id 33so273644pzk.0 for ; Thu, 29 Jul 2010 08:22:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type; bh=pzw6j4wEnzR76pKGXd8ebqkOxkEIcsUKAZ9mASrfvLg=; b=wyd0ABZZCnwmnVkG8KbUQVREoZayIoKoTFPBtZilx0ZexpWGNyxadbeZQkDlAjEx1N xLMvfnpeCLoHNZx8asNbdvM+YUal4KC0dNjmMyfBkra0ofhI3faiOlYh+DhAEZXvE+Fr NPmHW1DZ6xonKaM5PQxT4gub5gmG8osMRQOaI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=KWF0d3GTkKJ2i4dVSg/a8aPCHMT1kP4+nuUjIGVDXakvCIbcGGloY5lJzuRomEDLy9 FPs2D98RsJN62SsuzpZEiOc3KSDOZt3Gs8hhuUWj5jy7toYPvEqNYb8Voi1gPsQ3db+8 p3m1O2pmcjFD8muPrCIqQyIyu4D1XpsE5B+00= Original-Received: by 10.114.132.17 with SMTP id f17mr301632wad.223.1280416949163; Thu, 29 Jul 2010 08:22:29 -0700 (PDT) Original-Received: by 10.229.43.4 with HTTP; Thu, 29 Jul 2010 08:22:28 -0700 (PDT) In-Reply-To: <4C50C15D.6000808@mousecar.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:74338 Archived-At: --0016e64cbfa26b5a01048c884d78 Content-Type: text/plain; charset=ISO-8859-1 Hi Ken Where do you set the value of url in the second function? One big enhancement shall be setting the coding system of the temp buffer, based on the charset of the html page. Regards, Denny On Thu, Jul 29, 2010 at 7:46 AM, ken wrote: > 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 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 "" nil t) ;go to end of tag. > ;insert URL into page > (insert "\n

From: " url "\n

\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.) > > > > -- Thanks & Regards Denny Zhang --0016e64cbfa26b5a01048c884d78 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi Ken

Where do you set the value of url in the second function?
=
One big enhancement shall be setting the coding system of the temp buff= er, based on the charset of the html page.

Regards,
Denny

On Thu, Jul 29, 2010 at 7:46 AM, ken <gebser@mousecar.com= > wrote:
Lennart suggested I use a different defun, url-copy-file. =A0I tried that instead, but it didn't work. =A0But then I went back to my original cod= e,
moved a single parenthesis and... it worked... mostly. =A0Here's the co= de:

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

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


(defun edit-web-page (status)
=A0 =A0 =A0"Switch to the buffer returned by `url-retreive'.
=A0 =A0The buffer should contain the web page sent by the server." =A0 =A0 =A0(switch-to-buffer (current-buffer))
=A0 =A0(goto-char 0)
=A0 =A0(re-search-forward "<body.*>" nil t) ;go to end of = <body ...> tag.
=A0 =A0;insert URL into page
=A0 =A0(insert "\n<p>From: <a href= =3D\"" url "\">" url "</a>\n </p&= gt;\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. =A0The error messages are telling me that edit-web-pag= e
doesn't know the value of "url". =A0So how do I pass this var= iable-- with
its assignment from www-edit-web-page to edit-web-page? =A0(I have a
guess, but i'm more a C/bash/blah/blah/blah guy, so elisp is a bit
mysterious.)






--
Thanks & Regards
Denny Zhang

--0016e64cbfa26b5a01048c884d78--