all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Solved the problem of org-capture apparently not working
@ 2011-02-05  0:32 Charles Cave
  2011-02-05  4:27 ` Puneeth Chaganti
  2011-02-10 14:55 ` Bastien
  0 siblings, 2 replies; 7+ messages in thread
From: Charles Cave @ 2011-02-05  0:32 UTC (permalink / raw)
  To: emacs-orgmode

In early January I posted what I thought was a bug report with org-capture.

I found that capturing to a date-tree didn't always work and in one file the 
capture was written to the wrong place.

Well, the problem was with the data!  One of my headings began with 2011.

The tree looked something like this (edited)

* 2010
** 2010-12 December
*** 2010-12-05 Sunday
**** A heading
**** 2011 Actions  <---------- this caused the problem
**** Another heading
...
*** 2010-12-06 Monday
...
...


In 2011 when I captured into this file's date-tree, 
org-capture found the headline 2011 Actions which matched the algorithm
and the captured item appeared at the end of the headings at that level.

My suggestion to eliminate the problem is to modify the org-capture algorithm
so years have to match beginning of line + one asterisk + one space + the year

Similarly, months could match beginning of line + two asterisks + one space + 
the year + hyphen + month number + space + Monthname.    But the chance of this 
format heading appearing outside a date-tree would be very low.

Charles
 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Solved the problem of org-capture apparently not working
  2011-02-05  0:32 Solved the problem of org-capture apparently not working Charles Cave
@ 2011-02-05  4:27 ` Puneeth Chaganti
  2011-02-05  6:48   ` [PATCH] " Puneeth Chaganti
  2011-02-10 14:55 ` Bastien
  1 sibling, 1 reply; 7+ messages in thread
From: Puneeth Chaganti @ 2011-02-05  4:27 UTC (permalink / raw)
  To: Charles Cave; +Cc: emacs-orgmode

Hi,

On Sat, Feb 5, 2011 at 6:02 AM, Charles Cave <charles.cave@gmail.com> wrote:
[..]
> My suggestion to eliminate the problem is to modify the org-capture algorithm
> so years have to match beginning of line + one asterisk + one space + the year
>
> Similarly, months could match beginning of line + two asterisks + one space +
> the year + hyphen + month number + space + Monthname.    But the chance of this
> format heading appearing outside a date-tree would be very low.

org-datetree currently checks if a buffer has an entry with a DATE_TREE
property (any value), and if it finds one, the date tree will become a
subtree under that entry.

This change would break that feature.

-- Puneeth

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Solved the problem of org-capture apparently not working
  2011-02-05  4:27 ` Puneeth Chaganti
@ 2011-02-05  6:48   ` Puneeth Chaganti
  2011-02-08 18:50     ` Puneeth Chaganti
  2011-02-10 14:56     ` Bastien
  0 siblings, 2 replies; 7+ messages in thread
From: Puneeth Chaganti @ 2011-02-05  6:48 UTC (permalink / raw)
  To: Charles Cave; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1174 bytes --]

Hi,

On Sat, Feb 5, 2011 at 9:57 AM, Puneeth Chaganti <punchagan@gmail.com> wrote:
> Hi,
>
> On Sat, Feb 5, 2011 at 6:02 AM, Charles Cave <charles.cave@gmail.com> wrote:
> [..]
>> My suggestion to eliminate the problem is to modify the org-capture algorithm
>> so years have to match beginning of line + one asterisk + one space + the year
>>
>> Similarly, months could match beginning of line + two asterisks + one space +
>> the year + hyphen + month number + space + Monthname.    But the chance of this
>> format heading appearing outside a date-tree would be very low.
>
> org-datetree currently checks if a buffer has an entry with a DATE_TREE
> property (any value), and if it finds one, the date tree will become a
> subtree under that entry.
>
> This change would break that feature.


Attached is a patch that fixes this, by using the
org-datetree-base-level variable. More details in the commit message.

@Bastien,

I didn't get the time to configure and use git-send-email. I am
sending a patch obtained using git-format-patch. So, you will have to
use git-am to apply this. (of course, if this seems good enough :))

-- Puneeth

[-- Attachment #2: 0001-Fix-regex-for-finding-datetree-year-subtree.patch --]
[-- Type: application/octet-stream, Size: 2828 bytes --]

From ab7961c3cea92271d803fdb3df89663e9c9a88ab Mon Sep 17 00:00:00 2001
From: Puneeth Chaganti <punchagan@gmail.com>
Date: Sat, 5 Feb 2011 12:08:10 +0530
Subject: [PATCH] Fix regex for finding datetree year subtree

* org-datetree.el (org-datetree-find-year-create): Use
  `org-datetree-base-level' in the regex to find year subtree.

