From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Welle Subject: Re: org-bbdb-anniversaries-future Date: Wed, 01 Mar 2017 15:03:49 +0100 Message-ID: <87o9xlw0u2.fsf@luisa.c0t0d0s0.de> References: <87shmxwdhp.fsf@luisa.c0t0d0s0.de> <8737exce1j.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:56781) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cj4rH-00076e-7D for emacs-orgmode@gnu.org; Wed, 01 Mar 2017 09:04:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cj4rC-0008QO-9x for emacs-orgmode@gnu.org; Wed, 01 Mar 2017 09:03:59 -0500 Received: from mout.gmx.net ([212.227.17.22]:49720) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cj4rB-0008Pv-Uc for emacs-orgmode@gnu.org; Wed, 01 Mar 2017 09:03:54 -0500 Received: from stella.c0t0d0s0.de ([194.95.66.1]) by mail.gmx.com (mrgmx102 [212.227.17.168]) with ESMTPSA (Nemesis) id 0MgHHO-1cuXR23USk-00Ng0R for ; Wed, 01 Mar 2017 15:03:50 +0100 Received: from Stella (stella.c0t0d0s0.de [192.168.42.1]) by stella.c0t0d0s0.de (Postfix) with ESMTP id C54AFC5054 for ; Wed, 1 Mar 2017 15:03:49 +0100 (CET) In-Reply-To: <8737exce1j.fsf@nicolasgoaziou.fr> (Nicolas Goaziou's message of "Wed, 01 Mar 2017 14:38:48 +0100") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Hello, Nicolas Goaziou writes: > Hello, > > Michael Welle 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 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=org-bbdb-hmw-anniv-hack.diff 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 () --=-=-=--