Keks Dose
Keks Dose

Reputation: 143

Org-mode under Linux / Windows 7: How to include in agenda view same files -- which reside on different places, depending on OS

My Question:

My office pc is running under Windows 7, my notebook under Linux (openSuse 12.1). I'd like to include in the agenda view of org-mode a certain file "foo.org". Under Windows 7 the path is T:/123-12/foo.org ; under Linux the path is ~/Documents/Projects/12-123-Projectname/foo.org

On both computers is a identical file "Projects.org", which consists of my projects with all schedules, deadlines, bells and whistles. But this file Projects.org is too large and I need to swap content to the project folders. This file is synced between both computers every day and of course the two projects get synced as well.

How can I include the foo.org in the agenda view of both computers, with one entry in the main file "Project.org"? Is there a possibility to have a switch if linux / if windows 7 ? Or can it be done with symbolic links?


1. Edit to the answer to https://stackoverflow.com/a/11611956/1171221 by pmr

Can I add many files per OS?, e.g.:

(setq org-agenda-files
      (if (eq system-type 'windows-nt)
          '("windows-path1/file1.org" "windows-path2/file1.org" "windows-path3/foo7.org")
          '("unix-path1/file1.org"    "unix-path2/file2.org"    "unix-path3/foo7.org")))

 Thank you for your friendly help. Frankly, it is cumbersome to change the .emacs-file for every new "file-xy.org", but this seems to be a design of org.el.

Second thought on your answer: Naturally I've got different ".emacs" on Linux and Windows, the .emacs-files can not be synced. Either I'd have to outsource this definition (can I put it into my large project.org somehow?) into a file which can be synced, or, mh, I'd have to add any additional "foo-xy.org" manually to the respective .emacs-file and I don't need the distinction between the OS.


2. Edit: The Solution

pmrs' answer and comments were the key. I need one file providing the switch between Windows and Linux. But my .emacs-files on those two machines grew in different directions, too much effort to align them.

As another file which can be kept in sync between both machines I wrote my first lisp file: AW-org-agenda-files.el, which basically looks like this:

;;; AW-org-agenda-files.el --- *.org-Dateien mit TODOs in agenda-view einbeziehen 

;; Copyright: AW
;; Maintainer: AW
;; Keywords: customisation of Orgmode
;; Package: emacs

(setq org-agenda-files
      (if (eq system-type 'windows-nt)
      '("u:/Emacs/whatever.org" "u:/Emacs/Client1.org" "u:/Emacs/Client2.org" 
        "u:/Emacs/Privat.org" "t:/222-2012/file.org")
      '("~/Dokumente/Technik-u-Dokus/Emacs/whatever.org"
            "~/Dokumente/Technik-u-Dokus/Emacs/Client1.org" "~/Dokumente/Technik-u-Dokus/Emacs/Client2.org" "~/Dokumente/RA-win/2012-222-name/file.org")

))

(provide 'AW-org-agenda-files)
;;; end

Upvotes: 3

Views: 640

Answers (2)

Jonathan Leech-Pepin
Jonathan Leech-Pepin

Reputation: 7884

An alternate solution would be to create variables for the differences in the paths between the systems, and a variable listing all the files. In your case (omitting the final file which does not follow the same pattern):

(defvar my/org-windows "u:/Emacs")
(defvar my/org-linux "~/Dokumente/Technik-u-Dokus/Emacs")
(defvar my/org-agenda-files '("whatever.org"
                              "Client1.org"
                              "Client2.org"
                              "Privat.org"))

Then you just mapcar the path onto the file and you will have your list of agenda files.

(mapcar (lambda (i)
          (expand-file-name i
                            (if (eq system-type 'windows-nt)
                                my/org-windows
                              my/org-linux)))
        my/org-agenda-files)

This will not work for any files that have other paths, but if you have a limited set of paths you can define a set of variables for each location and then only have to update the list of actual files in that folder.

Upvotes: 1

pmr
pmr

Reputation: 59841

The files that are used to produce the agenda are stored in the variable org-agenda-files. You can conditionally initialize this variable in your .emacs according to the platform using the system-type variable.

(setq org-agenda-files
      (if (eq system-type 'windows-nt)
          '("windows-path/file.org")
        '("unix-path/file.org")))

For more information: C-h v system-type RET

Upvotes: 5

Related Questions