From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.devel Subject: Re: Nested sit-for's Date: Fri, 18 Aug 2006 11:03:04 +0200 Message-ID: <44E58248.7020202@gmx.at> References: <87y7tp90i1.fsf@stupidchicken.com> <87hd0bjvoi.fsf@furball.mit.edu> <44E493E0.5000205@gmx.at> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------080201030904090604000207" X-Trace: sea.gmane.org 1155891916 1257 80.91.229.2 (18 Aug 2006 09:05:16 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 18 Aug 2006 09:05:16 +0000 (UTC) Cc: Chong Yidong , rms@gnu.org, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Aug 18 11:05:11 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GE0Hr-00005w-B4 for ged-emacs-devel@m.gmane.org; Fri, 18 Aug 2006 11:05:07 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GE0Hq-0006tD-JV for ged-emacs-devel@m.gmane.org; Fri, 18 Aug 2006 05:05:06 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GE0Gz-0006R8-CS for emacs-devel@gnu.org; Fri, 18 Aug 2006 05:04:13 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GE0Gy-0006PV-1C for emacs-devel@gnu.org; Fri, 18 Aug 2006 05:04:12 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GE0Gx-0006PB-9n for emacs-devel@gnu.org; Fri, 18 Aug 2006 05:04:11 -0400 Original-Received: from [213.165.64.20] (helo=mail.gmx.net) by monty-python.gnu.org with smtp (Exim 4.52) id 1GE0Nc-0005M9-HH for emacs-devel@gnu.org; Fri, 18 Aug 2006 05:11:05 -0400 Original-Received: (qmail invoked by alias); 18 Aug 2006 09:04:09 -0000 Original-Received: from N950P015.adsl.highway.telekom.at (EHLO [62.47.62.175]) [62.47.62.175] by mail.gmx.net (mp031) with SMTP; 18 Aug 2006 11:04:09 +0200 X-Authenticated: #14592706 User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: de-DE, de, en-us, en Original-To: "Kim F. Storm" In-Reply-To: X-Y-GMX-Trusted: 0 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:58483 Archived-At: This is a multi-part message in MIME format. --------------080201030904090604000207 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit > Is the pre-command-hook installed permanently, or only when jit-lock is > active? > > IMHO, using a permanently installed pre-command-hook is not acceptable, but > it may be ok if only used temporarily... > > But why is this needed at all? Just a first shot. Try the revision. --------------080201030904090604000207 Content-Type: text/plain; name="jit-lock.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="jit-lock.patch" *** jit-lock.el.~1.53.~ Tue Aug 15 10:00:50 2006 --- jit-lock.el Fri Aug 18 10:57:54 2006 *************** *** 386,399 **** ;; eagerly extend the refontified region with ;; jit-lock-after-change-extend-region-functions. (when (< start orig-start) ! (lexical-let ((start start) (orig-start orig-start) (buf (current-buffer))) (run-with-timer 0 nil (lambda () ! (with-buffer-prepared-for-jit-lock ! (put-text-property start orig-start ! 'fontified t buf)))))) ;; Find the start of the next chunk, if any. (setq start (text-property-any next end 'fontified nil)))))))) --- 386,400 ---- ;; eagerly extend the refontified region with ;; jit-lock-after-change-extend-region-functions. (when (< start orig-start) ! (lexical-let ((start start) (orig-start orig-start) (buf (current-buffer))) (run-with-timer 0 nil (lambda () ! (with-current-buffer buf ! (with-buffer-prepared-for-jit-lock ! (put-text-property start orig-start ! 'fontified t))))))) ;; Find the start of the next chunk, if any. (setq start (text-property-any next end 'fontified nil)))))))) *************** *** 402,408 **** ;;; Stealth fontification. (defsubst jit-lock-stealth-chunk-start (around) ! "Return the start of the next chunk to fontify around position AROUND.. Value is nil if there is nothing more to fontify." (if (zerop (buffer-size)) nil --- 403,409 ---- ;;; Stealth fontification. (defsubst jit-lock-stealth-chunk-start (around) ! "Return the start of the next chunk to fontify around position AROUND. Value is nil if there is nothing more to fontify." (if (zerop (buffer-size)) nil *************** *** 442,513 **** (t next)))) result)))) ! (defun jit-lock-stealth-fontify () "Fontify buffers stealthily. ! This functions is called after Emacs has been idle for `jit-lock-stealth-time' seconds." ! ;; I used to check `inhibit-read-only' here, but I can't remember why. -stef ! (unless (or executing-kbd-macro memory-full ! (window-minibuffer-p (selected-window))) ! (let ((buffers (buffer-list)) ! (outer-buffer (current-buffer)) minibuffer-auto-raise ! message-log-max) ! (with-local-quit ! (while (and buffers (not (input-pending-p))) ! (with-current-buffer (pop buffers) ! (when jit-lock-mode ! ;; This is funny. Calling sit-for with 3rd arg non-nil ! ;; so that it doesn't redisplay, internally calls ! ;; wait_reading_process_input also with a parameter ! ;; saying "don't redisplay." Since this function here ! ;; is called periodically, this effectively leads to ! ;; process output not being redisplayed at all because ! ;; redisplay_internal is never called. (That didn't ! ;; work in the old redisplay either.) So, we learn that ! ;; we mustn't call sit-for that way here. But then, we ! ;; have to be cautious not to call sit-for in a widened ! ;; buffer, since this could display hidden parts of that ! ;; buffer. This explains the seemingly weird use of ! ;; save-restriction/widen here. ! (with-temp-message (if jit-lock-stealth-verbose (concat "JIT stealth lock " (buffer-name))) ! ! ;; In the following code, the `sit-for' calls cause a ! ;; redisplay, so it's required that the ! ;; buffer-modified flag of a buffer that is displayed ! ;; has the right value---otherwise the mode line of ! ;; an unmodified buffer would show a `*'. ! (let (start ! (nice (or jit-lock-stealth-nice 0)) ! (point (point-min))) ! (while (and (setq start ! (jit-lock-stealth-chunk-start point)) ! ;; In case sit-for runs any timers, ! ;; give them the expected current buffer. ! (with-current-buffer outer-buffer ! (sit-for nice))) ! ! ;; fontify a block. ! (jit-lock-fontify-now start (+ start jit-lock-chunk-size)) ! ;; If stealth jit-locking is done backwards, this leads to ! ;; excessive O(n^2) refontification. -stef ! ;; (when (>= jit-lock-context-unfontify-pos start) ! ;; (setq jit-lock-context-unfontify-pos end)) ! ! ;; Wait a little if load is too high. ! (when (and jit-lock-stealth-load ! (> (car (load-average)) jit-lock-stealth-load)) ! ;; In case sit-for runs any timers, ! ;; give them the expected current buffer. ! (with-current-buffer outer-buffer ! (sit-for (or jit-lock-stealth-time 30)))))))))))))) ! ! ;;; Deferred fontification. --- 443,487 ---- (t next)))) result)))) + (defvar jit-lock-stealth-buffers nil + "List of buffers that should be fontified stealthily.") ! (defun jit-lock-stealth-fontify (&optional repeat) "Fontify buffers stealthily. ! This function is called repeatedly after Emacs has been idle for `jit-lock-stealth-time' seconds." ! (unless (or (input-pending-p) ! executing-kbd-macro memory-full ! (window-minibuffer-p (selected-window)) ! (null (if repeat ! jit-lock-stealth-buffers ! (setq jit-lock-stealth-buffers (buffer-list))))) ! (let ((buffer (car jit-lock-stealth-buffers)) minibuffer-auto-raise ! message-log-max ! start load-delay) ! (when (or (not jit-lock-stealth-load) ! (or (<= (car (load-average)) jit-lock-stealth-load) ! (not (setq load-delay t)))) ! (with-current-buffer buffer ! (if (and jit-lock-mode ! (setq start (jit-lock-stealth-chunk-start (point)))) ! ;; Fontify one block. (with-temp-message (if jit-lock-stealth-verbose (concat "JIT stealth lock " (buffer-name))) ! (jit-lock-fontify-now start (+ start jit-lock-chunk-size))) ! ;; Nothing to fontify. ! (setq jit-lock-stealth-buffers (cdr jit-lock-stealth-buffers))))) ! (when jit-lock-stealth-buffers ! ;; The 0.1s are completely arbitrary here and should be replaced by ! ;; something more appropriate. ! (run-at-time ! (if load-delay ! (min jit-lock-stealth-time 0.1) ! (min jit-lock-stealth-nice 0.1)) ! nil 'jit-lock-stealth-fontify t))))) ;;; Deferred fontification. --------------080201030904090604000207 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel --------------080201030904090604000207--