From 74a4244db189fd476d61e732aef00bf4f2fbbdf2 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Sun, 11 Jan 2009 21:23:10 +0100 Subject: [PATCH] Archiving: Allow file name interpolation in target headline Matt Lundin writes: I had one more question/request concerning archives. Would it perhaps be possible to enable the file name substitution (i.e., "%s") after the double semi-colon, so that the file name can be used as a headline within the archive file? My ideal setup would be to have a single archive file for each year's work, with headlines named according to the original files of the archived subtrees. E.g., ,---- | * finances.org | ** archived item | * notes.org | ** archived item | ** another archived item `---- This commit does implement this request. --- doc/org.texi | 2 +- lisp/ChangeLog | 5 +++++ lisp/org-archive.el | 3 ++- lisp/org.el | 8 +++++++- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/doc/org.texi b/doc/org.texi index 762fd3b82..ca08938ec 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -1118,7 +1118,7 @@ each specifies the archive location for the text below it. The first such line also applies to any text before its definition. However, using this method is @emph{strongly} deprecated as it is incompatible with the outline structure of the document. The correct method for -setting multiple archive locations in a buffer is using a property.}: +setting multiple archive locations in a buffer is using properties.}: @example #+ARCHIVE: %s_done:: diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e54fd585e..b33c0bcea 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2009-01-11 Carsten Dominik + + * org-archive.el (org-extract-archive-heading): Allow %s for file + name also in achive location heading. + 2009-01-10 Carsten Dominik * org-archive.el (org-add-archive-files): Uniquify the list before diff --git a/lisp/org-archive.el b/lisp/org-archive.el index beebbfcc7..d37f84325 100644 --- a/lisp/org-archive.el +++ b/lisp/org-archive.el @@ -151,7 +151,8 @@ if LOCATION is not given, the value of `org-archive-location' is used." if LOCATION is not given, the value of `org-archive-location' is used." (setq location (or location org-archive-location)) (if (string-match "\\(.*\\)::\\(.*\\)" location) - (match-string 2 location))) + (format (match-string 2 location) + (file-name-nondirectory buffer-file-name)))) (defun org-archive-subtree (&optional find-done) "Move the current subtree to the archive. diff --git a/lisp/org.el b/lisp/org.el index c33560eef..21c5175d6 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -2770,7 +2770,9 @@ Org-mode Agenda. The archived entries will be filed as subtrees of the specified headline. When the headline is omitted, the subtrees are simply -filed away at the end of the file, as top-level entries. +filed away at the end of the file, as top-level entries. Also in +the heading you can use %s to represent the file name, this can be +useful when using the same archive for a number of different files. Here are a few examples: \"%s_archive::\" @@ -2784,6 +2786,10 @@ Here are a few examples: \"~/org/archive.org::\" Archive in file ~/org/archive.org (absolute path), as top-level trees. +\"~/org/archive.org::From %s\" + Archive in file ~/org/archive.org (absolute path), und headlines + \"From FILENAME\" where file name is the current file name. + \"basement::** Finished Tasks\" Archive in file ./basement (relative path), as level 3 trees below the level 2 heading \"** Finished Tasks\".