From: martin rudalics <rudalics@gmx.at>
Cc: Chong Yidong <cyd@stupidchicken.com>, rms@gnu.org, emacs-devel@gnu.org
Subject: Re: Nested sit-for's
Date: Fri, 18 Aug 2006 11:03:04 +0200 [thread overview]
Message-ID: <44E58248.7020202@gmx.at> (raw)
In-Reply-To: <m3d5az9heo.fsf@kfs-l.imdomain.dk>
[-- Attachment #1: Type: text/plain, Size: 283 bytes --]
> 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.
[-- Attachment #2: jit-lock.patch --]
[-- Type: text/plain, Size: 6596 bytes --]
*** 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))))))))))))))
!
!
\f
;;; 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)))))
\f
;;; Deferred fontification.
[-- Attachment #3: Type: text/plain, Size: 142 bytes --]
_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel
next prev parent reply other threads:[~2006-08-18 9:03 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <E1GD2sr-0005PH-UP@savannah.gnu.org>
[not found] ` <m3bqqlka7e.fsf@kfs-l.imdomain.dk>
[not found] ` <87y7tp90i1.fsf@stupidchicken.com>
2006-08-16 8:14 ` Nested sit-for's Kim F. Storm
2006-08-16 19:08 ` Chong Yidong
2006-08-17 6:02 ` Richard Stallman
2006-08-17 11:15 ` Kim F. Storm
2006-08-17 14:02 ` David Kastrup
2006-08-18 15:47 ` Richard Stallman
2006-08-17 14:14 ` Chong Yidong
2006-08-17 15:09 ` Kim F. Storm
2006-08-17 17:21 ` Chong Yidong
2006-08-17 21:28 ` Kim F. Storm
2006-08-17 22:42 ` Chong Yidong
2006-08-17 16:05 ` martin rudalics
2006-08-17 21:33 ` Kim F. Storm
2006-08-18 9:03 ` martin rudalics [this message]
2006-08-18 9:26 ` Kim F. Storm
2006-08-20 13:54 ` Chong Yidong
2006-08-20 21:05 ` Kim F. Storm
2006-08-20 21:52 ` martin rudalics
2006-08-20 22:05 ` Kim F. Storm
2006-08-21 11:13 ` Richard Stallman
2006-08-21 11:45 ` Kim F. Storm
2006-08-21 16:14 ` Stefan Monnier
2006-08-21 17:18 ` martin rudalics
2006-08-22 1:40 ` Stefan Monnier
2006-08-22 7:42 ` Richard Stallman
2006-08-17 14:21 ` Chong Yidong
2006-08-18 15:47 ` Richard Stallman
2007-10-17 14:41 ` Juanma Barranquero
2007-10-18 5:02 ` Richard Stallman
2007-10-18 7:40 ` Juanma Barranquero
2007-10-23 7:13 ` Richard Stallman
2006-08-17 15:33 ` Drew Adams
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=44E58248.7020202@gmx.at \
--to=rudalics@gmx.at \
--cc=cyd@stupidchicken.com \
--cc=emacs-devel@gnu.org \
--cc=rms@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.