From de588512d3ac338cf675b83c90f834af2cf111db Mon Sep 17 00:00:00 2001 From: James TD Smith Date: Sat, 7 Nov 2009 10:37:14 +0000 Subject: [PATCH 1/3] Fix a bug in org-link-display-format. It would break if there was a '\' in the link description. --- lisp/ChangeLog | 4 ++++ lisp/org.el | 9 +++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 112e0bc53..0ce2d5079 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -72,6 +72,10 @@ * org-docbook.el (org-export-as-docbook): Protect targets in verbatim emphasis. +2009-11-07 James TD Smith + + * org.el (org-link-display-format): Should be literal replacement. + 2009-11-06 Carsten Dominik * org-clock.el (org-show-notification): Handle messages that diff --git a/lisp/org.el b/lisp/org.el index c0afd10b2..ed32b94b0 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -17575,10 +17575,11 @@ Show the heading too, if it is currently invisible." if no description is present" (save-match-data (if (string-match org-bracket-link-analytic-regexp link) - (replace-match (or (match-string 5 link) - (concat (match-string 1 link) - (match-string 3 link))) - nil nil link) + (replace-match (if (match-end 5) + (match-string 5 link) + (concat (match-string 1 link) + (match-string 3 link))) + nil t link) link))) ;; Speedbar support From b81fae4c3fa39a15bda5e58016fe9dec28e38c18 Mon Sep 17 00:00:00 2001 From: James TD Smith Date: Tue, 10 Nov 2009 02:42:17 +0000 Subject: [PATCH 2/3] More bugfixes for agenda column view Make org-agenda-columns-summarize work properly with the new summary types. It was assuming the values should be summarised by adding them together. It's now updated to use the summary functions in org-columns-compile-map, and also handles summary types with calculated values properly. Leave calculated columns blank if there is no underlying value. Don't return zero if a property is missing. Changes are also applied to xemacs colview. --- lisp/ChangeLog | 16 +++++++++ lisp/org-colview-xemacs.el | 63 +++++++++++++++++++++++++----------- lisp/org-colview.el | 66 ++++++++++++++++++++++++++------------ 3 files changed, 105 insertions(+), 40 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 0ce2d5079..a72824d1b 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,19 @@ +2009-11-12 James TD Smith + + * org-colview.el (org-columns-display-here): Don't try to + calculate values if the underlying property is not set. + (org-columns-string-to-number): Convert age strings back into + fractional days. + (org-agenda-colview-summarize): Handle extended summary types + properly. + + * org-colview-xemacs.el (org-columns-display-here): Don't try to + calculate values if the underlying property is not set. + (org-columns-string-to-number): Convert age strings back into + fractional days. + (org-agenda-colview-summarize): Handle extended summary types + properly. + 2009-11-11 Carsten Dominik * org-protocol.el (org-protocol-char-to-string): New defsubst. diff --git a/lisp/org-colview-xemacs.el b/lisp/org-colview-xemacs.el index 56325798a..289d94f8d 100644 --- a/lisp/org-colview-xemacs.el +++ b/lisp/org-colview-xemacs.el @@ -358,6 +358,7 @@ This is the compiled version of the format.") (org-agenda-columns-cleanup-item val pl cphr org-columns-current-fmt-compiled))) ((and calc (functionp calc) + (not (string= val "")) (not (get-text-property 0 'org-computed val))) (org-columns-number-to-string (funcall calc (org-columns-string-to-number @@ -1230,9 +1231,16 @@ Don't set this, this is meant for dynamic scoping.") (if s (cond ((memq fmt '(min_age max_age mean_age)) - (if (string= s "") - org-columns-time - (time-to-number-of-days (apply 'encode-time (org-parse-time-string s t))))) + (cond ((string= s "") org-columns-time) + ((string-match + "\\([0-9]+\\)d \\([0-9]+\\)h \\([0-9]+\\)m \\([0-9]+\\)s" + s) + (+ (* 60 (+ (* 60 (+ (* 24 (string-to-number (match-string 1 s))) + (string-to-number (match-string 2 s)))) + (string-to-number (match-string 3 s)))) + (string-to-number (match-string 4 s)))) + (t (time-to-number-of-days (apply 'encode-time + (org-parse-time-string s t)))))) ((string-match ":" s) (let ((l (nreverse (org-split-string s ":"))) (sum 0.0)) (while l @@ -1577,10 +1585,11 @@ and tailing newline characters." "Summarize the summarizable columns in column view in the agenda. This will add overlays to the date lines, to show the summary for each day." (let* ((fmt (mapcar (lambda (x) - (list (car x) (if (equal (car x) "CLOCKSUM") - 'add_times (nth 4 x)))) + (if (equal (car x) "CLOCKSUM") + (list "CLOCKSUM" (nth 2 x) add_times + identity) + (cdr x))) org-columns-current-fmt-compiled)) - line c c1 stype props lsum entries prop v) + line c c1 stype calc sumfunc props lsum entries prop v) (catch 'exit (when (delq nil (mapcar 'cadr fmt)) ;; OK, at least one summation column, it makes sense to try this @@ -1603,24 +1612,40 @@ This will add overlays to the date lines, to show the summary for each day." (setq props (mapcar (lambda (f) - (setq prop (car f) stype (nth 1 f)) + (setq prop (car f) + stype (nth 3 f) + sumfunc (nth 5 f) + calc (or (nth 6 f) 'identity)) (cond ((equal prop "ITEM") (cons prop (buffer-substring (point-at-bol) (point-at-eol)))) ((not stype) (cons prop "")) - (t - ;; do the summary - (setq lsum 0) - (mapc (lambda (x) - (setq v (cdr (assoc prop x))) - (if v (setq lsum (+ lsum - (org-columns-string-to-number - v stype))))) - entries) - (setq lsum (org-columns-number-to-string lsum stype)) - (put-text-property - 0 (length lsum) 'face 'bold lsum) + (t ;; do the summary + (setq lsum nil) + (dolist (x entries) + (setq v (cdr (assoc prop x))) + (if v + (push + (funcall + (if (not (get-text-property 0 'org-computed v)) + calc + 'identity) + (org-columns-string-to-number + v stype)) + lsum))) + (setq lsum (remove nil lsum)) + (setq lsum + (cond ((> (length lsum) 1) + (org-columns-number-to-string + (apply sumfunc lsum) stype)) + ((eq (length lsum) 1) + (org-columns-number-to-string + (car lsum) stype)) + (t ""))) + (put-text-property 0 (length lsum) 'face 'bold lsum) + (if (neq calc 'identity) + (put-text-property 0 (length lsum) 'org-computed t lsum)) (cons prop lsum)))) fmt)) (org-columns-display-here props) diff --git a/lisp/org-colview.el b/lisp/org-colview.el index 0785ac251..8a77cee96 100644 --- a/lisp/org-colview.el +++ b/lisp/org-colview.el @@ -203,6 +203,7 @@ This is the compiled version of the format.") (org-agenda-columns-cleanup-item val pl cphr org-columns-current-fmt-compiled))) ((and calc (functionp calc) + (not (string= val "")) (not (get-text-property 0 'org-computed val))) (org-columns-number-to-string (funcall calc (org-columns-string-to-number @@ -1044,9 +1045,16 @@ Don't set this, this is meant for dynamic scoping.") (if s (cond ((memq fmt '(min_age max_age mean_age)) - (if (string= s "") - org-columns-time - (time-to-number-of-days (apply 'encode-time (org-parse-time-string s t))))) + (cond ((string= s "") org-columns-time) + ((string-match + "\\([0-9]+\\)d \\([0-9]+\\)h \\([0-9]+\\)m \\([0-9]+\\)s" + s) + (+ (* 60 (+ (* 60 (+ (* 24 (string-to-number (match-string 1 s))) + (string-to-number (match-string 2 s)))) + (string-to-number (match-string 3 s)))) + (string-to-number (match-string 4 s)))) + (t (time-to-number-of-days (apply 'encode-time + (org-parse-time-string s t)))))) ((string-match ":" s) (let ((l (nreverse (org-split-string s ":"))) (sum 0.0)) (while l @@ -1054,8 +1062,7 @@ Don't set this, this is meant for dynamic scoping.") sum)) ((memq fmt '(checkbox checkbox-n-of-m checkbox-percent)) (if (equal s "[X]") 1. 0.000001)) - (t (string-to-number s))) - 0)) + (t (string-to-number s))))) (defun org-columns-uncompile-format (cfmt) "Turn the compiled columns format back into a string representation." @@ -1364,10 +1371,11 @@ and tailing newline characters." "Summarize the summarizable columns in column view in the agenda. This will add overlays to the date lines, to show the summary for each day." (let* ((fmt (mapcar (lambda (x) - (list (car x) (if (equal (car x) "CLOCKSUM") - 'add_times (nth 4 x)))) + (if (equal (car x) "CLOCKSUM") + (list "CLOCKSUM" (nth 2 x) add_times + identity) + (cdr x))) org-columns-current-fmt-compiled)) - line c c1 stype props lsum entries prop v) + line c c1 stype calc sumfunc props lsum entries prop v) (catch 'exit (when (delq nil (mapcar 'cadr fmt)) ;; OK, at least one summation column, it makes sense to try this @@ -1390,24 +1398,40 @@ This will add overlays to the date lines, to show the summary for each day." (setq props (mapcar (lambda (f) - (setq prop (car f) stype (nth 1 f)) + (setq prop (car f) + stype (nth 3 f) + sumfunc (nth 5 f) + calc (or (nth 6 f) 'identity)) (cond ((equal prop "ITEM") (cons prop (buffer-substring (point-at-bol) (point-at-eol)))) ((not stype) (cons prop "")) - (t - ;; do the summary - (setq lsum 0) - (mapc (lambda (x) - (setq v (cdr (assoc prop x))) - (if v (setq lsum (+ lsum - (org-columns-string-to-number - v stype))))) - entries) - (setq lsum (org-columns-number-to-string lsum stype)) - (put-text-property - 0 (length lsum) 'face 'bold lsum) + (t ;; do the summary + (setq lsum nil) + (dolist (x entries) + (setq v (cdr (assoc prop x))) + (if v + (push + (funcall + (if (not (get-text-property 0 'org-computed v)) + calc + 'identity) + (org-columns-string-to-number + v stype)) + lsum))) + (setq lsum (remove nil lsum)) + (setq lsum + (cond ((> (length lsum) 1) + (org-columns-number-to-string + (apply sumfunc lsum) stype)) + ((eq (length lsum) 1) + (org-columns-number-to-string + (car lsum) stype)) + (t ""))) + (put-text-property 0 (length lsum) 'face 'bold lsum) + (if (neq calc 'identity) + (put-text-property 0 (length lsum) 'org-computed t lsum)) (cons prop lsum)))) fmt)) (org-columns-display-here props 'dateline) From aeb35b79951ee54b45c963093fd63a65af546d65 Mon Sep 17 00:00:00 2001 From: James TD Smith Date: Thu, 12 Nov 2009 01:46:18 +0000 Subject: [PATCH 3/3] Improve error reporting in org-habit. Include the entry in the error messages in org-habit-parse-todo. This makes it much easier to find the heading you need to fix. --- lisp/ChangeLog | 3 +++ lisp/org-habit.el | 18 ++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a72824d1b..4b89fc767 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,8 @@ 2009-11-12 James TD Smith + * org-habit.el (org-habit-parse-todo): Indicate which habit is + wrongly set up in the error messages. + * org-colview.el (org-columns-display-here): Don't try to calculate values if the underlying property is not set. (org-columns-string-to-number): Convert age strings back into diff --git a/lisp/org-habit.el b/lisp/org-habit.el index 4bb311e2b..75bcc3801 100644 --- a/lisp/org-habit.el +++ b/lisp/org-habit.el @@ -149,19 +149,21 @@ This list represents a \"habit\" for the rest of this module." (scheduled-repeat (org-get-repeat org-scheduled-string)) (sr-days (org-habit-duration-to-days scheduled-repeat)) (end (org-entry-end-position)) + (habit-entry (org-no-properties (nth 5 (org-heading-components)))) closed-dates deadline dr-days) (if scheduled (setq scheduled (time-to-days scheduled)) - (error "Habit has no scheduled date")) + (error "Habit %s has no scheduled date" habit-entry)) (unless scheduled-repeat - (error "Habit has no scheduled repeat period")) + (error "Habit %s has no scheduled repeat period" habit-entry)) (unless (> sr-days 0) - (error "Habit's scheduled repeat period is less than 1d")) + (error "Habit %s scheduled repeat period is less than 1d" habit-entry)) (when (string-match "/\\([0-9]+[dwmy]\\)" scheduled-repeat) (setq dr-days (org-habit-duration-to-days (match-string-no-properties 1 scheduled-repeat))) (if (<= dr-days sr-days) - (error "Habit's deadline repeat period is less than or equal to scheduled")) + (error "Habit %s deadline repeat period is less than or equal to scheduled (%s)" + habit-entry scheduled-repeat)) (setq deadline (+ scheduled (- dr-days sr-days)))) (org-back-to-heading t) (while (re-search-forward "- State \"DONE\".*\\[\\([^]]+\\)\\]" end t) @@ -218,13 +220,13 @@ SCHEDULED-DAYS defaults to the habit's actual scheduled days if nil. Habits are assigned colors on the following basis: Blue Task is before the scheduled date. Green Task is on or after scheduled date, but before the - end of the schedule's repeat period. + end of the schedule's repeat period. Yellow If the task has a deadline, then it is after schedule's - repeat period, but before the deadline. + repeat period, but before the deadline. Orange The task has reached the deadline day, or if there is - no deadline, the end of the schedule's repeat period. + no deadline, the end of the schedule's repeat period. Red The task has gone beyond the deadline day or the - schedule's repeat period." + schedule's repeat period." (let* ((scheduled (or scheduled-days (org-habit-scheduled habit))) (s-repeat (org-habit-scheduled-repeat habit)) (scheduled-end (+ scheduled (1- s-repeat)))