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

Re: Reducing the sit-for time in w3m-process-wait-process

>>>>> In [emacs-w3m : No.10494] David Engster wrote:
> David Engster <deng@xxxxxxxxxxxxxxx> writes:
>> I'm using the encapsulate-images feature from the shimbun package, and I
>> noticed that when an article contains many images, it takes pretty long
>> for w3m to fetch them. It seems to me this time is almost entirely spend
>> on the '(sit-for 1)' in w3m-process-wait-process, while the actual w3m
>> process is already finished. When I change this to '(sit-for 0.1)',
>> fetching the images is much faster. It also seems to me that this speeds
>> up refreshing shimbun groups in general.

> To followup on this: I sometimes got parsing errors with '(sit-for
> 0.1)', because the buffer didn't contain the whole output from the w3m
> binary. However, I could fix this by using accept-process-output in the
> w3m sentinel. Now everything works without problems, and the reduced
> sit-for time makes working with emacs-w3m faster. Before, a w3m call
> would at least take one second, even when w3m just received a redirect
> or was fetching a small picture for a shimbun article. I attached the
> two-lines patch to this mail.

Great!  I verified that the patch makes shimbun fast beyond
recognition for fetching articles containing many images.  David,
could you provide the ChangeLog entry?

However, I found one problem.  The patch makes XEmacs 21.4 and
21.5 slow for fetching shimbuns.  The `accept-process-output'
line you added always seems to take one second in XEmacs,
whereas the `sit-for' line in which the time has been reduced
seems to make no difference.  I'm not sure how to solve it but
I'd like to install the patch very much :) since I usually use
Emacs, not XEmacs.  Any idea?  If no one comments, I'll install
it in the emacs-w3m CVS trunk with the modification as follows:
--- w3m-proc.el~	2007-12-17 21:51:40 +0000
+++ w3m-proc.el	2008-12-05 08:31:15 +0000
@@ -342,7 +342,7 @@
     (let ((start (current-time)))
       (while (or (and (prog2
-			  (not (save-current-buffer (sit-for 1)))
+			  (not (save-current-buffer (sit-for 0.1)))
 		      ;; Some input is detected but it may be a key
 		      ;; press event which should be ignored when the
@@ -531,6 +531,8 @@
 	(if (buffer-name (process-buffer process))
 	    (with-current-buffer (process-buffer process)
+	      (w3m-static-unless (featurep 'xemacs)
+		(accept-process-output process 1))
 	      (setq w3m-process-queue
 		    (delq w3m-process-object w3m-process-queue))
 	      (let ((exit-status (process-exit-status process))