emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] [PATCH] Refresh appointments from org files exclusively


From: Jorge A. Alfaro-Murillo
Subject: [O] [PATCH] Refresh appointments from org files exclusively
Date: Sat, 06 Sep 2014 18:38:26 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux)

Hi,

I sometimes use appt-add as an alarm clock, as it is described in (info "(emacs) Appointments"). Recently I started using org-agenda-to-appt, and I wanted to update my appointments every time that I call the agenda, something like:

#+BEGIN_SRC emacs-lisp
(add-hook 'org-agenda-finalize-hook (lambda () (org-agenda-to-appt t))) #+END_SRC

But this removes the entries that appt-add has added, in other words it removes my alarms.

The attached patch permits that, when refreshing, only appointments that have the text property org-headline set to t are deleted. So it would leave any appointments set by appt-add. I do not know if all the entries that org-agenda-to-appt adds have an org-headline set to t, from my tests it seems like that is the case.

The functionality has backward compatibility (uses C-u C-u), but perhaps it would make more sense to use C-u for refreshing only org entries and C-u C-u for refreshing everything, or even never setting appt-time-msg-list to nil from org.

If the patch is approved to refresh the appointments after every agenda buffer is built while keeping those appointments added by appt-add, you can do:

#+BEGIN_SRC emacs-lisp
(add-hook 'org-agenda-finalize-hook (lambda () (org-agenda-to-appt '(16)))) #+END_SRC

Best,

-- Jorge.
>From 2a5bf43b8ce112eab30df55f25e1744a7b388d64 Mon Sep 17 00:00:00 2001
From: "Jorge A. Alfaro Murillo" <address@hidden>
Date: Sat, 6 Sep 2014 18:01:20 -0400
Subject: [PATCH] org-agenda.el: Refresh appointments from org files

* lisp/org-agenda.el (org-agenda-to-appt): Double prefix arg refresh
only the list of appointments that come from org files.

Uses the text-properties in appt-time-msg-list to see if an entry has
an org-heading property.

TINYCHANGE
---
 lisp/org-agenda.el | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index bcbacf0..ff4a448 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -10046,7 +10046,9 @@ tag and (if present) the flagging note."
 (defun org-agenda-to-appt (&optional refresh filter &rest args)
   "Activate appointments found in `org-agenda-files'.
 With a \\[universal-argument] prefix, refresh the list of
-appointments.
+appointments. With a double prefix arg \\[universal-argument]
+\\[universal-argument], refresh only the list of appointments
+that come from org files.
 
 If FILTER is t, interactively prompt the user for a regular
 expression, and filter out entries that don't match it.
@@ -10076,7 +10078,15 @@ details and examples.
 If an entry has a APPT_WARNTIME property, its value will be used
 to override `appt-message-warning-time'."
   (interactive "P")
-  (if refresh (setq appt-time-msg-list nil))
+  (if (equal refresh '(4))
+      (setq appt-time-msg-list nil))
+  (if (equal refresh '(16))
+      (let (new-appt-time-msg-list)
+       (dolist (entry appt-time-msg-list)
+         (if (not (text-property-any 1 (length (cadr entry))
+                                     'org-heading t (cadr entry)))
+             (add-to-list 'new-appt-time-msg-list entry)))
+       (setq appt-time-msg-list new-appt-time-msg-list)))
   (if (eq filter t)
       (setq filter (read-from-minibuffer "Regexp filter: ")))
   (let* ((cnt 0) ; count added events
@@ -10119,8 +10129,6 @@ to override `appt-message-warning-time'."
                                 (and (stringp evt-filter)
                                      (string-match evt-filter evt)))))))
              (wrn (get-text-property 1 'warntime x)))
-        ;; FIXME: Shall we remove text-properties for the appt text?
-        ;; (setq evt (set-text-properties 0 (length evt) nil evt))
         (when (and ok tod)
           (setq tod (concat "00" (number-to-string tod))
                 tod (when (string-match
-- 
2.0.1


reply via email to

[Prev in Thread] Current Thread [Next in Thread]