简体   繁体   English

Linux / Windows 7下的组织模式:如何在议程视图中包含相同的文件 - 这些文件位于不同的位置,具体取决于操作系统

[英]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). 我的办公电脑在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? 或者可以用符号链接完成吗?


1. Edit to the answer to https://stackoverflow.com/a/11611956/1171221 by pmr 1.编辑pmr的https://stackoverflow.com/a/11611956/1171221答案

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文件,我不需要区分操作系统。


2. Edit: The Solution 2.编辑:解决方案

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.

相关问题 为什么Windows或Linux下的同一文件有不同的SHA-1? - Why a different SHA-1 for the same file under windows or linux? OS Windows和Linux中的结果不同 - Different results in OS Windows and Linux tkinter 在 windows 和 linux 下是否不同? - Is tkinter different under windows and linux? linux如何将不同文件夹下的同名文件批量复制重命名到单独的文件夹,文件重命名为父文件夹? - How do batch copy and rename files with same names under different folders to a separate folder with files renamed to their parent folder in linux? Linux $ PATH对于同一用户是不同的,具体取决于它的访问方式 - Linux $PATH is different for the same user, depending on how it is accessed 如何使用Linux下属于子用户命名空间的文件? - How to work with files which belong to the subuser namespace under Linux? 如何将 logback 文件路径概括为 windows/linux 操作系统? - How to generalize logback files paths to both windows/linux OS? Linux和Windows java编译器是否生成相同或不同的类文件? - Do Linux and Windows java compilers produce the same or different class files? 在Linux中,如何批量复制不同文件夹下的文件? - In Linux, how to batch copy files under different folders? Mac和Windows / Linux之间的布局不同(相同的* .ui文件) - Different layout between Mac and Windows/Linux (same *.ui files)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM