From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mikael Fornius Subject: Re: [feature request] use relative path in the file set by org-agenda-files Date: Thu, 25 Mar 2010 12:01:27 +0100 Message-ID: <87hbo4d5rs.fsf@eee.lan> References: <87sk7rnxe8.fsf@eee.lan> <4D4BCB95-CFF9-4FA1-B346-07B55F8CBA82@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NuklI-00055E-OI for emacs-orgmode@gnu.org; Thu, 25 Mar 2010 06:58:04 -0400 Received: from [140.186.70.92] (port=33795 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NuklG-000556-70 for emacs-orgmode@gnu.org; Thu, 25 Mar 2010 06:58:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NuklE-0002gu-53 for emacs-orgmode@gnu.org; Thu, 25 Mar 2010 06:58:02 -0400 Received: from violet.abc.se ([62.80.200.155]:44735) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NuklD-0002cn-PA for emacs-orgmode@gnu.org; Thu, 25 Mar 2010 06:58:00 -0400 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Carsten Dominik Cc: emacs-orgmode@gnu.org, zwz --=-=-= Thanks Carsten for the feedback! The following patch remembers the un-expanded file names by re-reading the agenda-files definition file before saving. It matches the expanded file names with the un-expanded and keeps the un-expanded version when saving. If you like it please apply it. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=org-agenda-files-expansion.patch Content-Description: org-agenda-files-expansion diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 4c76cc0..709dbd8 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,12 @@ +2010-03-25 Mikael Fornius + + * org.el (org-agenda-files): Typo. + (org-read-agenda-file-list): Optional argument added helping + org-store-new-agenda-file-list to remember un-expanded file names. + (org-store-new-agenda-file-list): Keep un-expanded file names when + saving, if availible. + (org-agenda-files): Updating documentation. + 2010-03-25 Carsten Dominik * org-ascii.el (org-export-as-ascii): Catch the case of exporting diff --git a/lisp/org.el b/lisp/org.el index 68dd1ed..0abe787 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -2780,7 +2780,8 @@ If an entry is a directory, all files in that directory that are matched by If the value of the variable is not a list but a single file name, then the list of agenda files is actually stored and maintained in that file, one -agenda file per line." +agenda file per line. In this file paths can be given relative to this files +directory, tilde expansion and environment variable substitution is also made." :group 'org-agenda :type '(choice (repeat :tag "List of files and directories" file) @@ -14641,7 +14642,7 @@ If EXCLUDE-TMP is non-nil, ignore temporary buffers." "Get the list of agenda files. Optional UNRESTRICTED means return the full list even if a restriction is currently in place. -When ARCHIVES is t, include all archive files hat are really being +When ARCHIVES is t, include all archive files that are really being used by the agenda files. If ARCHIVE is `ifmode', do this only if `org-agenda-archives-mode' is t." (let ((files @@ -14694,17 +14695,28 @@ the buffer and restores the previous window configuration." (defun org-store-new-agenda-file-list (list) "Set new value for the agenda file list and save it correctly." (if (stringp org-agenda-files) - (let ((f org-agenda-files) b) - (while (setq b (find-buffer-visiting f)) (kill-buffer b)) - (with-temp-file f - (insert (mapconcat 'identity list "\n") "\n"))) + (let ((fe (org-read-agenda-file-list t)) b u) + (while (setq b (find-buffer-visiting org-agenda-files)) + (kill-buffer b)) + (with-temp-file org-agenda-files + (insert + (mapconcat + (lambda (f) ;; Keep un-expanded entries. + (if (setq u (assoc f fe)) + (cdr u) + f)) + list "\n") + "\n"))) (let ((org-mode-hook nil) (org-inhibit-startup t) (org-insert-mode-line-in-empty-file nil)) (setq org-agenda-files list) (customize-save-variable 'org-agenda-files org-agenda-files)))) -(defun org-read-agenda-file-list () - "Read the list of agenda files from a file." +(defun org-read-agenda-file-list (&optional pair-with-expansion) + "Read the list of agenda files from a file. +If PAIR-WITH-EXPANSION is t return pairs with un-expanded +filenames, used by org-store-new-agenda-file-list to write back +un-expanded file names." (when (file-directory-p org-agenda-files) (error "`org-agenda-files' cannot be a single directory")) (when (stringp org-agenda-files) @@ -14712,8 +14724,11 @@ the buffer and restores the previous window configuration." (insert-file-contents org-agenda-files) (mapcar (lambda (f) - (expand-file-name (substitute-in-file-name f) - (file-name-directory org-agenda-files))) + (let ((e (expand-file-name (substitute-in-file-name f) + (file-name-directory org-agenda-files)))) + (if pair-with-expansion + (cons e f) + e))) (org-split-string (buffer-string) "[ \t\r\n]*?[\r\n][ \t\r\n]*"))))) ;;;###autoload --=-=-= -- Mikael Fornius --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --=-=-=--