emacs-bug-tracker
[Top][All Lists]
Advanced

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

[debbugs-tracker] bug#8453: closed (enhancement to image mode)


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#8453: closed (enhancement to image mode)
Date: Sat, 19 Jan 2013 15:25:01 +0000

Your message dated Sat, 19 Jan 2013 23:23:19 +0800
with message-id <address@hidden>
and subject line Re: bug#8453: enhancement to image mode
has caused the debbugs.gnu.org bug report #8453,
regarding enhancement to image mode
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
8453: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8453
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: enhancement to image mode Date: Sat, 09 Apr 2011 10:29:48 +0900 User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9
Hello, I am trying to send this through the send bug report function, I hope
it works.

With the help of Drew Adams on gnu.emacs.help, I added the following to
image-mode, which allows one to visit the following or previous image, which
is useful if images are in a series, such as in pages of books.  If this is
deemed useful, I would like to have this added to emacs.

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

(defun next-image (arg)
  "when visitng an image, go to the next image in the same
directory of the same type. No argument or nil will move to the
following image in ascending order, t will move to the previous
one.  Thanks to Drew Adams for help with this on gnu.emacs.help"
  (interactive "P")
  (unless (and (buffer-file-name) (eq major-mode 'image-mode))
    (error "Not visiting a file in image mode"))
  (let* ((files   (directory-files
                   (file-name-directory (buffer-file-name)) nil
                   (file-name-extension (buffer-file-name)) ))
         (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)
  "when visitng an image, go to the next image in the same
directory of the same type. No argument or nil will move to the
following image in ascending order, t will move to the previous
one.  Thanks to Drew Adams for help with this on gnu.emacs.help"
  (interactive "P")
  (next-image t))


-- 
 Christian Wittern



--- End Message ---
--- Begin Message --- Subject: Re: bug#8453: enhancement to image mode Date: Sat, 19 Jan 2013 23:23:19 +0800 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.92 (gnu/linux)
Stefan Monnier <address@hidden> writes:

>> With the help of Drew Adams on gnu.emacs.help, I added the following
>> to image-mode, which allows one to visit the following or previous
>> image, which is useful if images are in a series, such as in pages of
>> books.  If this is deemed useful, I would like to have this added to
>> emacs.
>
> This looks very handy, indeed.  I'd recommend to slightly change the
> code so it just looks for the first filename greater than the current
> name (so it also works in the odd case where the current file is not
> in the directory any more).

Done, with some substantial modifications.


--- End Message ---

reply via email to

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