On Sat, Feb 5, 2011 at 9:57 AM, Puneeth Chaganti wrote:
>
>> On Sat, Feb 5, 2011 at 6:02 AM, Charles Cave wrote:
>> In early January I posted what I thought was a bug report with org-capture.
>>
>> I found that capturing to a date-tree didn't always work and in one file the
>> capture was written to the wrong place.
>>
>> Well, the problem was with the data!  One of my headings began with 2011.
>>
>> The tree looked something like this (edited)
>>
>> * 2010
>> ** 2010-12 December
>> *** 2010-12-05 Sunday
>> **** A heading
>> **** 2011 Actions  <---------- this caused the problem
>> **** Another heading
>> ...
>> *** 2010-12-06 Monday
>> ...
>> ...
>>
>>
> In 2011 when I captured into this file's date-tree,
> org-capture found the headline 2011 Actions which matched the algorithm
> and the captured item appeared at the end of the headings at that level.
>
>> My suggestion to eliminate the problem is to modify the org-capture algorithm
>> so years have to match beginning of line + one asterisk + one space + the year
>>
>> Similarly, months could match beginning of line + two asterisks + one space +
>> the year + hyphen + month number + space + Monthname.    But the chance of this
>> format heading appearing outside a date-tree would be very low.
>
> org-datetree currently checks if a buffer has an entry with a DATE_TREE
> property (any value), and if it finds one, the date tree will become a
> subtree under that entry.
>
> This change would break that feature.

Using the value of `org-datetree-base-level' in the regex instead of
checking for at least one star, or hard coding the number of stars (as
suggested by Charles Cave).

Also, only the regex for finding the year subtree needs to be changed,
since it is assumed that all the children of this subtree are
"generated" and there are no bad headings, like in Charles' example.
---
 lisp/org-datetree.el |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/lisp/org-datetree.el b/lisp/org-datetree.el
index 8014f8f..5c48f86 100644
--- a/lisp/org-datetree.el
+++ b/lisp/org-datetree.el
@@ -64,7 +64,8 @@ tree can be found."
       (goto-char (prog1 (point) (widen))))))
 
 (defun org-datetree-find-year-create (year)
-  (let ((re "^\\*+[ \t]+\\([12][0-9][0-9][0-9]\\)[ \t\n]")
+  (let* ((n org-datetree-base-level)
+	(re (format "^\\*\\{%s\\}[ \t]+\\([12][0-9][0-9][0-9]\\)[ \t\n]" n))
 	match)
     (goto-char (point-min))
     (while (and (setq match (re-search-forward re nil t))
-- 
1.7.3.5


[-- Attachment #3: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH] Solved the problem of org-capture apparently not working
  2011-02-05  6:48   ` [PATCH] " Puneeth Chaganti
@ 2011-02-08 18:50     ` Puneeth Chaganti
  2011-02-10 14:56     ` Bastien
  1 sibling, 0 replies; 7+ messages in thread
From: Puneeth Chaganti @ 2011-02-08 18:50 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1578 bytes --]

Hi,

Resending the patch, since it seems like patchwork hasn't grabbed it.

