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

Re: jde + emacs-w3m problem

Katsumi Yamaoka writes:
 > I'm sorry to say that there is no person knowing VM well in the
 > emacs-w3m community.  Although Gnus, Wanderlust and Mew fully
 > support emacs-w3m.  If those who make the patch for VM appear,
 > we will highly appreciate.

Hi Katsumi,

I have succeeded in patching vm to work with emacs-w3m. It works
very well. I did have one problem, however, with emacs-w3m.
The function w3m-rendering-extract-title kept failing with
an argument out of range error when attempting to delete the
region containing the title. I believe the reason it fails
is that the match data for the title string is invalidated
by the subsequent call to w3m-decode-entities-string. This
should not happen because w3m-decode-entities-string uses
save-match-data to save and restore match data. However, it
does happen. The match data is not restored after the 
call to w3m-decode-entities-string. I fixed the problem by
the following change to w3m-rendering-extract-title: 

(defun w3m-rendering-extract-title ()
  "Extract the title from the half-dumped data in this buffer."
  (goto-char (point-min))
  (or (when (re-search-forward "<title_alt[ \t\n]+title=\"\\([^\"]+\\)\">"
			       nil t)
;;;;;;;;;;;;;;;;;;;;;;; OLD ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;	(prog1 (w3m-decode-entities-string (match-string 1)
;;	  (delete-region (match-beginning 0) (match-end 0))))

;;;;;;;;;;;;;;;;;;;;;;; NEW ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	(let* ((start (match-beginning 0))
	       (end (match-end 0))
	       (title (w3m-decode-entities-string (match-string 1))))
	   (delete-region start end)
      (when (and (stringp w3m-current-url)
		 (string-match "/\\([^/]+\\)/?\\'" w3m-current-url))
	(match-string 1 w3m-current-url))

With this small change, w3m-region renders vm mail buffers 
perfectly--at least on the few samples of HTML mail I've received
so far.