emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Makes diary sexps appear correct in agenda views.
@ 2009-02-19 15:27 Mikael Fornius
  2009-02-19 17:25 ` Mikael Fornius
  2009-02-20 10:05 ` [PATCH] Makes diary sexps appear correct in agenda views Carsten Dominik
  0 siblings, 2 replies; 5+ messages in thread
From: Mikael Fornius @ 2009-02-19 15:27 UTC (permalink / raw)
  To: emacs-orgmode

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

Fixes a problem with some diary-sexps not occuring correct or not
showing up at all in agenda view. (More description in the attached
patch.)

I hope it will be useful!

Org-mode is a great mode.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Makes-diary-sexps-appear-correct-in-agenda-views.patch --]
[-- Type: text/x-patch, Size: 2562 bytes --]

From 0f05f81034eefeca63fd03f841c22a89357f3768 Mon Sep 17 00:00:00 2001
From: Mikael Fornius <mfo@abc.se>
Date: Thu, 19 Feb 2009 15:54:05 +0100
Subject: [PATCH] Makes diary sexps appear correct in agenda views.

Advanced sexps did not show up because of problem in
org-agenda-get-sexps. Now:

When no additional text in sexp-entry it uses the headline text in
agenda:

* Today is the 17th
<%%(diary-date 17 t t)>
<%%(diary-date 18 t t) Now it is the 18th.>
* Birthdays
<%%(diary-anniversary 3 3 1979) Adam becomes %d years old!>

The first is formatted with "Today is the 17th" in the agenda view,
the second sexp as "Now it is the 18th." (not with the heading) and
the anniversary as "Adam becomes 30 years old!".
---
 lisp/org-agenda.el |   23 ++++++++++-------------
 1 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 40fc456..a67081a 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -3504,7 +3504,7 @@ the documentation of `org-diary'."
 		      'help-echo
 		      (format "mouse-2 or RET jump to org file %s"
 			      (abbreviate-file-name buffer-file-name))))
-	 (regexp "^&?%%(")
+	 (regexp "<%%(")
 	 marker category ee txt tags entry result beg b sexp sexp-entry
 	 todo-state)
     (goto-char (point-min))
@@ -3516,7 +3516,7 @@ the documentation of `org-diary'."
 	(setq b (point))
 	(forward-sexp 1)
 	(setq sexp (buffer-substring b (point)))
