From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thierry Volpiatto Newsgroups: gmane.emacs.help Subject: Re: extension for image view to go to next or previous image Date: Fri, 08 Apr 2011 08:34:42 +0200 Message-ID: <871v1dcku5.fsf@gmail.com> References: <293db391-853d-4043-8b0b-aa68dad213bf@t13g2000vbo.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1302244546 22506 80.91.229.12 (8 Apr 2011 06:35:46 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 8 Apr 2011 06:35:46 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Apr 08 08:35:42 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Q85ID-0002cE-GN for geh-help-gnu-emacs@m.gmane.org; Fri, 08 Apr 2011 08:35:41 +0200 Original-Received: from localhost ([127.0.0.1]:53474 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q85IC-0007Q6-Vp for geh-help-gnu-emacs@m.gmane.org; Fri, 08 Apr 2011 02:35:41 -0400 Original-Received: from [140.186.70.92] (port=44248 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q85Hd-0007Q1-Op for help-gnu-emacs@gnu.org; Fri, 08 Apr 2011 02:35:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q85Hc-0002Tx-89 for help-gnu-emacs@gnu.org; Fri, 08 Apr 2011 02:35:05 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:60576) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q85Hb-0002Tm-O8 for help-gnu-emacs@gnu.org; Fri, 08 Apr 2011 02:35:04 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1Q85HY-0002It-Mh for help-gnu-emacs@gnu.org; Fri, 08 Apr 2011 08:35:00 +0200 Original-Received: from 221.77.197-77.rev.gaoland.net ([77.197.77.221]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 08 Apr 2011 08:35:00 +0200 Original-Received: from thierry.volpiatto by 221.77.197-77.rev.gaoland.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 08 Apr 2011 08:35:00 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 41 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 221.77.197-77.rev.gaoland.net User-Agent: Gnus/5.110016 (No Gnus v0.16) Emacs/23.3.50 (gnu/linux) Cancel-Lock: sha1:ntM2rar3X0zygzAAuY6ZH2v5c+Y= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 80.91.229.12 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:80692 Archived-At: chris writes: > Hi there, > > I am frequently viewing images in emacs that are part of a sequence, > therefore I am missing a way to go the next or previous image. I was > wondering if this is possible somehow already? Or maybe somebody can > show me how to do this with elisp? The filenames for these images are > chosen in a way that sorting by name brings them in the right order, > also usually the directory that contains them is open in a dired > buffer, so if necessary, maybe one could retrieve the position of the > current image and then simply get the name of the next image from > there? > > Any help would be greatly appreciated, You can use iterators to do that. You can find some of my iterators functions actually in ioccur.el, the iterator package on emacswiki is no more updated/maintained. http://mercurial.intuxication.org/hg/ioccur Use it like this: --8<---------------cut here---------------start------------->8--- ELISP> (setq A (ioccur-iter-list '("img1.jpg" "img2.jpg" "img3.jpg" "img4.jpg" "img5.jpg"))) ELISP> (ioccur-iter-next A) "img1.jpg" ELISP> (ioccur-iter-next A) "img2.jpg" ELISP> (ioccur-iter-next A) "img3.jpg" --8<---------------cut here---------------end--------------->8--- When you want to go back, create a new iterator from the last element to beginning of sequence. To go forward again, same recreate an iterator etc... You can also create infinite iterators. (See ioccur-iter-circular) -- A+ Thierry Get my Gnupg key: gpg --keyserver pgp.mit.edu --recv-keys 59F29997