[Top][All Lists]

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

Re: thumbs.el and transparency

From: Mathias Dahl
Subject: Re: thumbs.el and transparency
Date: Sun, 29 Jan 2006 17:01:11 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

"Richard M. Stallman" <address@hidden> writes:

>     Thumbs operation on the other hand is er, pretty obvious and
>     straight-forward, and it seems reasonably useful for what it does...
>     At the least, I got a buffer full of thumbnails with the first command
>     I tried.  I never did figure out how to make tumme do that.
> We need to make it tumme simpler to invoke.

Here is an example of such a command. It tries to mirror the way the
`thumbs' command works. I added a new defcustom, a new defun with a
defalias and made a slight change to `tumme-display-thumbs'. Basic
code proudly copied from thumbs.el:

(defcustom tumme-show-all-from-dir-max-files 50
  "*Maximum number of files to show using`tumme-show-all-from-dir'.
 before warning the user."
  :type 'integer
  :group 'tumme)

(defun tumme-show-all-from-dir (dir)
  "Make a preview buffer for all images in DIR and display it.
If the number of files in DIR that matches
`image-file-name-regexp' exceeds
`tumme-show-all-from-dir-max-files', a warning will be

Note: you won't get the same integration (movement tracking,
marking, automatic jumping to the correct dired buffer etc) using
this command as if you had used `tumme-display-thumbs' directly
from a dired buffer, but for basic thumbnail and image viewing it
works well."
  (interactive "DDir: ")
  (let* ((files (directory-files 
                 dir t (image-file-name-regexp))))
    (if (or (<= (length files) tumme-show-all-from-dir-max-files)
            (and (> (length files) tumme-show-all-from-dir-max-files)
                  (format "Directory contains more than %d files. Proceed? " 
          (tumme-display-thumbs nil nil files)
          (switch-to-buffer tumme-thumbnail-buffer))
      (message "Cancelled."))))     

(defalias 'tumme 'tumme-show-all-from-dir)

(defun tumme-display-thumbs (&optional arg append files)
  "Display thumbnails of all marked files, in `tumme-thumbnail-buffer'.
If a thumbnail image does not exist for a file, it is created on
the fly.  With prefix argument ARG, display only thumbnail for
file at point (this is useful if you have marked some files but
want to show another one). 

Optional argument FILES is a list of file names that will be used
instead of using file names from dired.

With optional argument APPEND, append thumbnail to thumbnail buffer
instead of erasing it first.

Recommended usage is to split the current frame horizontally so
that you have the dired buffer in the left window and the
`tumme-thumbnail-buffer' buffer in the right window."
  (interactive "P")
  (let ((buf (tumme-create-thumbnail-buffer))
        curr-file thumb-name file-list count dired-buf beg)
    (if files
          (setq file-list files)
          (setq dired-buf nil))
      (setq dired-buf (current-buffer))
      (if arg
          (setq files (list (dired-get-filename)))
        (setq files (dired-get-marked-files))))
      (set-buffer buf)
      (let ((inhibit-read-only t))
        (if (not append)
          (goto-char (point-max)))
         (lambda (curr-file)
           (setq thumb-name (tumme-thumb-name curr-file))
           (if (and (not (file-exists-p thumb-name))
                    (not (= 0 (tumme-create-thumb curr-file thumb-name))))
               (message "Thumb could not be created for file %s" curr-file)
             (tumme-insert-thumbnail thumb-name curr-file dired-buf)))
      (cond ((eq 'dynamic tumme-line-up-method)
            ((eq 'fixed tumme-line-up-method)
            ((eq 'interactive tumme-line-up-method)
            ((eq 'none tumme-line-up-method)

Combined with one of the example defuns I posted earlier I think that this
would indeed be quite easy to use for a beginner, or at least match
the easiness (?) of thumbs:

(defun tumme-display-thumbnail-original-image-and-buffer (&optional arg)
  "Call `tumme-display-thumbnail-original-image' and display display buffer.
See command `tumme-display-thumbnail-original-image' for
  (interactive "P")
  (tumme-display-thumbnail-original-image arg)
  (display-buffer tumme-display-image-buffer))

Rebind RET:

(define-key tumme-thumbnail-mode-map "\C-m"

It would be great if someone could test the usefullness of this.


reply via email to

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