emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Re: org-bbdb-anniversaries-future
  2016-03-08 13:08     ` Nick Dokos
@ 2016-03-08 15:43       ` Georges
  0 siblings, 0 replies; 17+ messages in thread
From: Georges @ 2016-03-08 15:43 UTC (permalink / raw)
  To: emacs-orgmode

Nick Dokos <ndokos <at> gmail.com> writes:

> Michael Welle <mwe012008 <at> gmx.net> writes:
> 
> > Marco Wahl <marcowahlsoft <at> gmail.com> writes:
> >
> >> BTW I use `org-bbdb-anniversaries-future'.  See section "Anniversaries
> >> from BBDB" in the info documentation (info "(org) Weekly/daily agenda").


Not present in latest org elpa package.

--

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

* Re: org-bbdb-anniversaries-future
       [not found] <qf8k5dxnqs.ln2@news.c0t0d0s0.de>
@ 2016-07-14 22:22 ` Marco Wahl
  2017-03-01  9:19 ` org-bbdb-anniversaries-future Alan Schmitt
  1 sibling, 0 replies; 17+ messages in thread
From: Marco Wahl @ 2016-07-14 22:22 UTC (permalink / raw)
  To: emacs-orgmode

Hi!

> org-bbdb-anniversaries-future uses the following format to insert
> anniversaries into the agenda:
>
> Birthday: [[bbdb:foo bar][foo bar (37th) -- 2016-07-14]]
>
> Seeing the date in the agenda makes me feel like I have a lot of time to
> get a present. Then, just before the shops close, I realise that her
> birthday is today ;).
>
> So I introduced a function that calculates the agenda entry with respect
> to the time span between the actual event and the agenda date. This allows
> to have entries like
>
> Birthday: [[bbdb:foo bar][foo bar (37th) -- 2016-07-14]]
> Birthday: [[bbdb:foo bar][foo bar (37th) -- in 8 days]]
> Birthday: [[bbdb:foo bar][foo bar (37th) -- tomorrow]]
> Birthday: [[bbdb:foo bar][foo bar (37th) -- today]]
>
> The patch is attached to this posting.

+1 for including this feature.


Regards
-- 
Marco Wahl

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

* Re: org-bbdb-anniversaries-future
       [not found] <qf8k5dxnqs.ln2@news.c0t0d0s0.de>
  2016-07-14 22:22 ` org-bbdb-anniversaries-future Marco Wahl
@ 2017-03-01  9:19 ` Alan Schmitt
  2017-03-01  9:30   ` org-bbdb-anniversaries-future Michael Welle
  2017-03-01 10:35   ` org-bbdb-anniversaries-future Marco Wahl
  1 sibling, 2 replies; 17+ messages in thread
From: Alan Schmitt @ 2017-03-01  9:19 UTC (permalink / raw)
  To: Michael Welle; +Cc: emacs-orgmode

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

Hello,

On 2016-07-14 14:09, Michael Welle <mwe012008@gmx.net> writes:

> Hello,
>
> org-bbdb-anniversaries-future uses the following format to insert
> anniversaries into the agenda:
>
> Birthday: [[bbdb:foo bar][foo bar (37th) -- 2016-07-14]]
>
> Seeing the date in the agenda makes me feel like I have a lot of time to
> get a present. Then, just before the shops close, I realise that her
> birthday is today ;).
>
> So I introduced a function that calculates the agenda entry with respect
> to the time span between the actual event and the agenda date. This allows
> to have entries like
>
> Birthday: [[bbdb:foo bar][foo bar (37th) -- 2016-07-14]]
> Birthday: [[bbdb:foo bar][foo bar (37th) -- in 8 days]]
> Birthday: [[bbdb:foo bar][foo bar (37th) -- tomorrow]]
> Birthday: [[bbdb:foo bar][foo bar (37th) -- today]]
>
> The patch is attached to this posting.

Sorry for reviving this old thread, but was this added to org? I would
find it most useful.

Best,

Alan

-- 
OpenPGP Key ID : 040D0A3B4ED2E5C7
Monthly Athmospheric CO₂, Mauna Loa Obs. 2017-01: 406.13, 2016-01: 402.52

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 454 bytes --]

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

* Re: org-bbdb-anniversaries-future
  2017-03-01  9:19 ` org-bbdb-anniversaries-future Alan Schmitt
@ 2017-03-01  9:30   ` 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 10:35   ` org-bbdb-anniversaries-future Marco Wahl
  1 sibling, 2 replies; 17+ messages in thread
From: Michael Welle @ 2017-03-01  9:30 UTC (permalink / raw)
  To: emacs-orgmode

