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

Re: emacs-lynx



From: jidanni@xxxxxxxxxxx said
Subject: [emacs-w3m:10602] Re: emacs-lynx
Message-ID: <87priq4os6.fsf@xxxxxxxxxxx>
Date: Wed, 14 Jan 2009 10:14:33 +0800

> Well for lazy me maybe waiting for the authors to give a way to
> disable something (tables) might be shorter than waiting for a way to
> enable something.

I think up a crazy idea as the following code.
But this is a very dirty method. Uum...

;; in your ~/.emacs-w3m
(add-hook 'w3m-mode-hook
	  (lambda ()
	    (define-key w3m-mode-map "\M-t" 'w3m-redisplay-invert-render-table)
	    (define-key w3m-mode-map "\M-T" 'w3m-redisplay-toggle-render-table)))

(defvar w3m-no-render-table nil
  "*If non-nil, do not render any table tag.")

(defun w3m-redisplay-invert-render-table (&optional arg)
  (interactive "P")
  (let ((w3m-no-render-table (not w3m-no-render-table)))
    (w3m-redisplay-this-page arg)
    (message (format "Display with%s rendering table"
		     (if w3m-no-render-table " NO" "")))))

(defun w3m-redisplay-toggle-render-table (&optional arg)
  (interactive "P")
  (setq w3m-no-render-table (not w3m-no-render-table))
  (w3m-redisplay-this-page arg)
  (message (format "Change redering table to %s"
		   (if w3m-no-render-table "nil" "TRUE"))))

(eval-after-load "w3m-filter"
  '(nconc w3m-filter-rules '((".*" w3m-filter-no-render-table))))

(defun w3m-filter-no-render-table (&optional url)
  (when w3m-no-render-table
    (let ((case-fold-search t))
      (goto-char (point-min))
      (while (re-search-forward "</?\\(table\\)[ \t\r\f\n>]" nil t)
	(goto-char (match-beginning 1))
	(insert "NO_"))
      (goto-char (point-min))
      (while (re-search-forward "<\\(tr\\)[ \t\r\f\n>]" nil t)
	(goto-char (match-beginning 1))
	(insert "NO_")
	(goto-char (match-beginning 0))
	(insert "<br>"))
      (goto-char (point-min))
      (while (re-search-forward "</\\(tr\\)>" nil t)
	(goto-char (match-beginning 1))
	(insert "NO_")))))

-- 
Hideyuki SHIRAI (mailto:shirai@xxxxxxxxxxx)
Sorry Japanese only.

試してみると、確かに特定のブログとか読みやすくなりますね。

ここに付けた一時的な表示(M-t)ではなくて、"Cc" などと同じ扱いで
"Cr" とかいうキーバインドでテーブルレンダリング抹消をできるよう
にしてその URL を覚えておければ便利そうです。

だけど、一番の問題は、テーブルのレンダリングって
w3m/doc/STORY.html の一番最初に

  ・W3m can render tables.

って書いてあるってことなんだよなぁ。。。

当然 <NO_table> というあまりに汚いやり方も大問題ですが。