From: filebat Mark <filebat.mark@gmail.com>
To: Teemu Likonen <tlikonen@iki.fi>
Cc: GNU Emacs List <help-gnu-emacs@gnu.org>
Subject: Re: Retrieve a web page into buffer and insert some text into it.
Date: Sat, 31 Jul 2010 10:05:22 +0800 [thread overview]
Message-ID: <AANLkTi=d2m9S-X2fPZf4whNjttF1dsS88TH4-OAaam1y@mail.gmail.com> (raw)
In-Reply-To: <87sk30sxlg.fsf@mithlond.arda>
[-- Attachment #1: Type: text/plain, Size: 1677 bytes --]
Thanks a lot, likonen for your suggestion.
Agree, (let ((case-fold-search t)) is much safer than override global
variable.
I need to do more homework for lisp programming. ^-^
Regards,
Denny
On 7/31/10, Teemu Likonen <tlikonen@iki.fi> wrote:
>
> * 2010-07-31 00:51 (+0800), filebat Mark wrote:
>
> > Does the below solve your problem?
>
>
> I don't know but I'll comment your code in general.
>
>
> > (defun match-web-body()
> > (interactive)
> > (setq case-fold-search t);;Make searches case insensitive
> > (goto-char 0)
> > (re-search-forward "\\(< *\n* *body\n* +fgcolor=\".*\" *\n*>\\)" nil t
> 1)
> > (setq match_str (match-string 1))
> > (message match_str)
> > )
>
>
> If you want to set case-fold-search or other state-changing variable for
> certain operation create a local binding for the variable, do not assign
> new value to the existing binding. In other words, do not do this:
>
>
> (setq case-fold-search t)
>
> (re-search-forward ...)
>
> Do this instead:
>
> (let ((case-fold-search t))
> (re-search-forward ...))
>
> Also, do not introduce new global variables in functions like you did
> here:
>
>
> > (setq match_str (match-string 1))
> > (message match_str)
>
>
> In that case there is no need for the variable at all. It could be
> written like this:
>
> (message "%s" (match-string 1))
>
> But even if you needed a variable you shouldn't introduce it with SETQ
> but create a local binding with LET:
>
> (let ((match-str (match-string 1)))
> (message "%s" match-str)
> ;; Plus other uses of the variable
> )
>
> In short, keep things local.
>
--
Thanks & Regards
Denny Zhang
[-- Attachment #2: Type: text/html, Size: 2215 bytes --]
prev parent reply other threads:[~2010-07-31 2:05 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-28 15:36 Retrieve a web page into buffer and insert some text into it ken
2010-07-28 15:46 ` Lennart Borgman
2010-07-28 23:46 ` ken
2010-07-29 15:22 ` filebat Mark
2010-07-29 20:01 ` ken
[not found] ` <AANLkTi=7Y3=H1CeY_OvKZWwZp4R1JwpJCJQ20OMHTEKu@mail.gmail.com>
2010-07-30 11:23 ` ken
2010-07-30 16:32 ` filebat Mark
2010-07-30 16:51 ` filebat Mark
2010-07-30 17:00 ` filebat Mark
2010-07-30 17:12 ` Teemu Likonen
2010-07-31 2:05 ` filebat Mark [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='AANLkTi=d2m9S-X2fPZf4whNjttF1dsS88TH4-OAaam1y@mail.gmail.com' \
--to=filebat.mark@gmail.com \
--cc=help-gnu-emacs@gnu.org \
--cc=tlikonen@iki.fi \
/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.