emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Agenda: Simplify old fix of face for deadline warning 0 day
@ 2011-08-01  8:57 Michael Brand
  2011-08-05  0:18 ` Bernt Hansen
  2011-08-14 16:42 ` Bastien
  0 siblings, 2 replies; 3+ messages in thread
From: Michael Brand @ 2011-08-01  8:57 UTC (permalink / raw)
  To: Org Mode; +Cc: Bernt Hansen

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

Agenda: Simplify old fix of face for deadline warning 0 day

* lisp/org-agenda.el (org-agenda-get-deadlines): Fix dfrac for the
case of wdays being 0.  Don't pass wdays to org-agenda-deadline-face,
like before the old fix.
(org-agenda-deadline-face): Revert to old state that was without
wdays.

This allows a deadline warning period of "-0d" to work also with a
custom configuration like:
(setq org-agenda-deadline-faces
      '((1.0001 . org-warning)              ; due yesterday or before
        (0.0    . org-upcoming-deadline)))  ; due today or later
For org-agenda-deadline-faces left at default and all other settings
not exceeding 1.0, the face for a deadline warning of any length
remains untouched by this patch.

references to history:
* commit of the old fix
  - http://orgmode.org/w/?p=org-mode.git;a=commitdiff;h=d0d6325
  - git show d0d6325
* mailing list old thread
  - http://thread.gmane.org/gmane.emacs.orgmode/5753
  - http://lists.gnu.org/archive/html/emacs-orgmode/2008-02/msg00395.html

[-- Attachment #2: 0001-Agenda-Simplify-old-fix-of-face-for-deadline-warning.patch --]
[-- Type: application/octet-stream, Size: 2676 bytes --]

From 7b2de46fb48069dbc11bb9d4619776a9fc30b6b9 Mon Sep 17 00:00:00 2001
From: Michael Brand <michael.ch.brand@gmail.com>
Date: Mon, 1 Aug 2011 10:53:33 +0200
Subject: [PATCH] Agenda: Simplify old fix of face for deadline warning 0 day

* lisp/org-agenda.el (org-agenda-get-deadlines): Fix dfrac for the
case of wdays being 0.  Don't pass wdays to org-agenda-deadline-face,
like before the old fix.
(org-agenda-deadline-face): Revert to old state that was without
wdays.

This allows a deadline warning period of "-0d" to work also with a
custom configuration like:
(setq org-agenda-deadline-faces
      '((1.0001 . org-warning)              ; due yesterday or before
        (0.0    . org-upcoming-deadline)))  ; due today or later
For org-agenda-deadline-faces left at default and all other settings
not exceeding 1.0, the face for a deadline warning of any length
remains untouched by this patch.

references to history:
* commit of the old fix
  - http://orgmode.org/w/?p=org-mode.git;a=commitdiff;h=d0d6325
  - git show d0d6325
* mailing list old thread
  - http://thread.gmane.org/gmane.emacs.orgmode/5753
  - http://lists.gnu.org/archive/html/emacs-orgmode/2008-02/msg00395.html
---
 lisp/org-agenda.el |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index d47013b..3c7a419 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -5156,7 +5156,7 @@ (defun org-agenda-get-deadlines ()
 			(let ((org-deadline-warning-days suppress-prewarning))
 			  (org-get-wdays s))
 		      (org-get-wdays s))
-	      dfrac (/ (* 1.0 (- wdays diff)) (max wdays 1))
+	      dfrac (- 1 (/ (* 1.0 diff) (max wdays 1)))
 	      upcomingp (and todayp (> diff 0)))
 	;; When to show a deadline in the calendar:
 	;; If the expiration is within wdays warning time.
@@ -5198,7 +5198,7 @@ (defun org-agenda-get-deadlines ()
 			     head category tags
 			     (if (not (= diff 0)) nil timestr)))))
 	      (when txt
-		(setq face (org-agenda-deadline-face dfrac wdays))
+		(setq face (org-agenda-deadline-face dfrac))
 		(org-add-props txt props
 		  'org-marker (org-agenda-new-marker pos)
 		  'org-hd-marker (org-agenda-new-marker pos1)
@@ -5213,10 +5213,9 @@ (defun org-agenda-get-deadlines ()
 		(push txt ee))))))
     (nreverse ee)))
 
-(defun org-agenda-deadline-face (fraction &optional wdays)
+(defun org-agenda-deadline-face (fraction)
   "Return the face to displaying a deadline item.
 FRACTION is what fraction of the head-warning time has passed."
-  (if (equal wdays 0) (setq fraction 1.))
   (let ((faces org-agenda-deadline-faces) f)
     (catch 'exit
       (while (setq f (pop faces))
-- 
1.7.4.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Agenda: Simplify old fix of face for deadline warning 0 day
  2011-08-01  8:57 [PATCH] Agenda: Simplify old fix of face for deadline warning 0 day Michael Brand
@ 2011-08-05  0:18 ` Bernt Hansen
  2011-08-14 16:42 ` Bastien
  1 sibling, 0 replies; 3+ messages in thread
From: Bernt Hansen @ 2011-08-05  0:18 UTC (permalink / raw)
  To: Michael Brand; +Cc: Org Mode

Michael Brand <michael.ch.brand@gmail.com> writes:

> Agenda: Simplify old fix of face for deadline warning 0 day
>
> * lisp/org-agenda.el (org-agenda-get-deadlines): Fix dfrac for the
> case of wdays being 0.  Don't pass wdays to org-agenda-deadline-face,
> like before the old fix.
> (org-agenda-deadline-face): Revert to old state that was without
> wdays.
>
> This allows a deadline warning period of "-0d" to work also with a
> custom configuration like:
> (setq org-agenda-deadline-faces
>       '((1.0001 . org-warning)              ; due yesterday or before
>         (0.0    . org-upcoming-deadline)))  ; due today or later
> For org-agenda-deadline-faces left at default and all other settings
> not exceeding 1.0, the face for a deadline warning of any length
> remains untouched by this patch.
>
> references to history:
> * commit of the old fix
>   - http://orgmode.org/w/?p=org-mode.git;a=commitdiff;h=d0d6325
>   - git show d0d6325
> * mailing list old thread
>   - http://thread.gmane.org/gmane.emacs.orgmode/5753
>   - http://lists.gnu.org/archive/html/emacs-orgmode/2008-02/msg00395.html

This patch works okay for me with my default setting of

,----
| org-agenda-deadline-faces is a variable defined in `org-faces.el'.
| Its value is 
| ((1.0 . org-warning)
|  (0.5 . org-upcoming-deadline)
|  (0.0 . default))
`----

Regards,
Bernt

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Agenda: Simplify old fix of face for deadline warning 0 day
  2011-08-01  8:57 [PATCH] Agenda: Simplify old fix of face for deadline warning 0 day Michael Brand
  2011-08-05  0:18 ` Bernt Hansen
@ 2011-08-14 16:42 ` Bastien
  1 sibling, 0 replies; 3+ messages in thread
From: Bastien @ 2011-08-14 16:42 UTC (permalink / raw)
  To: Michael Brand; +Cc: Bernt Hansen, Org Mode

Hi Michael,

Michael Brand <michael.ch.brand@gmail.com> writes:

> Agenda: Simplify old fix of face for deadline warning 0 day

Applied, thanks a lot!

-- 
 Bastien

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-08-14 16:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-01  8:57 [PATCH] Agenda: Simplify old fix of face for deadline warning 0 day Michael Brand
2011-08-05  0:18 ` Bernt Hansen
2011-08-14 16:42 ` Bastien

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