Re: [O] org-bbdb-anniversaries-future

2017-03-17 Thread Nicolas Goaziou
Hello,

Michael Welle  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



Re: [O] org-bbdb-anniversaries-future

2017-03-13 Thread Michael Welle
Hello,

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


Michael Welle  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



Re: [O] org-bbdb-anniversaries-future

2017-03-13 Thread Michael Welle
Hello,

Nicolas Goaziou wrote:
> 
> Hello,
> 
> Michael Welle  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



Re: [O] org-bbdb-anniversaries-future

2017-03-12 Thread Nicolas Goaziou
Hello,

Michael Welle  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



Re: [O] org-bbdb-anniversaries-future

2017-03-07 Thread Michael Welle
Hello,

Nicolas Goaziou  writes:

> Hello,
>
> Michael Welle  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

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


Re: [O] org-bbdb-anniversaries-future

2017-03-05 Thread Nicolas Goaziou
Hello,

Michael Welle  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



Re: [O] org-bbdb-anniversaries-future

2017-03-01 Thread Michael Welle
Hello,

Alan Schmitt  writes:

> On 2017-03-01 15:03, Michael Welle  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



Re: [O] org-bbdb-anniversaries-future

2017-03-01 Thread Rasmus
Michael Welle  writes:

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

You might want to discuss this with the FSF copyright clerk

copyright-cl...@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




Re: [O] org-bbdb-anniversaries-future

2017-03-01 Thread Alan Schmitt
On 2017-03-01 15:03, Michael Welle  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


signature.asc
Description: PGP signature


Re: [O] org-bbdb-anniversaries-future

2017-03-01 Thread Michael Welle
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

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

2017-03-01 Thread Nicolas Goaziou
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 ;)

> 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



Re: [O] org-bbdb-anniversaries-future

2017-03-01 Thread Marco Wahl


binMkTW0VNkZi.bin
Description: application/pgp-encrypted


binE8pzhIaYry.bin
Description: Binary data


Re: [O] org-bbdb-anniversaries-future

2017-03-01 Thread Marco Wahl
Alan Schmitt  writes:

> Hello,
>
> On 2016-07-14 14:09, Michael Welle  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




Re: [O] org-bbdb-anniversaries-future

2017-03-01 Thread Michael Welle
Hello,

Alan Schmitt  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



Re: [O] org-bbdb-anniversaries-future

2017-03-01 Thread Alan Schmitt
Hello,

On 2016-07-14 14:09, Michael Welle  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


signature.asc
Description: PGP signature


Re: [O] org-bbdb-anniversaries-future

2016-07-14 Thread Marco Wahl
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




Re: [O] org-bbdb-anniversaries-future

2016-03-08 Thread Georges
Nick Dokos  gmail.com> writes:

> Michael Welle  gmx.net> writes:
> 
> > Marco Wahl  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.

--