[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: |
Teemu Likonen |
Subject: |
Re: Retrieve a web page into buffer and insert some text into it. |
Date: |
Fri, 30 Jul 2010 20:12:11 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.2.50 (gnu/linux) |
* 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.
- Retrieve a web page into buffer and insert some text into it., ken, 2010/07/28
- Re: Retrieve a web page into buffer and insert some text into it., Lennart Borgman, 2010/07/28
- Re: Retrieve a web page into buffer and insert some text into it., ken, 2010/07/28
- Re: Retrieve a web page into buffer and insert some text into it., filebat Mark, 2010/07/29
- Re: Retrieve a web page into buffer and insert some text into it., ken, 2010/07/29
- Message not available
- Re: Retrieve a web page into buffer and insert some text into it., ken, 2010/07/30
- Re: Retrieve a web page into buffer and insert some text into it., filebat Mark, 2010/07/30
- Re: Retrieve a web page into buffer and insert some text into it., filebat Mark, 2010/07/30
- Re: Retrieve a web page into buffer and insert some text into it., filebat Mark, 2010/07/30
- Re: Retrieve a web page into buffer and insert some text into it.,
Teemu Likonen <=
- Re: Retrieve a web page into buffer and insert some text into it., filebat Mark, 2010/07/30