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 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