From mboxrd@z Thu Jan 1 00:00:00 1970 From: jorge.alfaro-murillo@yale.edu (Jorge A. Alfaro-Murillo) Subject: [PATCH] Refresh appointments from org files exclusively Date: Sat, 06 Sep 2014 18:38:26 -0400 Message-ID: <87zjecnzml.fsf@yale.edu> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:50089) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XQOde-0003zP-3f for emacs-orgmode@gnu.org; Sat, 06 Sep 2014 18:39:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XQOdY-0008TZ-31 for emacs-orgmode@gnu.org; Sat, 06 Sep 2014 18:39:22 -0400 Received: from plane.gmane.org ([80.91.229.3]:48686) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XQOdX-0008TV-SH for emacs-orgmode@gnu.org; Sat, 06 Sep 2014 18:39:16 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1XQOdV-0007A5-DP for emacs-orgmode@gnu.org; Sun, 07 Sep 2014 00:39:13 +0200 Received: from nat-130-132-173-153.central.yale.edu ([130.132.173.153]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 07 Sep 2014 00:39:13 +0200 Received: from jorge.alfaro-murillo by nat-130-132-173-153.central.yale.edu with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 07 Sep 2014 00:39:13 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain; format=flowed 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. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-org-agenda.el-Refresh-appointments-from-org-files.patch >From 2a5bf43b8ce112eab30df55f25e1744a7b388d64 Mon Sep 17 00:00:00 2001 From: "Jorge A. Alfaro Murillo" 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 --=-=-=--