emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* function to cycle through specific org files?
@ 2015-10-19  5:35 Xebar Saram
  2015-10-19 11:05 ` John Kitchin
  0 siblings, 1 reply; 3+ messages in thread
From: Xebar Saram @ 2015-10-19  5:35 UTC (permalink / raw)
  To: org mode

[-- Attachment #1: Type: text/plain, Size: 395 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 519 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: function to cycle through specific org files?
  2015-10-19  5:35 function to cycle through specific org files? Xebar Saram
@ 2015-10-19 11:05 ` John Kitchin
  2015-10-19 11:15   ` Kaushal Modi
  0 siblings, 1 reply; 3+ messages in thread
From: John Kitchin @ 2015-10-19 11:05 UTC (permalink / raw)
  To: Xebar Saram; +Cc: org mode

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-<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 :)). 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: function to cycle through specific org files?
  2015-10-19 11:05 ` John Kitchin
@ 2015-10-19 11:15   ` Kaushal Modi
  0 siblings, 0 replies; 3+ messages in thread
From: Kaushal Modi @ 2015-10-19 11:15 UTC (permalink / raw)
  To: John Kitchin; +Cc: Xebar Saram, emacs-org list

[-- Attachment #1: Type: text/plain, Size: 1692 bytes --]

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" <jkitchin@andrew.cmu.edu> 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-<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 :)). 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
>
>

[-- Attachment #2: Type: text/html, Size: 2662 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-10-19 11:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-19  5:35 function to cycle through specific org files? Xebar Saram
2015-10-19 11:05 ` John Kitchin
2015-10-19 11:15   ` Kaushal Modi

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).