emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] fix appointment warn time
@ 2013-04-26 16:17 Ivan Kanis
  2013-04-26 17:01 ` Bastien
  0 siblings, 1 reply; 15+ messages in thread
From: Ivan Kanis @ 2013-04-26 16:17 UTC (permalink / raw)
  To: org mode

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

It seemed to be a boundary error. (point) was at the end of the
timestamp which doesn't hold the org-appt-warntime property.

foo.org illustrate what I have seen. Evaling the get-property sexp
returns nil.

The patch adds a function that goes at the beginning of the header to
get the property. As a bonus it turns the string into a number.

Please let me know if the patch is accepted or needs improvement.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: warntime.diff --]
[-- Type: text/x-patch, Size: 2005 bytes --]

diff --git a/emacs/org/org-agenda.el b/emacs/org/org-agenda.el
index 631c6d0..a826b26 100644
--- a/emacs/org/org-agenda.el
+++ b/emacs/org/org-agenda.el
@@ -5425,6 +5425,14 @@ the documentation of `org-diary'."
 	  (org-end-of-subtree 'invisible))))
     (nreverse ee)))
 
+(defun org-agenda-get-warntime ()
+  "Return warn time number when the property exists."
+  (save-excursion
+    (org-back-to-heading t)
+    (let ((warntime (get-text-property (point) 'org-appt-warntime)))
+      (when warntime
+        (string-to-number warntime)))))
+  
 (defun org-agenda-todo-custom-ignore-p (time n)
   "Check whether timestamp is farther away than n number of days.
 This function is invoked if `org-agenda-todo-ignore-deadlines',
@@ -5570,7 +5578,7 @@ This function is invoked if `org-agenda-todo-ignore-deadlines',
 	      clockp (and org-agenda-include-inactive-timestamps
 			  (or (string-match org-clock-string tmp)
 			      (string-match "]-+\\'" tmp)))
-	      warntime (get-text-property (point) 'org-appt-warntime)
+	      warntime (org-agenda-get-warntime)
 	      donep (member todo-state org-done-keywords))
 	(if (or scheduledp deadlinep closedp clockp
 		(and donep org-agenda-skip-timestamp-if-done))
@@ -5659,7 +5667,7 @@ This function is invoked if `org-agenda-todo-ignore-deadlines',
 			     (memq 'agenda org-agenda-use-tag-inheritance))))
 		tags (org-get-tags-at nil (not inherited-tags))
 		todo-state (org-get-todo-state)
-		warntime (get-text-property (point) 'org-appt-warntime)
+                warntime (org-agenda-get-warntime)
 		extra nil)
 
 	  (dolist (r (if (stringp result)
@@ -6059,7 +6067,7 @@ specification like [h]h:mm."
 			   (not (= diff 0))))
 		  (setq txt nil)
 		(setq category (org-get-category)
-		      warntime (get-text-property (point) 'org-appt-warntime)
+		      warntime (org-agenda-get-warntime)
 		      category-pos (get-text-property (point) 'org-category-position))
 		(if (not (re-search-backward "^\\*+[ \t]+" nil t))
 		    (throw :skip nil)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: foo.org --]
[-- Type: text/x-org, Size: 175 bytes --]

** TPIT with Jean-Philippe at San Francisco <2013-01-18 Fri 15:00 +1w>
   :PROPERTIES:
   :APPT_WARNTIME: 5
   :END:

(get-text-property 71 'org-appt-warntime)
(goto-char 71)

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

end of thread, other threads:[~2013-05-14 15:18 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-26 16:17 [PATCH] fix appointment warn time Ivan Kanis
2013-04-26 17:01 ` Bastien
2013-04-27  8:34   ` Ivan Kanis
2013-04-27 12:02     ` Bastien
2013-04-28  8:48       ` Ivan Kanis
2013-04-28  8:59         ` Bastien
2013-04-28 19:57           ` Ivan Kanis
2013-05-14  8:36             ` Bastien
2013-05-14 11:46               ` Ivan Kanis
2013-05-14 11:49                 ` Bastien
2013-05-14 12:10                   ` Ivan Kanis
2013-05-14 13:20                     ` Miguel Ruiz
2013-05-14 14:08                       ` Bastien
2013-05-14 15:06                         ` Ivan Kanis
2013-05-14 15:18                           ` Bastien

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