emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Michael Welle <mwe012008@gmx.net>
To: emacs-orgmode@gnu.org
Subject: Re: org-bbdb-anniversaries-future
Date: Wed, 01 Mar 2017 15:03:49 +0100	[thread overview]
Message-ID: <87o9xlw0u2.fsf@luisa.c0t0d0s0.de> (raw)
In-Reply-To: <8737exce1j.fsf@nicolasgoaziou.fr> (Nicolas Goaziou's message of "Wed, 01 Mar 2017 14:38:48 +0100")

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

Hello,

Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> Hello,
>
> Michael Welle <mwe012008@gmx.net> 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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: org-bbdb-hmw-anniv-hack.diff --]
[-- Type: text/x-diff, Size: 2793 bytes --]

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

  reply	other threads:[~2017-03-01 14:04 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <qf8k5dxnqs.ln2@news.c0t0d0s0.de>
2016-07-14 22:22 ` org-bbdb-anniversaries-future Marco Wahl
2017-03-01  9:19 ` org-bbdb-anniversaries-future Alan Schmitt
2017-03-01  9:30   ` org-bbdb-anniversaries-future Michael Welle
2017-03-01 10:39     ` org-bbdb-anniversaries-future Marco Wahl
2017-03-01 13:38     ` org-bbdb-anniversaries-future Nicolas Goaziou
2017-03-01 14:03       ` Michael Welle [this message]
2017-03-01 14:30         ` org-bbdb-anniversaries-future Alan Schmitt
2017-03-01 14:40           ` org-bbdb-anniversaries-future Michael Welle
2017-03-01 14:34         ` org-bbdb-anniversaries-future Rasmus
2017-03-05 17:28         ` org-bbdb-anniversaries-future Nicolas Goaziou
2017-03-07  9:19           ` org-bbdb-anniversaries-future Michael Welle
2017-03-12 12:47             ` org-bbdb-anniversaries-future Nicolas Goaziou
2017-03-13  8:22               ` org-bbdb-anniversaries-future Michael Welle
2017-03-13  8:31                 ` org-bbdb-anniversaries-future Michael Welle
2017-03-17  7:29                   ` org-bbdb-anniversaries-future Nicolas Goaziou
2017-03-01 10:35   ` org-bbdb-anniversaries-future Marco Wahl
     [not found] <ipa2rcx5nc.ln2@news.c0t0d0s0.de>
2016-03-08  9:25 ` org-bbdb-anniversaries, bbdb v3 Marco Wahl
     [not found]   ` <7hp2rcx89n.ln2@news.c0t0d0s0.de>
2016-03-08 13:08     ` Nick Dokos
2016-03-08 15:43       ` org-bbdb-anniversaries-future Georges

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87o9xlw0u2.fsf@luisa.c0t0d0s0.de \
    --to=mwe012008@gmx.net \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).