emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Daniele Nicolodi <daniele@grinta.net>
To: emacs-orgmode@gnu.org
Subject: Re: Insert datetree entry
Date: Wed, 5 Apr 2017 17:19:23 -0600	[thread overview]
Message-ID: <f1abc76c-a2aa-fcbf-678f-28df47a1429d@grinta.net> (raw)
In-Reply-To: <87y3ve7ctk.fsf@topd0g>

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 <daniele@grinta.net> 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

      reply	other threads:[~2017-04-05 23:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-03 22:40 Insert datetree entry Daniele Nicolodi
2017-04-03 23:37 ` Bruce V Chiarelli
2017-04-04 18:42   ` Daniele Nicolodi
2017-04-04 19:25     ` Bruce V Chiarelli
2017-04-04 19:50       ` Daniele Nicolodi
2017-04-04 21:18       ` Daniele Nicolodi
2017-04-05 21:40         ` Bruce V Chiarelli
2017-04-05 23:19           ` Daniele Nicolodi [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

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f1abc76c-a2aa-fcbf-678f-28df47a1429d@grinta.net \
    --to=daniele@grinta.net \
    --cc=emacs-orgmode@gnu.org \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).