emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Refresh appointments from org files exclusively
@ 2014-09-06 22:38 Jorge A. Alfaro-Murillo
  0 siblings, 0 replies; only message in thread
From: Jorge A. Alfaro-Murillo @ 2014-09-06 22:38 UTC (permalink / raw)
  To: emacs-orgmode

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

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. 


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-agenda.el-Refresh-appointments-from-org-files.patch --]
[-- Type: text/x-diff, Size: 2388 bytes --]

From 2a5bf43b8ce112eab30df55f25e1744a7b388d64 Mon Sep 17 00:00:00 2001
From: "Jorge A. Alfaro Murillo" <jorge.alfaro-murillo@yale.edu>
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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2014-09-06 22:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-06 22:38 [PATCH] Refresh appointments from org files exclusively Jorge A. Alfaro-Murillo

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