[英]Org-mode under Linux / Windows 7: How to include in agenda view same files — which reside on different places, depending on OS
My office pc is running under Windows 7, my notebook under Linux (openSuse 12.1). 我的办公电脑在Windows 7下运行,我的笔记本在Linux下运行(openSuse 12.1)。 I'd like to include in the agenda view of org-mode a certain file "foo.org". 我想在org-mode的议程视图中包含某个文件“foo.org”。 Under Windows 7 the path is T:/123-12/foo.org ; 在Windows 7下,路径为T:/123-12/foo.org; under Linux the path is ~/Documents/Projects/12-123-Projectname/foo.org 在Linux下,路径是〜/ 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. 在两台计算机上都是一个相同的文件“Projects.org”,它由我的项目组成,包括所有日程安排,截止日期,铃声和口哨声。 But this file Projects.org is too large and I need to swap content to the project folders. 但是这个文件Projects.org太大了,我需要将内容交换到项目文件夹。 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"? 如何在两台计算机的议程视图中包含foo.org,主文件“Project.org”中有一个条目? Is there a possibility to have a switch if linux / if windows 7 ? 如果linux /如果是Windows 7,是否有可能有一个开关? Or can it be done with symbolic links? 或者可以用符号链接完成吗?
Can I add many files per OS?, eg: 我可以为每个操作系统添加多个文件吗?例如:
(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. 坦率地说,为每个新的“file-xy.org”更改.emacs文件很麻烦,但这似乎是org.el的设计。
Second thought on your answer: Naturally I've got different ".emacs" on Linux and Windows, the .emacs-files can not be synced. 再想一想你的答案:当然我在Linux和Windows上有不同的“.emacs”,无法同步.emacs文件。 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. 要么我必须将这个定义外包(我可以把它放到我的大型project.org中吗?)到一个可以同步的文件中,或者,我必须添加任何额外的“foo-xy.org”手动到相应的.emacs文件,我不需要区分操作系统。
pmrs' answer and comments were the key. pmrs的回答和评论是关键。 I need one file providing the switch between Windows and Linux. 我需要一个文件提供Windows和Linux之间的切换。 But my .emacs-files on those two machines grew in different directions, too much effort to align them. 但是这两台机器上的.emacs文件在不同的方向上增长,需要付出太多努力才能对齐它们。
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: 作为另一个可以在两台机器之间保持同步的文件,我编写了我的第一个lisp文件:AW-org-agenda-files.el,基本上看起来像这样:
;;; 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
The files that are used to produce the agenda are stored in the variable org-agenda-files
. 用于生成org-agenda-files
存储在变量org-agenda-files
。 You can conditionally initialize this variable in your .emacs
according to the platform using the system-type
variable. 您可以使用system-type
变量根据平台在.emacs
有条件地初始化此变量。
(setq org-agenda-files
(if (eq system-type 'windows-nt)
'("windows-path/file.org")
'("unix-path/file.org")))
For more information: Ch v system-type RET 有关更多信息: Ch v system-type RET
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
到文件,您将获得议程文件列表。
(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. 这对于具有其他路径的任何文件都不起作用,但如果您有一组有限的路径,则可以为每个位置定义一组变量,然后只需更新该文件夹中的实际文件列表。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.