From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Hyatt Subject: Re: [PATCH] Add the ability to archive to the datetree. Date: Wed, 9 Nov 2011 10:24:52 -0500 Message-ID: References: <8739dxfsl4.fsf@norang.ca> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([140.186.70.92]:39966) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ROA1J-0004IP-Ot for emacs-orgmode@gnu.org; Wed, 09 Nov 2011 10:25:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ROA1E-0004VD-Uh for emacs-orgmode@gnu.org; Wed, 09 Nov 2011 10:24:57 -0500 Received: from mail-vx0-f169.google.com ([209.85.220.169]:40150) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ROA1E-0004V5-Nc for emacs-orgmode@gnu.org; Wed, 09 Nov 2011 10:24:52 -0500 Received: by vcbfo11 with SMTP id fo11so477217vcb.0 for ; Wed, 09 Nov 2011 07:24:52 -0800 (PST) In-Reply-To: <8739dxfsl4.fsf@norang.ca> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Bernt Hansen Cc: emacs-orgmode@gnu.org The documentation didn't go into any details about how to specify the org-archive-location, or what you could do with it, instead it just referred to the documentation of that variable. Still, now that you mention it, it seemed worthwhile to add something to the docs, so I did that. I'll send another version of the patch now. On Wed, Nov 9, 2011 at 6:22 AM, Bernt Hansen wrote: > Hi Andrew, > > I'm just eyeballing your patch and there's a typo in your last hunk - > see comment inline. > > Don't you also need to update the texinfo documentation for this > enhancement? > > -Bernt > > Andrew Hyatt writes: > >> * org.el (org-archive-location): Add documentation on new datetree >> option. >> * org-archive.el (org-archive-subtree): Add special handling >> of datetree options to archive to datetree. >> >> --- >> =A0lisp/org-archive.el | =A0 21 +++++++++++++++++---- >> =A0lisp/org.el =A0 =A0 =A0 =A0 | =A0 =A07 +++++++ >> =A02 files changed, 24 insertions(+), 4 deletions(-) >> >> diff --git a/lisp/org-archive.el b/lisp/org-archive.el >> index 16c35cf..4df6f1e 100644 >> --- a/lisp/org-archive.el >> +++ b/lisp/org-archive.el >> @@ -213,13 +213,14 @@ this heading." >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(current-time))) >> =A0 =A0 =A0 =A0 category todo priority ltags itags atags >> =A0 =A0 =A0 =A0 ;; end of variables that will be used for saving context >> - =A0 =A0 =A0 location afile heading buffer level newfile-p infile-p vis= iting) >> + =A0 =A0 =A0 location afile heading buffer level newfile-p infile-p vis= iting >> + =A0 =A0 =A0 datetree-date) >> >> =A0 =A0 =A0 =A0;; Find the local archive location >> =A0 =A0 =A0 =A0(setq location (org-get-local-archive-location) >> =A0 =A0 =A0 =A0 =A0 afile (org-extract-archive-file location) >> =A0 =A0 =A0 =A0 =A0 heading (org-extract-archive-heading location) >> - =A0 =A0 =A0 =A0 infile-p (equal file (abbreviate-file-name afile))) >> + =A0 =A0 =A0 =A0 infile-p (equal file (abbreviate-file-name (or afile "= ")))) >> =A0 =A0 =A0 =A0(unless afile >> =A0 =A0 =A0 (error "Invalid `org-archive-location'")) >> >> @@ -230,6 +231,12 @@ this heading." >> =A0 =A0 =A0 (setq buffer (current-buffer))) >> =A0 =A0 =A0 =A0(unless buffer >> =A0 =A0 =A0 (error "Cannot access file \"%s\"" afile)) >> + =A0 =A0 =A0(when (string-match "\\`datetree/" heading) >> + =A0 =A0 ;; Replace with ***, to represent the 3 levels of headings the >> + =A0 =A0 ;; datetree has. >> + =A0 =A0 (setq heading (string-replace-match "\\`datetree/" heading "**= *")) >> + =A0 =A0 (setq datetree-date (org-date-to-gregorian >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(or (org-entry-get = nil "CLOSED" t) time)))) >> =A0 =A0 =A0 =A0(if (and (> (length heading) 0) >> =A0 =A0 =A0 =A0 =A0 =A0 =A0(string-match "^\\*+" heading)) >> =A0 =A0 =A0 =A0 (setq level (match-end 0)) >> @@ -262,6 +269,9 @@ this heading." >> =A0 =A0 =A0 =A0 (goto-char (point-max)) >> =A0 =A0 =A0 =A0 (insert (format "\nArchived entries from file %s\n\n" >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (buffer-file-name this-b= uffer)))) >> + =A0 =A0 (when datetree-date >> + =A0 =A0 =A0 (org-datetree-find-date-create datetree-date) >> + =A0 =A0 =A0 (org-narrow-to-subtree)) >> =A0 =A0 =A0 ;; Force the TODO keywords of the original buffer >> =A0 =A0 =A0 (let ((org-todo-line-regexp tr-org-todo-line-regexp) >> =A0 =A0 =A0 =A0 =A0 =A0 (org-todo-keywords-1 tr-org-todo-keywords-1) >> @@ -285,7 +295,8 @@ this heading." >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; Heading not found, just insert it at = the end >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (goto-char (point-max)) >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (or (bolp) (insert "\n")) >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 (insert "\n" heading "\n") >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; datetrees don't need to much spacing >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 (if datetree-date (insert heading) (insert= "\n" heading "\n")) >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (end-of-line 0)) >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; Make the subtree visible >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 (show-subtree) >> @@ -296,7 +307,8 @@ this heading." >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (org-end-of-subtree t)) >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 (skip-chars-backward " \t\r\n") >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 (and (looking-at "[ \t\r\n]*") >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(replace-match "\n\n"))) >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0;; datetree archives don't need so = much spacing. >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(replace-match (if datetree-date "\= n" "\n\n")))) >> =A0 =A0 =A0 =A0 =A0 ;; No specific heading, just go to end of file. >> =A0 =A0 =A0 =A0 =A0 (goto-char (point-max)) (insert "\n")) >> =A0 =A0 =A0 =A0 ;; Paste >> @@ -326,6 +338,7 @@ this heading." >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (setq n (concat "ARCHIVE_" (upcase (symb= ol-name e)))) >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (org-entry-put (point) n v))))) >> >> + =A0 =A0 =A0 (widen) >> =A0 =A0 =A0 =A0 ;; Save and kill the buffer, if it is not the same buffe= r. >> =A0 =A0 =A0 =A0 (when (not (eq this-buffer buffer)) >> =A0 =A0 =A0 =A0 =A0 (save-buffer)))) >> diff --git a/lisp/org.el b/lisp/org.el >> index 6ee3b4e..9c80c9c 100644 >> --- a/lisp/org.el >> +++ b/lisp/org.el >> @@ -4046,6 +4046,13 @@ Here are a few examples: >> =A0 =A0 =A0 Archive in file ./basement (relative path), as level 3 trees >> =A0 =A0 =A0 below the level 2 heading \"** Finished Tasks\". >> >> +\"~/org/datetree.org::datetree/* Finished Tasks\" >> + =A0 =A0 =A0 =A0The \"datetree/\" string is special, signifiying to > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0^^^^^^^^^^^ > Typo here =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 signifying > >> + =A0 =A0 =A0 =A0archive items to the datetree. =A0Items are placed in >> + =A0 =A0 =A0 =A0either the CLOSED date of the item, or the current date >> + =A0 =A0 =A0 =A0if there is no CLOSED date. =A0The heading will be a >> + =A0 =A0 =A0 =A0subentry to the current date. >> + >> =A0You may set this option on a per-file basis by adding to the buffer a >> =A0line like >