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

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



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.

Regards,
David
Index: w3m-proc.el
===================================================================
RCS file: /storage/cvsroot/emacs-w3m/w3m-proc.el,v
retrieving revision 1.68
diff -u -r1.68 w3m-proc.el
--- w3m-proc.el	17 Dec 2007 14:15:08 -0000	1.68
+++ w3m-proc.el	3 Dec 2008 21:28:17 -0000
@@ -342,7 +342,7 @@
     (let ((start (current-time)))
       (while (or (and (prog2
 			  (discard-input)
-			  (not (save-current-buffer (sit-for 1)))
+			  (not (save-current-buffer (sit-for 0.1)))
 			(discard-input))
 		      ;; Some input is detected but it may be a key
 		      ;; press event which should be ignored when the
@@ -531,6 +531,7 @@
     (unwind-protect
 	(if (buffer-name (process-buffer process))
 	    (with-current-buffer (process-buffer process)
+	      (accept-process-output process 1)
 	      (setq w3m-process-queue
 		    (delq w3m-process-object w3m-process-queue))
 	      (let ((exit-status (process-exit-status process))