-	(setq sexp-entry (if (looking-at "[ \t]*\\(\\S-.*\\)")
+	(setq sexp-entry (if (looking-at "[ \t]*\\(\\S-.*\\)>")
 			     (org-trim (match-string 1))
 			   ""))
 	(setq result (org-diary-sexp-entry sexp sexp-entry date))
@@ -3525,17 +3525,14 @@ the documentation of `org-diary'."
 		category (org-get-category beg)
 		todo-state (org-get-todo-state))
 
-	  (if (string-match "\\S-" result)
-	      (setq txt result)
-	    (setq txt "SEXP entry returned empty string"))
-
-	  (setq txt (org-format-agenda-item
-                     "" txt category tags 'time))
-	  (org-add-props txt props 'org-marker marker)
-	  (org-add-props txt nil
-	    'org-category category 'date date 'todo-state todo-state
-	    'type "sexp")
-	  (push txt ee))))
+	  (when (string-match "\\S-" result)
+	      (setq txt (org-format-agenda-item
+			 "" result category tags 'time))
+	      (org-add-props txt props 'org-marker marker)
+	      (org-add-props txt nil
+		'org-category category 'date date 'todo-state todo-state
+		'type "sexp")
+	      (push txt ee)))))
     (nreverse ee)))
 
 (defalias 'org-get-closed 'org-agenda-get-progress)
-- 
1.5.6


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


-- 
Mikael Fornius

[-- Attachment #4: Type: text/plain, Size: 204 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Remember: 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] 5+ messages in thread

* Re: [PATCH] Makes diary sexps appear correct in agenda views.
  2009-02-19 15:27 [PATCH] Makes diary sexps appear correct in agenda views Mikael Fornius
@ 2009-02-19 17:25 ` Mikael Fornius
  2009-02-20 10:29   ` Diary sexps in agenda Mikael Fornius
  2009-02-20 10:05 ` [PATCH] Makes diary sexps appear correct in agenda views Carsten Dominik
  1 sibling, 1 reply; 5+ messages in thread
From: Mikael Fornius @ 2009-02-19 17:25 UTC (permalink / raw)
  To: emacs-orgmode

(I reply my own post.)

When giving the problem a second thougt I realize that there may be
something to it that I do no understand fully.

The <%%(-sexps has worked properly before in earlier versions of org and
the regexp

> -	 (regexp "^&?%%(")

makes me think that there is more because I find the ampersand hard to
understand or motivate.

My patch works for me but maybe there is something else to it.

If it is so that the agenda should be able to read and interpret emacs
calendar ~/diary file also?, then my suggested patch is no good solution.



-- 
Mikael Fornius

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

* Re: [PATCH] Makes diary sexps appear correct in agenda views.
  2009-02-19 15:27 [PATCH] Makes diary sexps appear correct in agenda views Mikael Fornius
  2009-02-19 17:25 ` Mikael Fornius
@ 2009-02-20 10:05 ` Carsten Dominik
  2009-02-20 10:35   ` Mikael Fornius
  1 sibling, 1 reply; 5+ messages in thread
From: Carsten Dominik @ 2009-02-20 10:05 UTC (permalink / raw)
  To: Mikael Fornius; +Cc: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 4062 bytes --]


Hi Michael,

The <%%(diary-function)> format is really for DEADLINE and scheduled.

If you want to use diary-like entries, also including the text
after the function call, the idea is that you place these lines
directly in the buffer, exactly like you would in the diary buffer:

* Today is the 17th
%%(diary-date 17 t t)
%%(diary-date 18 t t) Now it is the 18th.
* Birthdays
%%(diary-anniversary 3 3 1979) Adam becomes %d years old!

> The <%%(-sexps has worked properly before in earlier versions of org  
> and
> the regexp
>
>> -	 (regexp "^&?%%(")
>
> makes me think that there is more because I find the ampersand hard to
> understand or motivate.

The ampersand is allowed because it has a function in diary buffers.
It has no function in Org buffers, but this allows you
to copy and paste diary lines into Org buffers without further
modifications.

HTH

- Carsten


On Feb 19, 2009, at 4:27 PM, Mikael Fornius wrote:

> Fixes a problem with some diary-sexps not occuring correct or not
> showing up at all in agenda view. (More description in the attached
> patch.)
>
> I hope it will be useful!
>
> Org-mode is a great mode.
>
> From 0f05f81034eefeca63fd03f841c22a89357f3768 Mon Sep 17 00:00:00 2001
> From: Mikael Fornius <mfo@abc.se>
> Date: Thu, 19 Feb 2009 15:54:05 +0100
> Subject: [PATCH] Makes diary sexps appear correct in agenda views.
>
> Advanced sexps did not show up because of problem in
> org-agenda-get-sexps. Now:
>
> When no additional text in sexp-entry it uses the headline text in
> agenda:
>
> * Today is the 17th
> <%%(diary-date 17 t t)>
> <%%(diary-date 18 t t) Now it is the 18th.>
> * Birthdays
> <%%(diary-anniversary 3 3 1979) Adam becomes %d years old!>
>
> The first is formatted with "Today is the 17th" in the agenda view,
> the second sexp as "Now it is the 18th." (not with the heading) and
> the anniversary as "Adam becomes 30 years old!".
> ---
> lisp/org-agenda.el |   23 ++++++++++-------------
> 1 files changed, 10 insertions(+), 13 deletions(-)
>
> diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
> index 40fc456..a67081a 100644
> --- a/lisp/org-agenda.el
> +++ b/lisp/org-agenda.el
> @@ -3504,7 +3504,7 @@ the documentation of `org-diary'."
> 		      'help-echo
> 		      (format "mouse-2 or RET jump to org file %s"
> 			      (abbreviate-file-name buffer-file-name))))
> -	 (regexp "^&?%%(")
> +	 (regexp "<%%(")
> 	 marker category ee txt tags entry result beg b sexp sexp-entry
> 	 todo-state)
>     (goto-char (point-min))
> @@ -3516,7 +3516,7 @@ the documentation of `org-diary'."
> 	(setq b (point))
> 	(forward-sexp 1)
> 	(setq sexp (buffer-substring b (point)))
> -	(setq sexp-entry (if (looking-at "[ \t]*\\(\\S-.*\\)")
> +	(setq sexp-entry (if (looking-at "[ \t]*\\(\\S-.*\\)>")
> 			     (org-trim (match-string 1))
> 			   ""))
> 	(setq result (org-diary-sexp-entry sexp sexp-entry date))
> @@ -3525,17 +3525,14 @@ the documentation of `org-diary'."
> 		category (org-get-category beg)
> 		todo-state (org-get-todo-state))
>
> -	  (if (string-match "\\S-" result)
> -	      (setq txt result)
> -	    (setq txt "SEXP entry returned empty string"))
> -
> -	  (setq txt (org-format-agenda-item
> -                     "" txt category tags 'time))
> -	  (org-add-props txt props 'org-marker marker)
> -	  (org-add-props txt nil
> -	    'org-category category 'date date 'todo-state todo-state
> -	    'type "sexp")
> -	  (push txt ee))))
> +	  (when (string-match "\\S-" result)
> +	      (setq txt (org-format-agenda-item
> +			 "" result category tags 'time))
> +	      (org-add-props txt props 'org-marker marker)
> +	      (org-add-props txt nil
> +		'org-category category 'date date 'todo-state todo-state
> +		'type "sexp")
> +	      (push txt ee)))))
>     (nreverse ee)))
>
> (defalias 'org-get-closed 'org-agenda-get-progress)
> -- 
> 1.5.6
>
>
> -- 
> Mikael Fornius
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode


