emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Tim Burt <tcburt@rochester.rr.com>
To: Jeffrey Brent McBeth <mcbeth@broggs.org>
Cc: emacs-orgmode@gnu.org
Subject: Re: org-capture, datetree, and tags
Date: Thu, 21 Feb 2013 06:42:13 -0500	[thread overview]
Message-ID: <m3ehg9j3l6.fsf@fluorine.burtket> (raw)
In-Reply-To: <m3fw0rjjrp.fsf@fluorine.burtket> (Tim Burt's message of "Wed, 20 Feb 2013 06:40:26 -0500")

Tim Burt <tcburt@rochester.rr.com> writes:

> Jeffrey Brent McBeth <mcbeth@broggs.org> writes:
>
>> I'm trying to capture into a datetree using org-capture, but if my tree has a tag on it (in particular noexport), then it creates a new datetree instead of using the one I have.
>> Example .emacs:
>> (global-set-key "\C-cc" 'org-capture)
>> (setq org-capture-templates
>> 	'(("t" "Test" plain (file+datetree "~/Test.org")
>> 		"%^{Greeting} World
>> I'm going to work this time")))
>>
>> Example Test.org:
>>
>> * 2013								   :noexport:
>> ** 2013-02 February
>> *** 2013-02-19 Tuesday
>> Hello World
>> I'm going to work this time
>>
>> So, based on the above, if I type C-cct Silly C-cc, I'll get this:
>>
>> * 2013								   :noexport:
>> ** 2013-02 February
>> *** 2013-02-19 Tuesday
>> Hello World
>> I'm going to work this time
>> * 2013
>> ** 2013-02 February
>> *** 2013-02-19 Tuesday
>> Silly World
>> I'm going to work this time
>>
>> Thanks for your attention,
>>  Jeffrey McBeth
>
> I can confirm both the behavior and a usecase for a tagged datetree.  
>
> In org-datetree.el the function org-datetree-find-year-create searches for
> the year on a headline and will not match content with anything beyond the
> fourth digit.
> : (defun org-datetree-find-year-create (year)
> :   (let ((re "^\\*+[ \t]+\\([12][0-9][0-9][0-9]\\)$")
> : 	match)
>
> In this particular case the tag in question is :noexport: with white space
> fore (and maybe aft), and the following change to the regular expression
> was tested with success.
> : (defun org-datetree-find-year-create (year)
> :   (let ((re "^\\*+[ \t]+\\([12][0-9][0-9][0-9]\\)[ \t]+:noexport:[ \t]*$")
> : 	match)
> Of course this only matches the specific tag in this example *and* only
> matches a datetree with this tag. The regular expression needs to be
> improved to include a valid tag set as optional.  

Improved the regular expression to permit multiple tags of letters,
numbers, underscores, and at signs.
:  (defun org-datetree-find-year-create (year)
:    (let ((re "^\\*+[ \t]+\\([12][0-9][0-9][0-9]\\)[ \t]*\\(:[[:alnum:]_@]*\\)*:*[ \t]*$")
:          match)
I've tested with the following headlines:
 - 2013
   - both with and without trailing spaces
 - 2013 :abc:
 - 2013 :abc123:
 - 2013 :abc123:_underscore:@attaboy::
 - 2013 :noexport:

Any comments on the regular expression are welcome before I make patch.



-- 
Tim Burt
www.rketburt.org
"It is healthful to every sane man to utter the art within him;" -- GK Chesterton

  reply	other threads:[~2013-02-21 11:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-19 12:25 org-capture, datetree, and tags Jeffrey Brent McBeth
2013-02-20 11:40 ` Tim Burt
2013-02-21 11:42   ` Tim Burt [this message]
2013-02-22 13:56     ` Bastien
2013-02-23 12:18       ` Tim Burt
2013-02-24 21:05         ` Tim Burt
2013-02-20 11:43 ` Jeffrey Brent McBeth

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=m3ehg9j3l6.fsf@fluorine.burtket \
    --to=tcburt@rochester.rr.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=mcbeth@broggs.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).