From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kaushal Modi Subject: Re: function to cycle through specific org files? Date: Mon, 19 Oct 2015 07:15:46 -0400 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=089e013a14ea5f4be10522734490 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43710) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zo8Pt-0002ye-QH for emacs-orgmode@gnu.org; Mon, 19 Oct 2015 07:15:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zo8Ps-00007I-7Y for emacs-orgmode@gnu.org; Mon, 19 Oct 2015 07:15:49 -0400 Received: from mail-ob0-x230.google.com ([2607:f8b0:4003:c01::230]:33422) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zo8Ps-000074-1a for emacs-orgmode@gnu.org; Mon, 19 Oct 2015 07:15:48 -0400 Received: by obbwb3 with SMTP id wb3so109655542obb.0 for ; Mon, 19 Oct 2015 04:15:47 -0700 (PDT) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: John Kitchin Cc: Xebar Saram , emacs-org list --089e013a14ea5f4be10522734490 Content-Type: text/plain; charset=UTF-8 In the event those org files are part of your org agenda, there is an inbuilt command to do that: org-cycle-agenda-files C-' (org-cycle-agenda-files) C-, Cycle through agenda file list, visiting one file after the other. http://orgmode.org/manual/Agenda-files.html On Oct 19, 2015 7:06 AM, "John Kitchin" wrote: > this feels kind of hacky, but it seems to do what you want: > > (setq my-files '("a.org" "b.org" "c.org")) > > (defun my-next-file () > (interactive) > (let ((f (pop my-files))) > (add-to-list 'my-files f t) > (find-file f))) > > (defun my-previous-file () > (interactive) > (let* ((r-my-files (reverse my-files)) > (f (pop r-my-files))) > (add-to-list 'r-my-files f t) > (setq my-files (reverse r-my-files)) > (find-file f))) > > (global-set-key (kbd "s-") 'my-next-file) > (global-set-key (kbd "s-") 'my-previous-file) > > the my-files var is not saved, so the order will not persist when you > close emacs. > > > Xebar Saram writes: > > > Hi all > > > > I know this should be easy (for anyone that knows elisp that is :)). how > > does one create a function that cycles up/down through a list of pre > > defined buffers/files? > > for example i want to cycle (ie open and show in the emacs window) > through: > > A.org B.org C.org > > i want to use ie A-left and A-right to open (if not already) and cycle > > through these files. any one has such a system? > > > > best > > > > Z > > -- > Professor John Kitchin > Doherty Hall A207F > Department of Chemical Engineering > Carnegie Mellon University > Pittsburgh, PA 15213 > 412-268-7803 > @johnkitchin > http://kitchingroup.cheme.cmu.edu > > --089e013a14ea5f4be10522734490 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

In the event those org files are part of your org agenda, th= ere is an inbuilt command to do that: org-cycle-agenda-files

C-' =C2=A0=C2=A0=C2=A0=C2=A0(org-cycle-agenda-files)
C-,=C2=A0=C2=A0=C2=A0 Cycle through agenda file list, visiting one file aft= er the other.=C2=A0

http= ://orgmode.org/manual/Agenda-files.html

On Oct 19, 2015 7:06 AM, "John Kitchin"= ; <jkitchin@andrew.cmu.edu> wrote:
this fe= els kind of hacky, but it seems to do what you want:

(setq my-files '("
a.org" "b.org" "c.org"))

(defun my-next-file ()
=C2=A0(interactive)
=C2=A0(let ((f (pop my-files)))
=C2=A0 =C2=A0(add-to-list 'my-files f t)
=C2=A0 =C2=A0(find-file f)))

(defun my-previous-file ()
=C2=A0 (interactive)
=C2=A0 (let* ((r-my-files (reverse my-files))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(f (pop r-my-files)))
=C2=A0 =C2=A0 (add-to-list 'r-my-files f t)
=C2=A0 =C2=A0 (setq my-files (reverse r-my-files))
=C2=A0 =C2=A0 (find-file f)))

(global-set-key (kbd "s-<right>") 'my-next-file)
(global-set-key (kbd "s-<left>") 'my-previous-file)

the my-files var is not saved, so the order will not persist when you
close emacs.


Xebar Saram writes:

> Hi all
>
> I know this should be easy (for anyone that knows elisp that is :)). h= ow
> does one create a function that cycles up/down through a list of pre > defined buffers/files?
> for example i want to cycle (ie open and show in the emacs window) thr= ough:
> A.org B.org C.org
> i want to use ie A-left and A-right to open (if not already) and cycle=
> through these files. any one has such a system?
>
> best
>
> Z

--
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu

--089e013a14ea5f4be10522734490--