all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
To: "'chris'" <cwittern@gmail.com>, <help-gnu-emacs@gnu.org>
Subject: RE: extension for image view to go to next or previous image
Date: Fri, 8 Apr 2011 17:28:00 -0700	[thread overview]
Message-ID: <C7BA5D6DD14041FD8072E1B4340AA8FE@us.oracle.com> (raw)
In-Reply-To: <b589bb7d-3215-43e9-8223-3ec0caa82f34@p3g2000vbv.googlegroups.com>

> what I had in mind was ... to press 'n' (or SPC) on an
> image and then see the next one, 'p' would get me the
> previous one.

Ah, you didn't say that.

In that case, you probably need to bind `n' and `p' in `image-mode-map'.  You
just need commands that visit the next/previous file in sequence, then bind `n'
and `p' to them.  Shouldn't be hard.  Iterate over `directory-files' (e.g.
filtered by `image-file-name-regexp'), and call `find-file'.

Might be a reasonable addition to the default `image-mode-map' bindings.  After
you create the commands, think about submitting such bindings as an enhancement
via `M-x send-emacs-bug-report'.

Something like this, perhaps (you can improve it, certainly):

(require 'image-mode)
(define-key image-mode-map "n" 'next-image)
(define-key image-mode-map "p" 'previous-image)

(defun next-image (arg)
  "..."
  (interactive "P")
  (unless (and (buffer-file-name) (eq major-mode 'image-mode))
    (error "Not visiting a file in image mode"))
  (let* ((regexp  (image-file-name-regexp))
         (files   (directory-files default-directory nil regexp))
         (len     (length files))
         (this    (file-name-nondirectory (buffer-file-name)))
         (idx     0))
    (catch 'next-image
      (dolist (file  files)
        (when (string= this file) (throw 'next-image (1+ idx)))
        (setq idx  (1+ idx))))
    (setq idx  (+ idx (if arg -1 1)))
    (when (< idx 0) (setq idx (1- len)))
    (when (>= idx len) (setq idx 0))
    (find-file (elt files idx))))

(defun previous-image (arg)
  "..."
  (interactive "P")
  (next-image t))

> > 1. Use Icicles.  `C-x C-f', then cycle using `up'/`down'.  
> >    When a file is an image file the image is displayed.
> >    To cycle among only files `foo*', type `foo' then cycle.
> 
> Hmm, I tried to use icicles, but it seems to fight with ido, which I
> am using. If they can't figure it out, I am with ido.  But at the
> moment, I am not sure this is the route I want to take.

http://www.emacswiki.org/emacs/Icicles_-_Ido_and_IswitchB

> > 2. Use `image-dired'. Use `right'/`left' + `RET' in the 
> >    thumbnails buffer to cycle among images.
> 
> I also looked at image-dired, but that seems to be a different use
> case.  If there was a way to make the thumbnails larger, it might be
> useful in some ways, but not for my main purpose.

image-dired-thumb-size, `image-dired-thumb-width', and
`image-dired-thumb-height' should let you control the size.




  reply	other threads:[~2011-04-09  0:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-08  1:49 extension for image view to go to next or previous image chris
2011-04-08  6:34 ` Thierry Volpiatto
2011-04-08 13:55 ` Drew Adams
     [not found] ` <mailman.9.1302270960.11168.help-gnu-emacs@gnu.org>
2011-04-08 23:07   ` chris
2011-04-09  0:28     ` Drew Adams [this message]
     [not found]     ` <mailman.12.1302309090.11006.help-gnu-emacs@gnu.org>
2011-04-09  1:24       ` chris
2011-04-09  4:03       ` rusi
2011-04-09 15:06         ` Drew Adams
2011-04-09  5:32     ` Thierry Volpiatto
     [not found] ` <mailman.20.1302244507.25447.help-gnu-emacs@gnu.org>
2011-04-08 23:11   ` chris
2011-04-09  5:39     ` Thierry Volpiatto

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=C7BA5D6DD14041FD8072E1B4340AA8FE@us.oracle.com \
    --to=drew.adams@oracle.com \
    --cc=cwittern@gmail.com \
    --cc=help-gnu-emacs@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.