[Date Prev][Date Next][Thread Prev][][Date Index][Thread Index]

Re: Patch to emacs-w3m



>>>>> In [emacs-w3m : No.05922]
>>>>>	Paul Kinnucan <paulk@mathworks.com> wrote:

> As promised, here is a version of w3m-decode-entity-string
> that handles strings with multiple embedded entities without
> creating a temporary buffer.

> (defun w3m-decode-entity-string (encoded-str)
>   "Decode entities in the string STR."

Thanks for the new code.  However, TSUCHIYA Masatoshi also
brought up a similar code yesterday in the emacs-w3m mailing
list.  It will probably be more efficient since there are less
concat's than yours.  Here it is:

(defun w3m-decode-entities-string (str)
  "Decode entities in the string STR."
  (save-match-data
    (let ((pos 0) (buf))
      (while (string-match w3m-entity-regexp str pos)
	(setq buf (cons (or (w3m-entity-value (match-string 1 str)
					      (match-beginning 2))
			    (match-string 0 str))
			(cons (substring str pos (match-beginning 0))
			      buf))
	      pos (match-end 0)))
      (if buf
	  (apply 'concat
		 (nreverse (if (< pos (length str))
			       (cons (substring str pos) buf)
			     buf)))
	str))))

Anyway, we aren't immediately going to implement the new code
now.  Since there are some bugs (see below) and we should fix
them, putting similar codes on two places (w3m-decode-entities
and w3m-decode-entities-string) may confuse the development.

(w3m-decode-entities-string "&ltx;")
 => "&ltx;"

Regards,
-- 
Katsumi Yamaoka <yamaoka@jpl.org>