From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniele Nicolodi Subject: Re: Insert datetree entry Date: Wed, 5 Apr 2017 17:19:23 -0600 Message-ID: References: <87fuhp83ls.fsf@topd0g> <92332b50-c4a8-73a3-f506-c058fb54b9de@grinta.net> <87efx87z71.fsf@topd0g> <0f31392a-463f-5c16-6ae0-2ddd8cab20d2@grinta.net> <87y3ve7ctk.fsf@topd0g> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:52372) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cvuD8-0006Ct-EF for emacs-orgmode@gnu.org; Wed, 05 Apr 2017 19:19:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cvuD4-0008Ip-FP for emacs-orgmode@gnu.org; Wed, 05 Apr 2017 19:19:34 -0400 Received: from zed.grinta.net ([109.74.203.128]:43654) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cvuD4-0008Ii-3n for emacs-orgmode@gnu.org; Wed, 05 Apr 2017 19:19:30 -0400 Received: from 688dnmac.campus.nist.gov (unknown [132.163.81.39]) (Authenticated sender: daniele) by zed.grinta.net (Postfix) with ESMTPSA id 99477E2F98 for ; Wed, 5 Apr 2017 23:19:26 +0000 (UTC) In-Reply-To: <87y3ve7ctk.fsf@topd0g> 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" To: emacs-orgmode@gnu.org 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 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