From 91ee57eed1ee8ba1892abb668da8ea498f010cd9 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Tue, 26 Feb 2008 16:26:20 +0000 Subject: [PATCH 1/5] Fixed `org-agenda-to-appt'. Refresh the list of appointments. Don't include appointments of deadlines, unless the deadline is for today. (org-agenda-get-day-entries file today :timestamp :scheduled) should be enough, since :timestamp also returns deadlines for today. --- org.el | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/org.el b/org.el index f1fe3d7a2..01d2f8236 100644 --- a/org.el +++ b/org.el @@ -4195,6 +4195,8 @@ If it is less than 8, the level-1 face gets re-used for level N+1 etc." ;; FIXME: get the argument lists for the UNKNOWN stuff (declare-function add-to-diary-list "diary-lib" (date string specifier &optional marker globcolor literal)) +(defvar appt-time-msg-list) +(declare-function appt-check "appt" (&optional force)) (declare-function table--at-cell-p "table" (position &optional object at-column)) (declare-function Info-find-node "info" (filename nodename &optional no-going-back)) (declare-function Info-goto-node "info" (nodename &optional fork)) @@ -18577,7 +18579,6 @@ If there is already a time stamp at the cursor position, update it." (org-insert-time-stamp (encode-time 0 0 0 (nth 1 cal-date) (car cal-date) (nth 2 cal-date)))))) -;; Make appt aware of appointments from the agenda ;;;###autoload (defun org-agenda-to-appt (&optional filter) "Activate appointments found in `org-agenda-files'. @@ -18597,6 +18598,9 @@ will only add headlines containing IMPORTANT or headlines belonging to the category \"Work\"." (interactive "P") (require 'calendar) + (require 'appt) + (setq appt-time-msg-list nil) + (appt-check t) (if (equal filter '(4)) (setq filter (read-from-minibuffer "Regexp filter: "))) (let* ((cnt 0) ; count added events @@ -18609,10 +18613,9 @@ belonging to the category \"Work\"." (setq entries (append entries (org-agenda-get-day-entries - file today - :timestamp :scheduled :deadline)))) + file today :timestamp :scheduled)))) (setq entries (delq nil entries)) - ;; Map thru entries and find if they pass thru the filter + ;; Map thru entries and find if we should filter them out (mapc (lambda(x) (let* ((evt (org-trim (get-text-property 1 'txt x))) From 9e7b43d39190ec903cd8967e675307adb9e528b6 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Tue, 26 Feb 2008 18:06:39 +0000 Subject: [PATCH 2/5] Docstring fix for `org-deadline-warning-days'. Don't use (org-deadline-warning-days 0) in `org-agenda-to-appt'. Removing the :deadline property from the list of arguments in the `org-agenda-get-day-entries' call should be enough. Prevent `appt-check' from modifying the current window layout. --- org.el | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/org.el b/org.el index 6b3e0d31f..b10fb418e 100644 --- a/org.el +++ b/org.el @@ -2708,7 +2708,7 @@ nearest into the future." (defcustom org-deadline-warning-days 14 "No. of days before expiration during which a deadline becomes active. This variable governs the display in sparse trees and in the agenda. -When negative, it means use this number (the absolute value of it) +When negative or null, it means use the absolute value of this number even if a deadline has a different individual lead time specified." :group 'org-time :group 'org-agenda-daily/weekly @@ -18600,12 +18600,11 @@ belonging to the category \"Work\"." (require 'calendar) (require 'appt) (setq appt-time-msg-list nil) - (appt-check t) + (save-window-excursion (appt-check t)) (if (equal filter '(4)) (setq filter (read-from-minibuffer "Regexp filter: "))) (let* ((cnt 0) ; count added events (org-agenda-new-buffers nil) - (org-deadline-warning-days 0) (today (org-date-to-gregorian (time-to-days (current-time)))) (files (org-agenda-files)) entries file) From b6251cca8e604b61f39e85aace5659841ac48993 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Tue, 26 Feb 2008 18:11:28 +0000 Subject: [PATCH 3/5] Updated the ChangeLog against latest changes. --- ChangeLog | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ChangeLog b/ChangeLog index 7b6e676bc..7241c7242 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2008-02-26 Bastien Guerry + + * org.el (org-agenda-to-appt): Don't set + `org-deadline-warning-days' to nil, but use a different list of + arguments for `org-agenda-get-day-entries'. Also refresh the list + of appointments. + (org-deadline-warning-days): Mention the fact that a value of zero + will also be enforced. + 2008-02-26 Carsten Dominik * org.el (org-agenda-to-appt): Set `org-deadline-warning-days' to From 7c0d910bd89f1d21d20a403bfe912802fc72da1e Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Tue, 26 Feb 2008 19:37:46 +0000 Subject: [PATCH 4/5] Update `org-agenda-to-appt'. Added `refresh' as the first argument for this function. A value of `t' for the filter argument now means: prompt the user for a regular expression and filter out entries that don't match it. Don't run `appt-check' inside `org-agenda-to-appt' since appt-check might already find agenda appointments in the diary file if it contains (org-diary ...). Removed the declare-function for appt-check. Cleaned up the ChangeLog for these changes. --- ChangeLog | 11 ++++++----- org.el | 37 ++++++++++++++++++++----------------- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7241c7242..5c9b6900e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,11 +1,12 @@ 2008-02-26 Bastien Guerry - * org.el (org-agenda-to-appt): Don't set - `org-deadline-warning-days' to nil, but use a different list of - arguments for `org-agenda-get-day-entries'. Also refresh the list - of appointments. + * org.el (org-agenda-to-appt): New argument `refresh' let the user + delete previous appointments stored in `appt-time-msg-list'. + Remove :deadline from the args of `org-agenda-get-day-entries' + instead of setting `org-deadline-warning-days' to nil. (org-deadline-warning-days): Mention the fact that a value of zero - will also be enforced. + will be treated like negative values. + (org-show-todo-tree): Fix a small typo in the docstring. 2008-02-26 Carsten Dominik diff --git a/org.el b/org.el index b10fb418e..7799ffbb2 100644 --- a/org.el +++ b/org.el @@ -2708,8 +2708,8 @@ nearest into the future." (defcustom org-deadline-warning-days 14 "No. of days before expiration during which a deadline becomes active. This variable governs the display in sparse trees and in the agenda. -When negative or null, it means use the absolute value of this number -even if a deadline has a different individual lead time specified." +When negative or null, use the absolute value of this number even if +a deadline has a different individual lead time specified." :group 'org-time :group 'org-agenda-daily/weekly :type 'number) @@ -4195,8 +4195,6 @@ If it is less than 8, the level-1 face gets re-used for level N+1 etc." ;; FIXME: get the argument lists for the UNKNOWN stuff (declare-function add-to-diary-list "diary-lib" (date string specifier &optional marker globcolor literal)) -(defvar appt-time-msg-list) -(declare-function appt-check "appt" (&optional force)) (declare-function table--at-cell-p "table" (position &optional object at-column)) (declare-function Info-find-node "info" (filename nodename &optional no-going-back)) (declare-function Info-goto-node "info" (nodename &optional fork)) @@ -14856,7 +14854,7 @@ This function should be run in the `org-after-todo-state-change-hook'." "Make a compact tree which shows all headlines marked with TODO. The tree will show the lines where the regexp matches, and all higher headlines above the match. -With \\[universal-argument] prefix, also show the DONE entries. +With a \\[universal-argument] prefix, also show the DONE entries. With a numeric prefix N, construct a sparse tree for the Nth element of `org-todo-keywords-1'." (interactive "P") @@ -18579,29 +18577,32 @@ If there is already a time stamp at the cursor position, update it." (org-insert-time-stamp (encode-time 0 0 0 (nth 1 cal-date) (car cal-date) (nth 2 cal-date)))))) +(defvar appt-time-msg-list) + ;;;###autoload -(defun org-agenda-to-appt (&optional filter) +(defun org-agenda-to-appt (&optional refresh filter) "Activate appointments found in `org-agenda-files'. -When prefixed, prompt for a regular expression and use it as a -filter: only add entries if they match this regular expression. +With a \\[universal-argument] prefix, refresh the list of +appointements. -FILTER can be a string. In this case, use this string as a -regular expression to filter results. +If FILTER is t, interactively prompt the user for a regular +expression, and filter out entries that don't match it. -FILTER can also be an alist, with the car of each cell being +If FILTER is a string, use this string as a regular expression +for filtering entries out. + +FILTER can also be an alist with the car of each cell being either 'headline or 'category. For example: '((headline \"IMPORTANT\") (category \"Work\")) will only add headlines containing IMPORTANT or headlines -belonging to the category \"Work\"." +belonging to the \"Work\" category." (interactive "P") (require 'calendar) - (require 'appt) - (setq appt-time-msg-list nil) - (save-window-excursion (appt-check t)) - (if (equal filter '(4)) + (if refresh (setq appt-time-msg-list nil)) + (if (eq filter t) (setq filter (read-from-minibuffer "Regexp filter: "))) (let* ((cnt 0) ; count added events (org-agenda-new-buffers nil) @@ -18639,7 +18640,9 @@ belonging to the category \"Work\"." (appt-add tod evt) (setq cnt (1+ cnt))))) entries) (org-release-buffers org-agenda-new-buffers) - (message "Added %d event%s for today" cnt (if (> cnt 1) "s" "")))) + (if (eq cnt 0) + (message "No event to add") + (message "Added %d event%s for today" cnt (if (> cnt 1) "s" ""))))) ;;; The clock for measuring work time. From ea1af6f855db12fdcff4ea7847e2d54851784012 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Tue, 26 Feb 2008 23:25:36 +0000 Subject: [PATCH 5/5] Reverted the changes about the use of `org-deadline-warning-days' in `org-agenda-to-appt'. --- ChangeLog | 2 -- org.el | 3 ++- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5c9b6900e..718ce275c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,8 +2,6 @@ * org.el (org-agenda-to-appt): New argument `refresh' let the user delete previous appointments stored in `appt-time-msg-list'. - Remove :deadline from the args of `org-agenda-get-day-entries' - instead of setting `org-deadline-warning-days' to nil. (org-deadline-warning-days): Mention the fact that a value of zero will be treated like negative values. (org-show-todo-tree): Fix a small typo in the docstring. diff --git a/org.el b/org.el index 7799ffbb2..0c2762d27 100644 --- a/org.el +++ b/org.el @@ -18606,6 +18606,7 @@ belonging to the \"Work\" category." (setq filter (read-from-minibuffer "Regexp filter: "))) (let* ((cnt 0) ; count added events (org-agenda-new-buffers nil) + (org-deadline-warning-days 0) (today (org-date-to-gregorian (time-to-days (current-time)))) (files (org-agenda-files)) entries file) @@ -18614,7 +18615,7 @@ belonging to the \"Work\" category." (setq entries (append entries (org-agenda-get-day-entries - file today :timestamp :scheduled)))) + file today :timestamp :scheduled :deadline)))) (setq entries (delq nil entries)) ;; Map thru entries and find if we should filter them out (mapc