Hello,

Alan Schmitt <alan.schmitt@polytechnique.org> writes:
[...]
> Sorry for reviving this old thread, but was this added to org? I would
> find it most useful.
no, it's not.

Even if we assume its quality is high enough to integrate it into Org,
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.

Regards
hmw

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

* Re: org-bbdb-anniversaries-future
  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:35   ` Marco Wahl
  1 sibling, 0 replies; 17+ messages in thread
From: Marco Wahl @ 2017-03-01 10:35 UTC (permalink / raw)
  To: emacs-orgmode

Alan Schmitt <alan.schmitt@polytechnique.org> writes:

> Hello,
>
> On 2016-07-14 14:09, Michael Welle <mwe012008@gmx.net> writes:
>
>> Hello,
>>
>> org-bbdb-anniversaries-future uses the following format to insert
>> anniversaries into the agenda:
>>
>> Birthday: [[bbdb:foo bar][foo bar (37th) -- 2016-07-14]]
>>
>> Seeing the date in the agenda makes me feel like I have a lot of time to
>> get a present. Then, just before the shops close, I realise that her
>> birthday is today ;).
>>
>> So I introduced a function that calculates the agenda entry with respect
>> to the time span between the actual event and the agenda date. This allows
>> to have entries like
>>
>> Birthday: [[bbdb:foo bar][foo bar (37th) -- 2016-07-14]]
>> Birthday: [[bbdb:foo bar][foo bar (37th) -- in 8 days]]
>> Birthday: [[bbdb:foo bar][foo bar (37th) -- tomorrow]]
>> Birthday: [[bbdb:foo bar][foo bar (37th) -- today]]
>>
>> The patch is attached to this posting.
>
> Sorry for reviving this old thread, but was this added to org? I would
> find it most useful.

+1

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

* Re: org-bbdb-anniversaries-future
  2017-03-01  9:30   ` org-bbdb-anniversaries-future Michael Welle
@ 2017-03-01 10:39     ` Marco Wahl
  2017-03-01 13:38     ` org-bbdb-anniversaries-future Nicolas Goaziou
  1 sibling, 0 replies; 17+ messages in thread
From: Marco Wahl @ 2017-03-01 10:39 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: application/pgp-encrypted, Size: 11 bytes --]