[-- Attachment #1.2: Type: text/html, Size: 8540 bytes --]

[-- Attachment #2: Type: text/plain, Size: 204 bytes --]

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

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

* Diary sexps in agenda
  2009-02-19 17:25 ` Mikael Fornius
@ 2009-02-20 10:29   ` Mikael Fornius
  0 siblings, 0 replies; 5+ messages in thread
From: Mikael Fornius @ 2009-02-20 10:29 UTC (permalink / raw)
  To: emacs-orgmode

(The patch is wrong, I had misunderstood, as I suspected, sorry.)

The problem was that I used < and > around the diary sexp when you
apparently should not.

You can but then the line after the sexp is not showed in the agenda.

It works correct if %%(...) is at beginning of line, with no <> braces.

But I first only knew of 

(info "(org) timestamps")

that says that you shound surround with <>. I later found the page

(info "(org) Weekly/Daily agenda")

who says not to, this maybe needs to be updated?

Or is this the intended behavior?

I think would best if agenda could handle both cases nicely. If you
think that it should be so I can give it another try, beware. :-)

Thanks!

-- 
Mikael Fornius

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

* Re: [PATCH] Makes diary sexps appear correct in agenda views.
  2009-02-20 10:05 ` [PATCH] Makes diary sexps appear correct in agenda views Carsten Dominik
@ 2009-02-20 10:35   ` Mikael Fornius
  0 siblings, 0 replies; 5+ messages in thread
From: Mikael Fornius @ 2009-02-20 10:35 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode

Thanks for you reply, I now understand that this is the intended beavior
and I should use %%( at beginnig of line.

I just found out my self :-) anyway
thanks a lot, now I am happy!

-- 
Mikael Fornius

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

end of thread, other threads:[~2009-02-20 10:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-19 15:27 [PATCH] Makes diary sexps appear correct in agenda views Mikael Fornius
2009-02-19 17:25 ` Mikael Fornius
2009-02-20 10:29   ` Diary sexps in agenda Mikael Fornius
2009-02-20 10:05 ` [PATCH] Makes diary sexps appear correct in agenda views Carsten Dominik
2009-02-20 10:35   ` Mikael Fornius

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).