Merge branch 'maint'

This commit is contained in:
Nicolas Goaziou 2016-11-25 01:54:14 +01:00
commit d82811a4f9
2 changed files with 61 additions and 57 deletions

View File

@ -6174,11 +6174,12 @@ scheduled items with an hour specification like [h]h:mm."
'done-face 'org-agenda-done 'done-face 'org-agenda-done
'mouse-face 'highlight 'mouse-face 'highlight
'help-echo 'help-echo
(format "mouse-2 or RET jump to org file %s" (format "mouse-2 or RET jump to Org file %s"
(abbreviate-file-name buffer-file-name)))) (abbreviate-file-name buffer-file-name))))
(regexp (if with-hour (regexp (if with-hour
org-scheduled-time-hour-regexp org-scheduled-time-hour-regexp
org-scheduled-time-regexp)) org-scheduled-time-regexp))
(today (org-today))
(todayp (org-agenda-today-p date)) ; DATE bound by calendar. (todayp (org-agenda-today-p date)) ; DATE bound by calendar.
(current (calendar-absolute-from-gregorian date)) (current (calendar-absolute-from-gregorian date))
(deadline-pos (deadline-pos
@ -6199,16 +6200,22 @@ scheduled items with an hour specification like [h]h:mm."
(show-all (or (eq org-agenda-repeating-timestamp-show-all t) (show-all (or (eq org-agenda-repeating-timestamp-show-all t)
(member todo-state (member todo-state
org-agenda-repeating-timestamp-show-all))) org-agenda-repeating-timestamp-show-all)))
;; SCHEDULE is the current scheduled date. When it ;; SCHEDULE is the bare scheduled date, i.e., without
;; contains a repeater and SHOW-ALL is non-nil, ;; any repeater. REPEAT is the closest repeat after
;; LAST-REPEAT is the repeat closest to CURRENT. ;; CURRENT, if all repeated time stamps are to be
;; Otherwise, LAST-REPEAT is equal to SCHEDULE. ;; shown, or after TODAY otherwise. REPEAT only
(last-repeat (org-agenda--timestamp-to-absolute ;; applies to future dates.
s current 'past show-all (current-buffer) pos)) (schedule (org-agenda--timestamp-to-absolute s))
(schedule (org-agenda--timestamp-to-absolute s current)) (repeat (cond ((< current today) schedule)
(diff (- last-repeat current)) (show-all
(org-agenda--timestamp-to-absolute
s current 'future (current-buffer) pos))
(t
(org-agenda--timestamp-to-absolute
s today 'future (current-buffer) pos))))
(diff (- current schedule))
(warntime (get-text-property (point) 'org-appt-warntime)) (warntime (get-text-property (point) 'org-appt-warntime))
(pastschedp (< schedule (org-today))) (pastschedp (< schedule today))
(habitp (and (fboundp 'org-is-habit-p) (org-is-habit-p))) (habitp (and (fboundp 'org-is-habit-p) (org-is-habit-p)))
(suppress-delay (suppress-delay
(let ((deadline (and org-agenda-skip-scheduled-delay-if-deadline (let ((deadline (and org-agenda-skip-scheduled-delay-if-deadline
@ -6225,44 +6232,35 @@ scheduled items with an hour specification like [h]h:mm."
;; Set delay to no later than DEADLINE. If ;; Set delay to no later than DEADLINE. If
;; DEADLINE has a repeater, compare last schedule ;; DEADLINE has a repeater, compare last schedule
;; repeat and last deadline repeat. ;; repeat and last deadline repeat.
(min (- last-repeat (min (- schedule deadline) org-scheduled-delay-days))
(org-agenda--timestamp-to-absolute
deadline current 'past show-all
(current-buffer)
(save-excursion
(beginning-of-line)
(1+ (search-forward org-deadline-string)))))
org-scheduled-delay-days))
(t 0)))) (t 0))))
(ddays (ddays
(cond (cond
;; Nullify delay when a repeater triggered already ;; Nullify delay when a repeater triggered already
;; and the delay is of the form --Xd. ;; and the delay is of the form --Xd.
((and (string-match-p "--[0-9]+[hdwmy]" s) ((and (string-match-p "--[0-9]+[hdwmy]" s)
(/= schedule last-repeat)) (> current schedule))
0) 0)
(suppress-delay (suppress-delay
(let ((org-scheduled-delay-days suppress-delay)) (let ((org-scheduled-delay-days suppress-delay))
(org-get-wdays s t t))) (org-get-wdays s t t)))
(t (org-get-wdays s t))))) (t (org-get-wdays s t)))))
;; Only show a scheduled item in the calendar if it is on or ;; Display scheduled items at base date (SCHEDULE), today if
;; past the current date. Skip it if it has been displayed ;; scheduled before the current date, and at any repeat past
;; for more than `org-scheduled-past-days'. ;; today. However, skip delayed items and items that have
(unless (or (and (>= ddays 0) (= diff (- ddays))) ;; been displayed for more than `org-scheduled-past-days'.
(and (< (+ diff ddays) 0) (unless (and todayp
(< (abs diff) org-scheduled-past-days) habitp
(and todayp (not org-agenda-only-exact-dates))) (bound-and-true-p org-habit-show-all-today))
(and todayp (when (or (and (> ddays 0) (< diff ddays))
habitp (> diff org-scheduled-past-days)
(bound-and-true-p org-habit-show-all-today))) (> schedule current)
(throw :skip nil)) (and (< schedule current)
;; Skip done habits, or tasks if (not todayp)
;; `org-agenda-skip-deadline-if-done' is non-nil or if it (/= repeat current)))
;; was scheduled in the past anyway. (throw :skip nil)))
(when (and donep ;; Possibly skip done tasks.
(or org-agenda-skip-scheduled-if-done (when (and donep org-agenda-skip-scheduled-if-done)
(/= schedule current)
habitp))
(throw :skip nil)) (throw :skip nil))
;; Skip entry if it already appears as a deadline, per ;; Skip entry if it already appears as a deadline, per
;; `org-agenda-skip-scheduled-if-deadline-is-shown'. This ;; `org-agenda-skip-scheduled-if-deadline-is-shown'. This
@ -6273,16 +6271,16 @@ scheduled items with an hour specification like [h]h:mm."
habitp)) habitp))
nil) nil)
(`repeated-after-deadline (`repeated-after-deadline
(>= last-repeat (>= repeat (time-to-days (org-get-deadline-time (point)))))
(time-to-days (org-get-deadline-time (point)))))
(`not-today pastschedp) (`not-today pastschedp)
(`t t) (`t t)
(_ nil)) (_ nil))
(throw :skip nil)) (throw :skip nil))
;; Skip habits if `org-habit-show-habits' is nil, or if we ;; Skip habits if `org-habit-show-habits' is nil, or if we
;; only show them for today. ;; only show them for today. Also skip done habits.
(when (and habitp (when (and habitp
(or (not (bound-and-true-p org-habit-show-habits)) (or donep
(not (bound-and-true-p org-habit-show-habits))
(and (not todayp) (and (not todayp)
(bound-and-true-p (bound-and-true-p
org-habit-show-habits-only-for-today)))) org-habit-show-habits-only-for-today))))
@ -6307,19 +6305,25 @@ scheduled items with an hour specification like [h]h:mm."
(if (string-match " \\([012]?[0-9]:[0-9][0-9]\\)" s) (if (string-match " \\([012]?[0-9]:[0-9][0-9]\\)" s)
(concat (substring s (match-beginning 1)) " ") (concat (substring s (match-beginning 1)) " ")
'time)) 'time))
(item (org-agenda-format-item (item
;; For past scheduled dates, make sure to (org-agenda-format-item
;; report time difference since SCHEDULE, (pcase-let ((`(,first ,next) org-agenda-scheduled-leaders))
;; not since closest repeater. (cond
(let ((diff (if (< (org-today) current) diff ;; If CURRENT is in the future, don't use past
(- schedule current)))) ;; scheduled prefix.
(if (= diff 0) (car org-agenda-scheduled-leaders) ((> current today) first)
(format (nth 1 org-agenda-scheduled-leaders) ;; SHOW-ALL focuses on future repeats. If one
(- 1 diff)))) ;; such repeat happens today, ignore late
head level category tags ;; schedule reminder. However, still report
(and (= diff 0) timestr) ;; such reminders when repeat happens later.
nil habitp)) ((and (not show-all) (= repeat today)) first)
(face (cond ((and (not habitp) pastschedp) ;; Initial report.
((= schedule current) first)
;; Subsequent reminders. Count from base
;; schedule.
(t (format next (1+ diff)))))
head level category tags timestr nil habitp))
(face (cond ((and (not habitp) (< current today))
'org-scheduled-previously) 'org-scheduled-previously)
(todayp 'org-scheduled-today) (todayp 'org-scheduled-today)
(t 'org-scheduled))) (t 'org-scheduled)))
@ -6335,7 +6339,7 @@ scheduled items with an hour specification like [h]h:mm."
'warntime warntime 'warntime warntime
'level level 'level level
'priority (if habitp (org-habit-get-priority habitp) 'priority (if habitp (org-habit-get-priority habitp)
(+ 94 (- 5 diff) (org-get-priority item))) (+ 99 diff (org-get-priority item)))
'org-habit-p habitp 'org-habit-p habitp
'todo-state todo-state) 'todo-state todo-state)
(push item scheduled-items)))))) (push item scheduled-items))))))

View File

@ -17802,7 +17802,7 @@ days in order to avoid rounding problems."
(org-define-error 'org-diary-sexp-no-match "Unable to match diary sexp") (org-define-error 'org-diary-sexp-no-match "Unable to match diary sexp")
(defun org-time-string-to-absolute (s &optional daynr prefer show-all buffer pos) (defun org-time-string-to-absolute (s &optional daynr prefer buffer pos)
"Convert time stamp S to an absolute day number. "Convert time stamp S to an absolute day number.
If DAYNR in non-nil, and there is a specifier for a cyclic time If DAYNR in non-nil, and there is a specifier for a cyclic time
@ -17826,7 +17826,7 @@ signalled."
(match-string 1 s) "" (calendar-gregorian-from-absolute daynr))) (match-string 1 s) "" (calendar-gregorian-from-absolute daynr)))
daynr daynr
(signal 'org-diary-sexp-no-match (list s)))) (signal 'org-diary-sexp-no-match (list s))))
((and daynr show-all) (org-closest-date s daynr prefer)) (daynr (org-closest-date s daynr prefer))
(t (time-to-days (t (time-to-days
(condition-case errdata (condition-case errdata
(apply #'encode-time (org-parse-time-string s)) (apply #'encode-time (org-parse-time-string s))