[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] org-bbdb-anniversaries-future
From: |
Michael Welle |
Subject: |
Re: [O] org-bbdb-anniversaries-future |
Date: |
Wed, 01 Mar 2017 15:03:49 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) |
Hello,
Nicolas Goaziou <address@hidden> writes:
> Hello,
>
> Michael Welle <address@hidden> writes:
>
>> Even if we assume its quality is high enough to integrate it into Org,
>
> If code quality was a concern, Org would still be in alpha release ;)
thank you for your kind words, Nicolas ;).
>> there might or might not be another problem: I haven't signed the FSF
>> papers. I would like to see the functionality in Org, too. Perhaps
>> someone can sneak it in ;). I can repost the code, stating that it is
>> licensed under the GPL or is even in the public domain, if that helps.
>
> I don't think it helps. IIRC, code integration in Emacs is pretty
> strict. You could simply sign FSF papers.
Yes. Trouble is nobody could explain to me what I have to sign and what
that means in the legal system I'm in. My last attempt to find that out
was in #emacs. It's about 'transfer of copyright' to the FSF. If I
translate 'copyright' to the corresponding construct in our legal
system, the transfer isn't possible. I can't give away the copyright.
Maybe 'transfer of copyright' isn't what signing the FSF papers mean, I
don't know. And IANAL ;).
> Otherwise, doesn't it fit as a tiny change? Would you mind sending the
> patch again?
Maybe it's a tiny change, if we strip the comments ;). It's not too
sophisticated, everyone could have done it.
Regards
hmw
diff --git a/lisp/org-bbdb.el b/lisp/org-bbdb.el
index f851668..5e99494 100644
--- a/lisp/org-bbdb.el
+++ b/lisp/org-bbdb.el
@@ -412,6 +412,22 @@ This is used by Org to re-create the anniversary hash
table."
(mapcar (lambda (i) (calendar-gregorian-from-absolute (+ abs i)))
(number-sequence 0 (1- n)))))
+(defun org-bbdb-anniversary-description (agenda-date anniv-date)
+ "Return a string used to modify an agenda anniversary entry. The
+ calculation of the string is based on the difference between
+ the anniversary date and the date on which the entry appears
+ in the agenda. This makes it possible to have different entries
+ for the same event depending on if it occurs in the next few days
+ or far away in the future."
+ (let ((delta (- (calendar-absolute-from-gregorian anniv-date)
+ (calendar-absolute-from-gregorian agenda-date))))
+
+ (cond
+ ((= delta 0) " -- today\\&")
+ ((= delta 1) " -- tomorrow\\&")
+ ((< delta 7) (format " -- in %d days\\&" delta))
+ ((format " -- %d-%02d-%02d\\&" (third anniv-date) (first anniv-date)
(second anniv-date))))))
+
;;;###autoload
(defun org-bbdb-anniversaries-future (&optional n)
"Return list of anniversaries for today and the next n-1 days (default n=7)."
@@ -425,19 +441,17 @@ must be positive"))
;; Function to annotate text of each element of l with the
;; anniversary date d.
(annotate-descriptions
- (lambda (d l)
+ (lambda (agenda-date d l)
(mapcar (lambda (x)
;; The assumption here is that x is a bbdb link
;; of the form [[bbdb:name][description]].
;; This function rather arbitrarily modifies
;; the description by adding the date to it in
;; a fixed format.
- (string-match "]]" x)
- (replace-match (format " -- %d-%02d-%02d\\&"
- (nth 2 d)
- (nth 0 d)
- (nth 1 d))
- nil nil x))
+ (let ((desc (org-bbdb-anniversary-description
+ agenda-date d)))
+ (string-match "]]" x)
+ (replace-match desc nil nil x)))
l))))
;; Map a function that generates anniversaries for each date
;; over the dates and nconc the results into a single list. When
@@ -447,12 +461,13 @@ must be positive"))
(apply #'nconc
(mapcar
(lambda (d)
- (let ((date d))
+ (let ((agenda-date date)
+ (date d))
;; Rebind 'date' so that org-bbdb-anniversaries will
;; be fooled into giving us the list for the given
;; date and then annotate the descriptions for that
;; date.
- (funcall annotate-descriptions d (org-bbdb-anniversaries))))
+ (funcall annotate-descriptions agenda-date d
(org-bbdb-anniversaries))))
dates)))))
(defun org-bbdb-complete-link ()
- Re: [O] org-bbdb-anniversaries-future, Alan Schmitt, 2017/03/01
- Re: [O] org-bbdb-anniversaries-future, Michael Welle, 2017/03/01
- Re: [O] org-bbdb-anniversaries-future, Marco Wahl, 2017/03/01
- Re: [O] org-bbdb-anniversaries-future, Nicolas Goaziou, 2017/03/01
- Re: [O] org-bbdb-anniversaries-future, Rasmus, 2017/03/01
- Re: [O] org-bbdb-anniversaries-future, Nicolas Goaziou, 2017/03/05
- Re: [O] org-bbdb-anniversaries-future, Michael Welle, 2017/03/07
- Re: [O] org-bbdb-anniversaries-future, Nicolas Goaziou, 2017/03/12
- Re: [O] org-bbdb-anniversaries-future, Michael Welle, 2017/03/13
- Re: [O] org-bbdb-anniversaries-future, Michael Welle, 2017/03/13
- Re: [O] org-bbdb-anniversaries-future, Nicolas Goaziou, 2017/03/17
Re: [O] org-bbdb-anniversaries-future, Marco Wahl, 2017/03/01