Frage

I want eog-style navigation when I press v on an image in dired buffer. I've searched the web for a bit, but haven't found anything straightforward. There's image-dired, but thumbnails isn't what I want.

I want the kind of behavior that's already in place for most file types: v in dired shows the file in view-mode, where n, p, and q do the obvious thing.

I've hacked some stuff around dired-view-next, but I wonder if there's already a package that does a good job?

War es hilfreich?

Lösung

This has been fixed in what will become Emacs 24.4. IOW, it works in recent development snapshots of Emacs 24.

v in Dired works just as you request: it shows the image. And then n, p, and q do just what you would expect: show the next or previous file (image), and quit, respectively. Each image is shown in image-mode, which binds n etc. to DTRT.

Consider just picking up the image-mode.el code from a dev snapshot and adding that to your init file. Dunno whether you might need to fiddle with some of that code so it works well with Emacs 24.3 (or whatever Emacs version you are using).

Andere Tipps

From Image Dired, you can run image-dired-display-thumbnail-original-image. If you modify the keymap so that v runs image-dired-display-thumbnail-original-image, but that will only display the image in another buffer.

You could perhaps write a custom minor mode, so that when you open an image, you modify the current dired mode. This new mode would make the image open in another buffer whilst keeping the cursor in the current buffer, and making n and p move the cursor and the displayed image to the next/previous image respectively. q would drop you back in. However, I've no idea how to do that.

I put my code here just in case there's no better equivalent. It works just as I want, but the implementation is a bit silly:

(defmacro image-view (direction)
  `(lambda ()
     (interactive)
     (quit-window)
     (let ((pt (point))
           filename)
       (or (ignore-errors
             (catch 'filename
               (while (dired-next-line ,direction)
                 (when (image-type-from-file-name
                        (setq filename (dired-get-filename)))
                   (throw 'filename filename)))))
           (goto-char pt))
       (dired-view-file))))

(eval-after-load "image-mode"
  '(progn
    (define-key image-mode-map "n" (image-view 1))
    (define-key image-mode-map "h" (image-view -1))))
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top