emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Using org-mode as day planner


From: Martin Pohlack
Subject: Re: [O] Using org-mode as day planner
Date: Mon, 13 Aug 2012 20:20:11 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:14.0) Gecko/20120714 Thunderbird/14.0

On 12.08.2012 17:48, John Hendy wrote:
> On Sat, Aug 11, 2012 at 4:34 AM, Bastien <address@hidden> wrote:
>> Hi John,
>>
>> John Hendy <address@hidden> writes:
>>
>>> Date trees are the obvious way to be able to do this, but they don't
>>> have any of the neat search functionality that I know of.
>>
>> Can you describe the search functionality you would like for date-trees?
>> I'm not sure I groked it.
> 
> Date trees allow for a very nice way for filing notes in chronological
> order, but =C-c / dateRange= does not work for date trees. Previously,
> active time stamps worked, but I didn't want all my notes showing up
> in my agenda, so I just dealt with not having a great solution. Then
> you provided one with the sparse-tree search timestamp-type selection
> ability, which rocks.
> 
> Date trees are still the best way to use capture for foolproof
> chronological storage of notes quickly... but I wouldn't be able to
> extract notes in a particular date-range with current functionality.

Hi John,

I have a very similar use case.  I capture all my stuff into a date tree
and for my weekly report I parse that and extract a subset.  It looks a
bit crude (hardcoded stuff for my setup) but works for now.  I must say
that date-trees in their current form feel a bit un-org-mody as they use
a completely different data format:

----------------------------------------------------------------------

(defun mp26/org-find-headline-prefix-in-buffer (heading &optional buffer
pos-only)
  "Find node with heading-prefix HEADING in BUFFER.
Return a marker to the heading if it was found, or nil if not.
If POS-ONLY is set, return just the position instead of a marker.

The heading prefix must match as prefix of the full headline.  It
may have a TODO keyword, a priority cookie and tags in the
standard locations."
  (with-current-buffer (or buffer (current-buffer))
    (save-excursion
      (save-restriction
        (widen)
        (goto-char (point-min))
        (let (case-fold-search)
          (if (re-search-forward
               (format org-complex-heading-regexp-format
                       (concat (regexp-quote heading) ".*")) nil t)
              (if pos-only
                  (match-beginning 0)
                (move-marker (make-marker) (match-beginning 0)))))))))

; fixme: optional parameter for starting date
(defun mp26/org-week-from-journal ()
  "Insert a copy of the current week from the journal."
  (interactive)
  (insert
   (mapconcat
    'identity
    (with-current-buffer "Journal.org<Daten>"
      (loop for days in '(-6 -5 -4 -3 -2 -1 0)
            collect
            (let* ((date (calendar-current-date days))
                   (date-string
                    (format "%d-%02d-%02d"
                            (nth 2 date) (nth 0 date) (nth 1 date))))
              (setq pos (mp26/org-find-headline-prefix-in-buffer
                         date-string nil t))
              (when pos
                (goto-char pos)
                (org-copy-subtree)
                (car kill-ring)))))
   "")))

----------------------------------------------------------------------




reply via email to

[Prev in Thread] Current Thread [Next in Thread]