--
Puneeth


---------- Forwarded message ----------
From: Puneeth Chaganti <punchagan@gmail.com>
Date: Sat, Feb 5, 2011 at 12:18 PM
Subject: Re: [Orgmode] [PATCH] Solved the problem of org-capture
apparently not working
To: Charles Cave <charles.cave@gmail.com>
Cc: emacs-orgmode@gnu.org


Hi,

On Sat, Feb 5, 2011 at 9:57 AM, Puneeth Chaganti <punchagan@gmail.com> wrote:
> Hi,
>
> On Sat, Feb 5, 2011 at 6:02 AM, Charles Cave <charles.cave@gmail.com> wrote:
> [..]
>> My suggestion to eliminate the problem is to modify the org-capture algorithm
>> so years have to match beginning of line + one asterisk + one space + the year
>>
>> Similarly, months could match beginning of line + two asterisks + one space +
>> the year + hyphen + month number + space + Monthname.    But the chance of this
>> format heading appearing outside a date-tree would be very low.
>
> org-datetree currently checks if a buffer has an entry with a DATE_TREE
> property (any value), and if it finds one, the date tree will become a
> subtree under that entry.
>
> This change would break that feature.


Attached is a patch that fixes this, by using the
org-datetree-base-level variable. More details in the commit message.

@Bastien,

I didn't get the time to configure and use git-send-email. I am
sending a patch obtained using git-format-patch. So, you will have to
use git-am to apply this. (of course, if this seems good enough :))

-- Puneeth



-- 
Puneeth

