[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: pages with many images slow
- From: Naohiro Aota <naota@xxxxxxxxx>
- Date: Sat, 31 Jan 2009 04:11:51 +0900
- X-ml-name: emacs-w3m
- X-mail-count: 10654
- References: <87hc4d1yx4.fsf@xxxxxxxxxxx> <871vutozvb.fsf@xxxxxxxxxxxxxxxx> <b4mvds2bvpw.fsf@xxxxxxx> <87mydelbxf.fsf@xxxxxxxxxxxxxxxx> <b4mr62qigu1.fsf@xxxxxxx> <87ocxuja5o.fsf@xxxxxxxxxxxxxxxx> <b4mskn57gnj.fsf@xxxxxxx>
Katsumi Yamaoka <yamaoka@xxxxxxx> writes:
>>>>>> In [emacs-w3m : No.10639] Naohiro Aota wrote:
>> Katsumi Yamaoka <yamaoka@xxxxxxx> writes:
> BTW, when pressing the T key, the order of images re-displaying
> in a page (containing many images, like asahi.com) differs from
> that of the unpatched w3m.el. While the unpatched w3m.el seems
> to start re-displaying of images from the top of a page, the
> patched one seems to do it from the bottom of a page. It might
> give a user an impression that emacs-w3m does nothing for a while
> (if she/he is looking at the top of a page). Though it might be
> hard to achieve, it will be better to start it from images that
> are currently visible in a page.
> (できない相談かもしれませんが、T を押したときに、現在見えている
> 画像から再表示を始めるのが良いかもしれません。)
まだ、ちょっと実験的ですが…
w3m-idle-images-show-list に cons しているものと同じものを画像のところに
w3m-idle-image-item という text-property として置いておきます。
w3m-idle-images-show() でのプロセス起動の選択を以下のようにします。
- w3m の buffer 上にいれば
-- (point) に w3m-idle-image-item があればそれを
-- なければ、一番近くの w3m-idle-image-item を
- buffer 上にない、あるいは前項で選択できていなければ、今まで通り
w3m-idle-images-show-list の lastを
そして選択されたもの (item) を w3m-idle-images-show-list から、消して
text-property も消しておくとカーソルの近くの画像(≒ 現在見えている画像)
から順番に表示するようになる…はずです。
;; 一応、今のコードでも last からとっているのでぺージの先頭から表示する
;; はずなのだけどな
--
青田
Index: w3m.el
===================================================================
RCS file: /storage/cvsroot/emacs-w3m/w3m.el,v
retrieving revision 1.1414
diff -u -r1.1414 w3m.el
--- w3m.el 27 Jan 2009 04:33:33 -0000 1.1414
+++ w3m.el 30 Jan 2009 18:55:28 -0000
@@ -3623,18 +3623,44 @@
(defvar w3m-idle-images-show-interval 1)
(defun w3m-idle-images-show ()
- (let ((repeat t))
+ (let ((repeat t)
+ (onbuffer (member (current-buffer) (w3m-list-buffers)))
+ (current (get-text-property (point) 'w3m-idle-image-item)))
(while (and repeat w3m-idle-images-show-list)
- (setq w3m-idle-images-show-list (nreverse w3m-idle-images-show-list))
- (let* ((item (car w3m-idle-images-show-list))
+ (let* ((item (or (and onbuffer
+ (or current
+ (let* ((prev (previous-single-property-change
+ (point) 'w3m-idle-image-item))
+ (next (next-single-property-change
+ (point) 'w3m-idle-image-item))
+ (prev-diff (and prev (abs (- (point) prev))))
+ (next-diff (and next (abs (- (point) next)))))
+ (cond
+ ((and prev next)
+ (get-text-property
+ (if (< prev-diff next-diff) prev next)
+ 'w3m-idle-image-item))
+ (prev
+ (get-text-property prev
+ 'w3m-idle-image-item))
+ (next
+ (get-text-property next
+ 'w3m-idle-image-item))
+ (t nil)))))
+ (car (last w3m-idle-images-show-list))))
(start (nth 0 item))
(end (nth 1 item))
(iurl (nth 2 item))
(url (nth 3 item))
(no-cache (nth 4 item))
(size (nth 5 item)))
+ (setq w3m-idle-images-show-list
+ (delete item w3m-idle-images-show-list))
(when (buffer-live-p (marker-buffer start))
(with-current-buffer (marker-buffer start)
+ (let (buffer-read-only)
+ (remove-text-properties start end '(w3m-idle-image-item))
+ (set-buffer-modified-p nil))
(w3m-process-with-null-handler
(lexical-let ((start start)
(end end)
@@ -3661,8 +3687,6 @@
(set-buffer-modified-p nil))
(set-marker start nil)
(set-marker end nil))))))))
- (setq w3m-idle-images-show-list
- (nreverse (cdr w3m-idle-images-show-list)))
(setq repeat (sit-for 0.1 nil)))
(unless w3m-idle-images-show-list
(cancel-timer w3m-idle-images-show-timer)
@@ -3769,19 +3793,22 @@
(set-buffer-modified-p nil)))
(set-marker start nil)
(set-marker end nil))))
- (setq w3m-idle-images-show-list
- (cons (list (set-marker (make-marker) start)
+ (let ((item (list (set-marker (make-marker) start)
(set-marker (make-marker) end)
(w3m-url-transfer-encode-string iurl)
w3m-current-url
no-cache
- size)
- w3m-idle-images-show-list))
- (unless w3m-idle-images-show-timer
- (setq w3m-idle-images-show-timer
- (run-with-idle-timer w3m-idle-images-show-interval
- t
- 'w3m-idle-images-show))))))))
+ size)))
+ (setq w3m-idle-images-show-list
+ (cons item w3m-idle-images-show-list))
+ (w3m-add-text-properties
+ start end
+ `(w3m-idle-image-item ,item))
+ (unless w3m-idle-images-show-timer
+ (setq w3m-idle-images-show-timer
+ (run-with-idle-timer w3m-idle-images-show-interval
+ t
+ 'w3m-idle-images-show)))))))))
;; Remove.
(while (< (setq start (if (w3m-image end)
end
@@ -3809,7 +3836,9 @@
(delete-region start end)
(setq end start))
(t (w3m-remove-image start end)))
- (w3m-add-text-properties start end '(w3m-image-status off))))
+ (w3m-add-text-properties start end
+ '(w3m-image-status off
+ w3m-idle-image-item nil))))
(set-buffer-modified-p nil)))))
(defun w3m-toggle-inline-image (&optional force no-cache)