From: Mikael Fornius <mfo@abc.se>
To: Carsten Dominik <carsten.dominik@gmail.com>
Cc: emacs-orgmode@gnu.org, zwz <zhangweize@gmail.com>
Subject: Re: [feature request] use relative path in the file set by org-agenda-files
Date: Thu, 25 Mar 2010 12:01:27 +0100 [thread overview]
Message-ID: <87hbo4d5rs.fsf@eee.lan> (raw)
In-Reply-To: 4D4BCB95-CFF9-4FA1-B346-07B55F8CBA82@gmail.com
[-- Attachment #1: Type: text/plain, Size: 294 bytes --]
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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: org-agenda-files-expansion --]
[-- Type: text/x-patch, Size: 3675 bytes --]
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 <mfo@abc.se>
+
+ * 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 <carsten.dominik@gmail.com>
* 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
[-- Attachment #3: Type: text/plain, Size: 20 bytes --]
--
Mikael Fornius
[-- Attachment #4: Type: text/plain, Size: 201 bytes --]
_______________________________________________
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
prev parent reply other threads:[~2010-03-25 10:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-23 7:32 [feature request] use relative path in the file set by org-agenda-files zwz
2010-03-23 10:30 ` Mikael Fornius
2010-03-24 12:00 ` Carsten Dominik
2010-03-25 11:01 ` Mikael Fornius [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87hbo4d5rs.fsf@eee.lan \
--to=mfo@abc.se \
--cc=carsten.dominik@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=zhangweize@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.