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

Re: the w3m keys should work even if on a gnus header

In [emacs-w3m : No.11702] jidanni@xxxxxxxxxxx wrote:
> When reading in gnus, as we know, the w3m keys like
>} w3m-next-image
> only work when the cursor is below the [1. text/html],


> Wouldn't it be neat if they worked no matter where the cursor was?

I hesitate to do that since it will mask new Gnus' features someone
may add in the future.  So, I think it should be done at one's risk;
like this:

(defadvice mm-inline-text-html-render-with-w3m (after add-some-w3m-keys
  "Make some emacs-w3m keys be available in the whole of article buffer."
  (when (and mm-inline-text-html-with-w3m-keymap
	     (boundp 'w3m-minor-mode-map)
    (let ((inhibit-read-only t)
	  (keymap (make-sparse-keymap))
	  start end)
      (define-key keymap "}" 'w3m-next-image)
      (define-key keymap "{" 'w3m-previous-image)
	(setq start (point-min))
	(while (setq start (text-property-any start (point-max) 'keymap nil))
	  (setq end (text-property-not-all start (point-max) 'keymap nil))
	  (put-text-property start end 'keymap keymap))))))