[-- Attachment #2: Type: application/octet-stream, Size: 987 bytes --]

-----BEGIN PGP MESSAGE-----

hQEMA17LZETWL1NiAQgAlA3b3HQZLNQoA/CWvYjNKXh2eXZv7nR5Wa14Qtd/vhcP
7+4jI9fXJ1zvvxEoDnCDRTUQSzrcsPnDl80TN+9rlfENsYadQ7QITSNUZea+HxGK
cVUh7Fv+iSDX1nHyz4Dp5iUzgJhybsj4oPuUa9cVn6kXSB6bPUH3t88CWEBaHn5D
15MHm66hkgagU3Do1cAHsisFv9XRWHF2kKjf38a8RClHQgICYG3DpVbP9Lz7obcG
k6F1qmAaZ4ryWftWVXwbi+ruVrh6TB7lTdEO/V3SvOXzbdyMt6g4pj4SbCsQB1Vh
Bay1Vd02R9wjUP6eh+Wh7HVgk+9roBSbbHi/Thcm09LA2AG82TwvpyN6N2MU/apl
8+BrUkTiuvTeAzPI6y2kILYXxwGeX1q46hh3PdI3/7W1y4j+a1JolEwms2uS1HKh
e0sEqWKyA7rirzxfkV1u7UEcw2mVlrXABvutkolEp85XoRVogiV2o+yW5XJd08zt
9v21GF7rDirc6yzIaYa0E4fZsAAE5pgFIyt6DFEZfEXCnU16stUFjzfjQtv1ImTZ
lL2mRn1yw7KpYtYYpNBGfOJaYso4hcmqLBOhPJk3ATopHAmko5APmaNQ7igYlyaj
Bla0d+iTsdgKd2UvUstx3JP82njOih5tHnIvd4Ploe47xdCmqTaF9tGSygBy5I87
p7qv0grNDvzYPO/cXRpjrhVEy9+626f7jFJiu2VdNoRP9fuR+JIWDyCvYoc5eGxp
zOFcoiX7j+v3pHUGIogw15JZ3qVu+B/uGJ2PkmJfqArUNouQ5z6So+nfjMgmzWtm
DEyDNnnQTk5DhuBy+sBhsaZ7w8ab/uVKclGDWj3l50AM5Iq11TWFQdORi+FI7RZg
dlG0yZxx39G94w==
=bf+3
-----END PGP MESSAGE-----

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

* Re: org-bbdb-anniversaries-future
  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     ` Nicolas Goaziou
  2017-03-01 14:03       ` org-bbdb-anniversaries-future Michael Welle
  1 sibling, 1 reply; 17+ messages in thread
From: Nicolas Goaziou @ 2017-03-01 13:38 UTC (permalink / raw)
  To: Michael Welle; +Cc: emacs-orgmode

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

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

Otherwise, doesn't it fit as a tiny change? Would you mind sending the
patch again?

Regards,

-- 
Nicolas Goaziou

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

* Re: org-bbdb-anniversaries-future
  2017-03-01 13:38     ` org-bbdb-anniversaries-future Nicolas Goaziou
@ 2017-03-01 14:03       ` Michael Welle
  2017-03-01 14:30         ` org-bbdb-anniversaries-future Alan Schmitt
                           ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Michael Welle @ 2017-03-01 14:03 UTC (permalink / raw)
  To: emacs-orgmode

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

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

* Re: org-bbdb-anniversaries-future
  2017-03-01 14:03       ` org-bbdb-anniversaries-future Michael Welle
@ 2017-03-01 14:30         ` 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
  2 siblings, 1 reply; 17+ messages in thread
From: Alan Schmitt @ 2017-03-01 14:30 UTC (permalink / raw)
  To: Michael Welle; +Cc: emacs-orgmode

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

On 2017-03-01 15:03, Michael Welle <mwe012008@gmx.net> writes:

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

Does the FSFE version works for emacs
(https://fsfe.org/activities/ftf/fla.en.html)? Because it seems to be
adapted to legal systems outside of the USA. I had a look at the French
version and they explicitly mention that they make this version because
in France transferring copyright is impossible (you may just give
exploitation rights).

Best,

Alan

-- 
OpenPGP Key ID : 040D0A3B4ED2E5C7
Monthly Athmospheric CO₂, Mauna Loa Obs. 2017-01: 406.13, 2016-01: 402.52

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 454 bytes --]

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

* Re: org-bbdb-anniversaries-future
  2017-03-01 14:03       ` org-bbdb-anniversaries-future Michael Welle
  2017-03-01 14:30         ` org-bbdb-anniversaries-future Alan Schmitt
@ 2017-03-01 14:34         ` Rasmus
  2017-03-05 17:28         ` org-bbdb-anniversaries-future Nicolas Goaziou
  2 siblings, 0 replies; 17+ messages in thread
From: Rasmus @ 2017-03-01 14:34 UTC (permalink / raw)
  To: emacs-orgmode

Michael Welle <mwe012008@gmx.net> writes:

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

You might want to discuss this with the FSF copyright clerk

    copyright-clerk@fsf.org

They will also be able to tell you if you can use e.g. the FSFE
assignments.

Rasmus

-- 
The second rule of Fight Club is: You do not talk about Fight Club

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

* Re: org-bbdb-anniversaries-future
  2017-03-01 14:30         ` org-bbdb-anniversaries-future Alan Schmitt
@ 2017-03-01 14:40           ` Michael Welle
  0 siblings, 0 replies; 17+ messages in thread
From: Michael Welle @ 2017-03-01 14:40 UTC (permalink / raw)
  To: emacs-orgmode

Hello,

Alan Schmitt <alan.schmitt@polytechnique.org> writes:

> On 2017-03-01 15:03, Michael Welle <mwe012008@gmx.net> writes:
>
>>> 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 ;).
>
> Does the FSFE version works for emacs
> (https://fsfe.org/activities/ftf/fla.en.html)?
good question, I don't know the answer... yet.

Regards
hmw

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

* Re: org-bbdb-anniversaries-future
  2017-03-01 14:03       ` org-bbdb-anniversaries-future Michael Welle
  2017-03-01 14:30         ` org-bbdb-anniversaries-future Alan Schmitt
  2017-03-01 14:34         ` org-bbdb-anniversaries-future Rasmus
@ 2017-03-05 17:28         ` Nicolas Goaziou
  2017-03-07  9:19           ` org-bbdb-anniversaries-future Michael Welle
  2 siblings, 1 reply; 17+ messages in thread
From: Nicolas Goaziou @ 2017-03-05 17:28 UTC (permalink / raw)
  To: Michael Welle; +Cc: emacs-orgmode

Hello,

Michael Welle <mwe012008@gmx.net> writes:

> Maybe it's a tiny change, if we strip the comments ;). It's not too
> sophisticated, everyone could have done it.

I definitely think it _is_ a tiny change.

Some comments follow.

> +(defun org-bbdb-anniversary-description (agenda-date anniv-date)
> +  "Return a string used to modify an agenda anniversary entry. The 

The first line needs to be a sentence on its own. IOW, the last "The"
belong to the next line.
> +   calculation of the string is based on the difference between

Indentation in this line and all subsequent ones needs to be removed.

> +   the anniversary date and the date on which the entry appears
> +   in the agenda. This makes it possible to have different entries

Docstrings follow US English conventions, i.e., two spaces are required
after a full stop.

> +   for the same event depending on if it occurs in the next few days
> +   or far away in the future."

You also need to document what are the arguments (type).  They are
written up-cased in the docstring.

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

You need to used "cl-" prefix, e.g., `cl-third'. OTOH, I'd rather use
pattern matching here, for clarity:

  (pcase-let ((`(,month ,day ,year) anniv-date))
    (format " -- %s-%02%d-%02d\\&" year month day))

