emacs-devel
[Top][All Lists]
Advanced

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

Re: thumbs.el and transparency


From: David Kastrup
Subject: Re: thumbs.el and transparency
Date: Sun, 29 Jan 2006 19:13:09 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

Miles Bader <address@hidden> writes:

> 2006/1/29, Mathias Dahl <address@hidden>:
>> Such a command would need to check how many images the directory
>> contains and warn the user if the number of files exeeds a certain,
>> configurable, limit (say 50 or something like that as default).
>
> How hard would it be to have it do the thumb-ification in the
> background, so that it wouldn't really matter if there were many image
> files (the user would see them being added, and could use those that
> were available)?  This is the way many image browsing programs work,
> and it's a very nice way of dealing with the delay of
> thumb-conversion.

I'd like to mention how preview-latex does this sort of background
rendering in order to have it least offensive: it keeps a queue of
images that still may have to be processed.  Then it uses a
conditional display property (the importance is not the condition,
which needs to evaluate to t, but the side effect from evaluating the
condition) for showing on-screen stuff first with the help of the
following two functions:

(defun preview-add-urgentization (fun ov &rest rest)
  "Cause FUN (function call form) to be called when redisplayed.
FUN must be a form with OV as first argument,
REST as the remainder, returning T."
  (let ((dispro (overlay-get ov 'display)))
    (unless (eq (car dispro) 'when)
      (overlay-put ov 'display `(when (,fun ,ov ,@rest)  . ,dispro)))))

(defun preview-remove-urgentization (ov)
  "Undo urgentization of OV by `preview-add-urgentization'.
Returns the old arguments to `preview-add-urgentization'
if there was any urgentization."
  (let ((dispro (overlay-get ov 'display)))
    (when (eq (car dispro) 'when)
      (prog1
          (car (cdr dispro))
        (overlay-put ov 'display (cdr (cdr dispro)))))))

(this is in preview/prv-emacs.el, since the variant for XEmacs looks
quite different).

This is used as

  (preview-add-urgentization #'preview-gs-urgentize ov run-buffer)

when the overlay is pushed into preview-gs-queue.
preview-gs-urgentize then does the following:

(defun preview-gs-urgentize (ov buff)
  "Make a displayed overlay render with higher priority.
This function is used in fake conditional display properties
for reordering the conversion order to prioritize on-screen
images.  OV is the overlay in question, and BUFF is the
Ghostscript process buffer where the buffer-local queue
is located."
  ;; It does not matter that ov gets queued twice in that process: the
  ;; first version to get rendered will clear the 'queued property.
  ;; It cannot get queued more than twice since we remove the
  ;; conditional display property responsible for requeuing here.
  ;; We don't requeue if the overlay has been killed (its buffer made
  ;; nil).  Not necessary, but while we are checking...
  ;; We must return t.
  (preview-remove-urgentization ov)
  (when (and (overlay-get ov 'queued)
             (overlay-buffer ov))
    (with-current-buffer buff
      (push ov preview-gs-queue)))
  t)


Ok, the net effect is that stuff that is on-screen will get pushed to
the front of the queue.  That means when moving around in the buffer,
first the on-screen stuff gets done, afterwards the non-visible stuff
gets done in background.

I think this would be a reasonable way of proceeding with large
directory listings, too.

If it is any help: those parts are written by myself and a part of
AUCTeX for which I have assigned papers.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum




reply via email to

[Prev in Thread] Current Thread [Next in Thread]