[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Insert datetree entry
From: |
Daniele Nicolodi |
Subject: |
Re: [O] Insert datetree entry |
Date: |
Wed, 5 Apr 2017 17:19:23 -0600 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 |
On 4/5/17 3:40 PM, Bruce V Chiarelli wrote:
>
> Daniele Nicolodi writes:
>
>> On 4/4/17 1:25 PM, Bruce V Chiarelli wrote:
>>>
>>> Daniele Nicolodi <address@hidden> writes:
>> Hi Bruce,
>>
>> I modified your code as follow to be able to insert a datetree entry
>> correctly being anywhere in an existing datetree. I also added the
>> possibility of having a prefix argument to prompt for the date. It works
>> for me, but I don't know if this is the most elegant way to obtain what
>> I want. Comments are welcome.
>>
>>
>> ;; look for datetree root
>> (defun dnn-org-datetree-root ()
>> (let ((re
>> "^\\([12][0-9]\\{3\\}\\)\\(-\\([01][0-9]\\)\\(-\\([0123][0-9]\\)\\)?\\)?
>> \\w+$"))
>> (while (string-match re (org-get-heading))
>> (org-up-heading-safe))
>> (org-up-heading-safe)))
>>
>> ;; add a datetree entry
>> (defun dnn-org-datetree-find-create (arg)
>> (interactive "P")
>> (let ((d (calendar-gregorian-from-absolute
>> (if arg (time-to-days (org-read-date nil t)) (org-today)))))
>> (dnn-org-datetree-root)
>> (org-datetree-find-date-create d 'subtree-at-point)))
>
> Nice! I'm afraid I'm unqualified to give any comments/criticism on your
> code, since I'm fairly new to elisp myself. Looks better than what I had
> though, at least to work around the missing 'subtree-at-point
> feature. Maybe someone else can chime in.
If that code works around the missiong 'subtree-at-point feature on
older org-mode releases, it is absolutely by chance, I "back-ported" the
feature into my system from current org-mode master branch :-)
Cheers,
Daniele