From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ken Newsgroups: gmane.emacs.help Subject: Re: Retrieve a web page into buffer and insert some text into it. Date: Fri, 30 Jul 2010 07:23:26 -0400 Message-ID: <4C52B62E.9060405@mousecar.com> References: <4C504E73.6050207@mousecar.com> <4C50C15D.6000808@mousecar.com> <4C51DE14.2060102@mousecar.com> Reply-To: gebser@mousecar.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1280489101 13446 80.91.229.12 (30 Jul 2010 11:25:01 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 30 Jul 2010 11:25:01 +0000 (UTC) To: GNU Emacs List Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Jul 30 13:24:57 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 1Oenhw-0002Qy-JG for geh-help-gnu-emacs@m.gmane.org; Fri, 30 Jul 2010 13:24:56 +0200 Original-Received: from localhost ([127.0.0.1]:60782 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oenhw-0002IX-1P for geh-help-gnu-emacs@m.gmane.org; Fri, 30 Jul 2010 07:24:56 -0400 Original-Received: from [140.186.70.92] (port=55663 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OenhL-0002Gs-4Q for help-gnu-emacs@gnu.org; Fri, 30 Jul 2010 07:24:20 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OenhJ-0000V2-PA for help-gnu-emacs@gnu.org; Fri, 30 Jul 2010 07:24:18 -0400 Original-Received: from mout.perfora.net ([74.208.4.195]:53021) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OenhJ-0000Uu-KA for help-gnu-emacs@gnu.org; Fri, 30 Jul 2010 07:24:17 -0400 Original-Received: from dellap.mousecar.net (dsl093-011-017.cle1.dsl.speakeasy.net [66.93.11.17]) by mrelay.perfora.net (node=mrus3) with ESMTP (Nemesis) id 0MY7Me-1ORcOw2xN2-00UyAy; Fri, 30 Jul 2010 07:24:14 -0400 User-Agent: Thunderbird 2.0.0.24 (X11/20100721) In-Reply-To: X-Enigmail-Version: 0.96.0 OpenPGP: id=5AD091E7 X-Provags-ID: V02:K0:DhdSklIRKySmR9m2dyU70+dEiRXFRIoOT08kb7RcF2q GRdK5NgnYDqPypzpeelPs5ep4/hsTL4afyG0oTg7vgnxzQ8YPs fgah6QQ0fFAtxNGW7RRMawRm0xF8DBKfhrodG+f18k0pJneCGo tIZWETZ6Vxn8rthBziZIW8b006SdncTb1pHB+nj8V420WO441N 2TLGEXLTF4/q758cD6fvyrKwWUWWQeADvp9qmoQuIA= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. 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:74352 Archived-At: Thanks, Denny. I got the args working right, so it's basically working. So now I'm on to another issue: the re-search-forward function. Again, it's a syntax thing. As the code suggests, I'm looking for the html opening body tag. That text could be as simple as "", but could also be: < BodY fgcolor="hazel" > I thought this would work: (re-search-forward "<\s*[bB][oO][dD][yY]\s.*>" nil t) but apparently "\s" is being treated as a literal and not as representing [whitespace]. Also, it doesn't seem that elisp has a function for doing a case-insensitive RE search. On 07/29/2010 10:37 PM filebat Mark wrote: > Hi Ken > > Yes, the parameter of CBARGS in url-retrieve function is confusing. > I also tried this, but it complains of "wrong number of arguments". > > Let's wait to see whether others have any comment. I will spend some > time, when I'm free. > > > On Fri, Jul 30, 2010 at 4:01 AM, ken > wrote: > > > On 07/29/2010 11:22 AM filebat Mark wrote: > > Hi Ken > > Hi, Denny. Thanks for replying > > > > Where do you set the value of url in the second function? > > It needs to be passed from the first defun, but I don't know the syntax > for doing that. The url-retrieve function is a little complex in terms > of its arguments. I think it's stumped even the experts on this list. > > > > One big enhancement shall be setting the coding system of the temp > > buffer, based on the charset of the html page. > > Thanks for bringing that up. Yeah, I followed that on your thread. I > might have to deal with that too. If, after I get the main part of my > code working how I want it, I find it's having that problem, I'll review > your emails (which I still have) and perhaps get back to you for > some tips. > > > > Regards, > > Denny > > Back at ya! > ken > > > > > > 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 > > > > > > > -- > Thanks & Regards > > Denny Zhang >