[-- Attachment #2: 0001-Fix-regex-for-finding-datetree-year-subtree.patch.txt --]
[-- Type: text/plain, Size: 2828 bytes --]

From ab7961c3cea92271d803fdb3df89663e9c9a88ab Mon Sep 17 00:00:00 2001
From: Puneeth Chaganti <punchagan@gmail.com>
Date: Sat, 5 Feb 2011 12:08:10 +0530
Subject: [PATCH] Fix regex for finding datetree year subtree

* org-datetree.el (org-datetree-find-year-create): Use
  `org-datetree-base-level' in the regex to find year subtree.

On Sat, Feb 5, 2011 at 9:57 AM, Puneeth Chaganti wrote:
>
>> On Sat, Feb 5, 2011 at 6:02 AM, Charles Cave wrote:
>> In early January I posted what I thought was a bug report with org-capture.
>>
>> I found that capturing to a date-tree didn't always work and in one file the
>> capture was written to the wrong place.
>>
>> Well, the problem was with the data!  One of my headings began with 2011.
>>
>> The tree looked something like this (edited)
>>
>> * 2010
>> ** 2010-12 December
>> *** 2010-12-05 Sunday
>> **** A heading
>> **** 2011 Actions  <---------- this caused the problem
>> **** Another heading
>> ...
>> *** 2010-12-06 Monday
>> ...
>> ...
>>
>>
> In 2011 when I captured into this file's date-tree,
> org-capture found the headline 2011 Actions which matched the algorithm
> and the captured item appeared at the end of the headings at that level.
>
>> My suggestion to eliminate the problem is to modify the org-capture algorithm
>> so years have to match beginning of line + one asterisk + one space + the year
>>
>> Similarly, months could match beginning of line + two asterisks + one space +
>> the year + hyphen + month number + space + Monthname.    But the chance of this
>> format heading appearing outside a date-tree would be very low.
>
> org-datetree currently checks if a buffer has an entry with a DATE_TREE
> property (any value), and if it finds one, the date tree will become a
> subtree under that entry.
>
> This change would break that feature.

Using the value of `org-datetree-base-level' in the regex instead of
checking for at least one star, or hard coding the number of stars (as
suggested by Charles Cave).

Also, only the regex for finding the year subtree needs to be changed,
since it is assumed that all the children of this subtree are
"generated" and there are no bad headings, like in Charles' example.
---
 lisp/org-datetree.el |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/lisp/org-datetree.el b/lisp/org-datetree.el
index 8014f8f..5c48f86 100644
--- a/lisp/org-datetree.el
+++ b/lisp/org-datetree.el
@@ -64,7 +64,8 @@ tree can be found."
       (goto-char (prog1 (point) (widen))))))
 
 (defun org-datetree-find-year-create (year)
-  (let ((re "^\\*+[ \t]+\\([12][0-9][0-9][0-9]\\)[ \t\n]")
+  (let* ((n org-datetree-base-level)
+	(re (format "^\\*\\{%s\\}[ \t]+\\([12][0-9][0-9][0-9]\\)[ \t\n]" n))
 	match)
     (goto-char (point-min))
     (while (and (setq match (re-search-forward re nil t))
-- 
1.7.3.5


[-- Attachment #3: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: Solved the problem of org-capture apparently not working
  2011-02-05  0:32 Solved the problem of org-capture apparently not working Charles Cave
  2011-02-05  4:27 ` Puneeth Chaganti
@ 2011-02-10 14:55 ` Bastien
  1 sibling, 0 replies; 7+ messages in thread
From: Bastien @ 2011-02-10 14:55 UTC (permalink / raw)
  To: Charles Cave; +Cc: emacs-orgmode

Charles Cave <charles.cave@gmail.com> writes:

> In early January I posted what I thought was a bug report with
> org-capture.

Fixed, thanks!

-- 
 Bastien

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Solved the problem of org-capture apparently not working
  2011-02-05  6:48   ` [PATCH] " Puneeth Chaganti
  2011-02-08 18:50     ` Puneeth Chaganti
@ 2011-02-10 14:56     ` Bastien
  2011-02-10 15:13       ` Puneeth Chaganti
  1 sibling, 1 reply; 7+ messages in thread
From: Bastien @ 2011-02-10 14:56 UTC (permalink / raw)
  To: Puneeth Chaganti; +Cc: emacs-orgmode, Charles Cave

Hi Puneeth,

Puneeth Chaganti <punchagan@gmail.com> writes:

> Attached is a patch that fixes this, by using the
> org-datetree-base-level variable. More details in the commit message.

I applied a more general solution for years, months and days datetrees.
Thanks for your patch anyway, it helped me better understand the issue!

> I didn't get the time to configure and use git-send-email. I am
> sending a patch obtained using git-format-patch. So, you will have to
> use git-am to apply this. (of course, if this seems good enough :))

It is good enough, no worry :)

-- 
 Bastien

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Solved the problem of org-capture apparently not working
  2011-02-10 14:56     ` Bastien
@ 2011-02-10 15:13       ` Puneeth Chaganti
  0 siblings, 0 replies; 7+ messages in thread
From: Puneeth Chaganti @ 2011-02-10 15:13 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode, Charles Cave

Hi,

On Thu, Feb 10, 2011 at 8:26 PM, Bastien <bastien.guerry@wikimedia.fr> wrote:
> Hi Puneeth,
>
> Puneeth Chaganti <punchagan@gmail.com> writes:
>
>> Attached is a patch that fixes this, by using the
>> org-datetree-base-level variable. More details in the commit message.
>
> I applied a more general solution for years, months and days datetrees.
> Thanks for your patch anyway, it helped me better understand the issue!

Thanks. I like the way, it's been fixed. :)

-- 
Puneeth

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-02-10 15:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-05  0:32 Solved the problem of org-capture apparently not working Charles Cave
2011-02-05  4:27 ` Puneeth Chaganti
2011-02-05  6:48   ` [PATCH] " Puneeth Chaganti
2011-02-08 18:50     ` Puneeth Chaganti
2011-02-10 14:56     ` Bastien
2011-02-10 15:13       ` Puneeth Chaganti
2011-02-10 14:55 ` Bastien

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.