Also, could you provide a commit message?

Thank you.

Regards,

-- 
Nicolas Goaziou

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

* Re: org-bbdb-anniversaries-future
  2017-03-05 17:28         ` org-bbdb-anniversaries-future Nicolas Goaziou
@ 2017-03-07  9:19           ` Michael Welle
  2017-03-12 12:47             ` org-bbdb-anniversaries-future Nicolas Goaziou
  0 siblings, 1 reply; 17+ messages in thread
From: Michael Welle @ 2017-03-07  9:19 UTC (permalink / raw)
  To: emacs-orgmode

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

Hello,

Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> Hello,
>
> Michael Welle <mwe012008@gmx.net> writes:
>
>> Maybe it's a tiny change, if we strip the comments ;). It's not too
>> sophisticated, everyone could have done it.
>
> I definitely think it _is_ a tiny change.
>
> Some comments follow.
thank you for the valuable comments. I think I've incorporated them all.
Furthermore I reworded some of the comments and I introduced a defvar,
so that the point in time, when to switch to the more general
descriptive text isn't hardcoded anymore, but customisable. 


> Also, could you provide a commit message?
----
Make anniversaries' time span information more descriptive in agenda.

* lisp/org-bbdb.el (org-bbdb-anniversary-description): New function.
(org-bbdb-general-anniversary-description-after): New variable.
(org-bbdb-anniversaries-future): Incorporate calculation of the description.
----

Regards
hmw


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

diff --git a/lisp/org-bbdb.el b/lisp/org-bbdb.el
index f851668..0aa1ddb 100644
--- a/lisp/org-bbdb.el
+++ b/lisp/org-bbdb.el
@@ -138,6 +138,19 @@
   :group 'org-bbdb-anniversaries
   :require 'bbdb)
 
+(defcustom org-bbdb-general-anniversary-description-after 7
+  "When to switch anniversary descriptions to a more general format.
+Anniversary descriptions include the point in time, when the
+anniversary appears.  This is, in its most general form, just the
+date of the anniversary.  Or more specific terms, like 'today',
+'tomorrow' or 'in n days' are used to describe the time span.  If
+the anniversary is ORG-BBDB-GENERAL-ANNIVERSARY-DESCRIPTION-AFTER
+or more days in the future, the general description is used,
+otherwise the more specific description is used."
+  :type  'integer
+  :group 'org-bbdb-anniversaries
+  :require 'bbdb)
+
 (defcustom org-bbdb-anniversary-format-alist
   '(("birthday" .
      (lambda (name years suffix)
@@ -412,7 +425,25 @@ 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)))))
 
-;;;###autoload
+(defun org-bbdb-anniversary-description (agenda-date anniv-date)
+  "Return a string used to incorporate into an agenda anniversary entry.
+The calculation of the anniversary description string is based on
+the difference between the anniversary date, given as ANNIV-DATE,
+and the date on which the entry appears in the agenda, given as
+AGENDA-DATE.  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 org-bbdb-general-anniversary-description-after) (format " -- in %d days\\&" delta))
+     ((pcase-let ((`(,month ,day ,year) anniv-date))
+	(format " -- %d-%02d-%02d\\&" year month day))))))
+
+
 (defun org-bbdb-anniversaries-future (&optional n)
   "Return list of anniversaries for today and the next n-1 days (default n=7)."
   (let ((n (or n 7)))
@@ -425,19 +456,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 +476,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 ()

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

* Re: org-bbdb-anniversaries-future
  2017-03-07  9:19           ` org-bbdb-anniversaries-future Michael Welle
@ 2017-03-12 12:47             ` Nicolas Goaziou
  2017-03-13  8:22               ` org-bbdb-anniversaries-future Michael Welle
  0 siblings, 1 reply; 17+ messages in thread
From: Nicolas Goaziou @ 2017-03-12 12:47 UTC (permalink / raw)
  To: Michael Welle; +Cc: emacs-orgmode

Hello,

Michael Welle <mwe012008@gmx.net> writes:

> thank you for the valuable comments. I think I've incorporated them all.
> Furthermore I reworded some of the comments and I introduced a defvar,
> so that the point in time, when to switch to the more general
> descriptive text isn't hardcoded anymore, but customisable.

I applied your patch. Thank you.

I added :version, :package-version and :safe keywords in the defcustom.
I sligthly reworded the docstring so as to avoid documenting recursively
the variable.

Could you provide an ORG-NEWS entry for the feature?

Regards,

-- 
Nicolas Goaziou

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

* Re: org-bbdb-anniversaries-future
  2017-03-12 12:47             ` org-bbdb-anniversaries-future Nicolas Goaziou
@ 2017-03-13  8:22               ` Michael Welle
  2017-03-13  8:31                 ` org-bbdb-anniversaries-future Michael Welle
  0 siblings, 1 reply; 17+ messages in thread
From: Michael Welle @ 2017-03-13  8:22 UTC (permalink / raw)
  To: emacs-orgmode

Hello,

Nicolas Goaziou wrote:
> 
> Hello,
> 
> Michael Welle <mwe012008@gmx.net> writes:
> 
> > thank you for the valuable comments. I think I've incorporated them all.
> > Furthermore I reworded some of the comments and I introduced a defvar,
> > so that the point in time, when to switch to the more general
> > descriptive text isn't hardcoded anymore, but customisable.
> 
> I applied your patch. Thank you.
thank you. I think that makes at least three people, including me,
happy ;).


> I added :version, :package-version and :safe keywords in the defcustom.
> I sligthly reworded the docstring so as to avoid documenting recursively
> the variable.
> 
> Could you provide an ORG-NEWS entry for the feature?


*** More specific anniversary descriptions

Anniversary descriptions (used in the agenda view, for instance)
include the point in time, when the anniversary appears. This is,
in its most general form, just the date of the anniversary. Or
more specific terms, like "today", "tomorrow" or "in n days" are
used to describe the time span.

This feature allows to automatically change the description of an
anniversary, depending on if it occurs in the next few days or
far away in the future.


Regards
hmw

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

* Re: org-bbdb-anniversaries-future
  2017-03-13  8:22               ` org-bbdb-anniversaries-future Michael Welle
@ 2017-03-13  8:31                 ` Michael Welle
  2017-03-17  7:29                   ` org-bbdb-anniversaries-future Nicolas Goaziou
  0 siblings, 1 reply; 17+ messages in thread
From: Michael Welle @ 2017-03-13  8:31 UTC (permalink / raw)
  To: emacs-orgmode

Hello,

oops, I think the double space after full stop rule applies here, too.
Sorry for the noise.


Michael Welle <mwe012008@gmx.net> writes:
[...]
>> Could you provide an ORG-NEWS entry for the feature?
>
>
*** More specific anniversary descriptions

Anniversary descriptions (used in the agenda view, for instance)
include the point in time, when the anniversary appears.  This is,
in its most general form, just the date of the anniversary.  Or
more specific terms, like "today", "tomorrow" or "in n days" are
used to describe the time span.

This feature allows to automatically change the description of an
anniversary, depending on if it occurs in the next few days or
far away in the future.


Regards
hmw

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

* Re: org-bbdb-anniversaries-future
  2017-03-13  8:31                 ` org-bbdb-anniversaries-future Michael Welle
@ 2017-03-17  7:29                   ` Nicolas Goaziou
  0 siblings, 0 replies; 17+ messages in thread
From: Nicolas Goaziou @ 2017-03-17  7:29 UTC (permalink / raw)
  To: Michael Welle; +Cc: emacs-orgmode

Hello,

Michael Welle <mwe012008@gmx.net> writes:

> *** More specific anniversary descriptions
>
> Anniversary descriptions (used in the agenda view, for instance)
> include the point in time, when the anniversary appears.  This is,
> in its most general form, just the date of the anniversary.  Or
> more specific terms, like "today", "tomorrow" or "in n days" are
> used to describe the time span.
>
> This feature allows to automatically change the description of an
> anniversary, depending on if it occurs in the next few days or
> far away in the future.

Added. Thank you.

Regards,

-- 
Nicolas Goaziou

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

end of thread, other threads:[~2017-03-17  7:29 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [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       ` org-bbdb-anniversaries-future Michael Welle
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

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