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

Re: too many filters



From: jidanni@xxxxxxxxxxx said
Subject: [emacs-w3m:11059] too many filters
Message-ID: <87pr9ubxhm.fsf_-_@xxxxxxxxxxx>
Date: Mon, 14 Sep 2009 00:49:57 +0800

>>> But sooner or later one will have to face the facts and update the
>>> underlying w3m program

OK.

> E.g., with all the filters I've acquired in
> http://jidanni.org/comp/configuration/.emacs-w3m
> rendering pages like
> http://taipeitravel.net/user/Article.aspx?Lang=1&SNo=04000275
> http://taipeitravel.net/user/Article.aspx?Lang=1&SNo=04002202
> takes ages. What's worse is
> 'C-c C-k runs the command w3m-process-stop'
> does not stop anything... they are too CPU intensive to stop!
> However, doing (setq w3m-use-filter nil) makes rendering those pages a
> breeze, proving that I've already got too many filters.

Sorry, my filter update.

(defun w3m-filter-unsupport-tags (url)
  (let ((case-fold-search t)
	pos)
    ;; <button
    (w3m-filter-replace-regexp url "<button[\r\t\n ]" "<input ")
    ;; <option disabled
    (goto-char (point-min))
    (while (re-search-forward "<option\\([^>]+\\)disabled[^>]*>" nil t)
      (goto-char (match-end 0))
      (insert "[disabled] "))
    ;; <input type="search" name="search" />
    (goto-char (point-min))
    (while (re-search-forward "<input [^>]*type=\"\\(search\\)\"[^>]*>" nil t)
      (goto-char (match-beginning 1))
      (delete-region (match-beginning 1) (match-end 1))
      (insert "text"))
    ;; <dfn id="xxxx">
    (goto-char (point-min))
    (while (re-search-forward "<dfn[^>]+id=\\([^>\r\t\n ]+\\)" nil t)
      (replace-match "<a id=\\1" nil nil)
      (unless (looking-at ">")
	(setq pos (point))
	(when (search-forward ">" nil t)
	  (delete-region pos (match-beginning 0))))
      (when (search-forward "</dfn>" nil t)
	(replace-match "</a>" nil nil)))
    ;; <span id="xxxx">
    (goto-char (point-min))
    (while (re-search-forward "<span[^>]+id=\\([^>\r\t\n ]+\\)" nil t)
      (replace-match "<a id=\\1" nil nil)
      (unless (looking-at ">")
	(setq pos (point))
	(when (search-forward ">" nil t)
	  (delete-region pos (match-beginning 0))))
      (when (search-forward "</span>" nil t)
	(replace-match "</a>" nil nil)))))

-- 
Hideyuki SHIRAI (mailto:shirai@xxxxxxxxxxx)