all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#15987: 24.3; diary-add-to-list ignored by diary-mark-entries
@ 2013-11-28 14:40 Roland Winkler
  2013-11-30 23:08 ` Glenn Morris
  2019-08-18 17:55 ` Stefan Kangas
  0 siblings, 2 replies; 14+ messages in thread
From: Roland Winkler @ 2013-11-28 14:40 UTC (permalink / raw)
  To: 15987

I am not an expert with diary and calendar, but it seems to me that
there is an unnecessary duplication of code in diary-list-entries
and diary-mark-entries making it rather difficult to feed entries
into diary-mark-entries if these entries do not come from a diary
file.

The context is the following:

BBDB 3 defines the function bbdb-anniv-diary-entries which adds
anniversaries from BBDB records to `diary-list-entries' by calling
diary-add-to-list.  This is a clean thing and works fine.

Now I've been asked on the BBDB mailing list how these anniversaries
from BBDB records can also be marked in the Emacs calendar, and it
seems to me that there is no easy way to achieve this.  The problem
seems to be that diary-add-to-list is used to set up the diary
buffer.  But diary-mark-entries (or more specifically
diary-mark-entries-1) parses the diary file(s) similarly to what
diary-list-entries is doing; but this is directly used to mark the
calendar buffer.  For marking calendar entries, there is no such
thing as the variable diary-list-entries where "other sources of
diary entries" (beyond diary files) could feed there entries to,
which are then all processed to generate the marking of the calendar
buffer.

Am I missing something?



In GNU Emacs 24.3.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.4.2)
 of 2013-10-04 on regnitz
Windowing system distributor `The X.Org Foundation', version 11.0.11103000
System Description:	Ubuntu 12.04.3 LTS





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

* bug#15987: 24.3; diary-add-to-list ignored by diary-mark-entries
  2013-11-28 14:40 bug#15987: 24.3; diary-add-to-list ignored by diary-mark-entries Roland Winkler
@ 2013-11-30 23:08 ` Glenn Morris
  2013-12-01  1:25   ` Roland Winkler
  2019-08-18 17:55 ` Stefan Kangas
  1 sibling, 1 reply; 14+ messages in thread
From: Glenn Morris @ 2013-11-30 23:08 UTC (permalink / raw)
  To: Roland Winkler; +Cc: 15987

"Roland Winkler" wrote:

> BBDB 3 defines the function bbdb-anniv-diary-entries which adds
> anniversaries from BBDB records to `diary-list-entries' by calling
> diary-add-to-list.  This is a clean thing and works fine.

Not sure I agree. It may happen to do something, but this function is
intended to be used to add entries from a literal diary file.
These days, it might be called "diary--add-to-list".
diary-entries-list is dynamically bound during certain diary operations,
it is not a generally accessible variable.

> Now I've been asked on the BBDB mailing list how these anniversaries
> from BBDB records can also be marked in the Emacs calendar, and it
> seems to me that there is no easy way to achieve this.

It's intended to mark entries from a diary-file, not arbitrary sources.
So I view this as a wishlist item to have non-diary sources treated as
diary entries. I don't think this is going to be a high priority for me
to implement, because it doesn't make much sense to me. Eg what will
happen when you press "d" on such a marked date in the calendar?
This "Searches the file named in `diary-file' for entries that match
[the date]". There will be no file to search.

Instead you could simply have a function that exports bbdb data to a
diary file, and include it from the main diary file. Then everything
would just work, right now.

I mean, you can do something horrible with hooks, eg

(add-hook 'diary-mark-entries-hook
           (lambda () (calendar-mark-date-pattern 11 11 2013)))

But don't do that, just export a diary file.





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

* bug#15987: 24.3; diary-add-to-list ignored by diary-mark-entries
  2013-11-30 23:08 ` Glenn Morris
@ 2013-12-01  1:25   ` Roland Winkler
  2013-12-01 12:03     ` Stephen Berman
  0 siblings, 1 reply; 14+ messages in thread
From: Roland Winkler @ 2013-12-01  1:25 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 15987

On Sat Nov 30 2013 Glenn Morris wrote:
> Not sure I agree. It may happen to do something, but this function is
> intended to be used to add entries from a literal diary file.
> These days, it might be called "diary--add-to-list".
> diary-entries-list is dynamically bound during certain diary operations,
> it is not a generally accessible variable.

BBDB's context is that bbdb-anniv-diary-entries is added to
diary-list-entries-hook (which is run when diary-entries-list is
properly bound).  The function bbdb-anniv-diary-entries then calls
diary-add-to-list.  This approach has been used by BBDB for 15
years and I believe that quite a few people have liked this.

No matter whether you consider this approach clean or not, I think
it is reasonable to have *some* mechanism for adding diary entries
from other sources than just diary files.

> It's intended to mark entries from a diary-file, not arbitrary sources.
> So I view this as a wishlist item to have non-diary sources treated as
> diary entries. I don't think this is going to be a high priority for me
> to implement, because it doesn't make much sense to me. Eg what will
> happen when you press "d" on such a marked date in the calendar?

Well, it would be nice to have some mechanism to let the external
source of diary entries define what should happen.  I mean, in the
case of BBDB this is obvious: when pressing "d" this should then
jump to the respective BBDB record.

> This "Searches the file named in `diary-file' for entries that match
> [the date]". There will be no file to search.
> 
> Instead you could simply have a function that exports bbdb data to a
> diary file, and include it from the main diary file. Then everything
> would just work, right now.

I don't know whether it makes much sense to jump to an entry in such
an auto-generated file.  I'd be rather confused.





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

* bug#15987: 24.3; diary-add-to-list ignored by diary-mark-entries
  2013-12-01  1:25   ` Roland Winkler
@ 2013-12-01 12:03     ` Stephen Berman
  2013-12-02  1:46       ` Roland Winkler
  0 siblings, 1 reply; 14+ messages in thread
From: Stephen Berman @ 2013-12-01 12:03 UTC (permalink / raw)
  To: Roland Winkler; +Cc: 15987

On Sat, 30 Nov 2013 19:25:11 -0600 "Roland Winkler" <winkler@gnu.org> wrote:

> Well, it would be nice to have some mechanism to let the external
> source of diary entries define what should happen.  I mean, in the
> case of BBDB this is obvious: when pressing "d" this should then
> jump to the respective BBDB record.

It should be possible to do this by implementing a BBDB function for
diary-goto-entry-function; see todo-diary-goto-entry for an example.
(In fact, diary-goto-entry-function was added when the new version of
todo-mode.el was added to Emacs, precisely for this purpose; note,
however, that Todo files that are meant to contain diary entries must be
included in the diary by the usual #include mechanism.)

Steve Berman





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

* bug#15987: 24.3; diary-add-to-list ignored by diary-mark-entries
  2013-12-01 12:03     ` Stephen Berman
@ 2013-12-02  1:46       ` Roland Winkler
  0 siblings, 0 replies; 14+ messages in thread
From: Roland Winkler @ 2013-12-02  1:46 UTC (permalink / raw)
  To: Stephen Berman; +Cc: 15987

On Sun Dec 1 2013 Stephen Berman wrote:
> It should be possible to do this by implementing a BBDB function for
> diary-goto-entry-function; see todo-diary-goto-entry for an example.
> (In fact, diary-goto-entry-function was added when the new version of
> todo-mode.el was added to Emacs, precisely for this purpose; note,
> however, that Todo files that are meant to contain diary entries must be
> included in the diary by the usual #include mechanism.)

Thanks, I'll look into this.  Hopefully, such an approach will not
require too dirty tricks.





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

* bug#15987: 24.3; diary-add-to-list ignored by diary-mark-entries
  2013-11-28 14:40 bug#15987: 24.3; diary-add-to-list ignored by diary-mark-entries Roland Winkler
  2013-11-30 23:08 ` Glenn Morris
@ 2019-08-18 17:55 ` Stefan Kangas
  2019-08-21  2:48   ` Roland Winkler
  1 sibling, 1 reply; 14+ messages in thread
From: Stefan Kangas @ 2019-08-18 17:55 UTC (permalink / raw)
  To: Roland Winkler; +Cc: 15987, Stephen Berman

"Roland Winkler" <winkler@gnu.org> writes:

> On Sun Dec 1 2013 Stephen Berman wrote:
>> It should be possible to do this by implementing a BBDB function for
>> diary-goto-entry-function; see todo-diary-goto-entry for an example.
>> (In fact, diary-goto-entry-function was added when the new version of
>> todo-mode.el was added to Emacs, precisely for this purpose; note,
>> however, that Todo files that are meant to contain diary entries must be
>> included in the diary by the usual #include mechanism.)
>
> Thanks, I'll look into this.  Hopefully, such an approach will not
> require too dirty tricks.

Hi Roland,

Did you ever get a chance to look into this?  I'm asking since it's
been a while (six years more or less), and it would be good if we
could clarify if this is indeed doable and/or desirable.

Thanks,
Stefan Kangas





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

* bug#15987: 24.3; diary-add-to-list ignored by diary-mark-entries
  2019-08-18 17:55 ` Stefan Kangas
@ 2019-08-21  2:48   ` Roland Winkler
  2019-08-21  3:06     ` Stefan Kangas
  0 siblings, 1 reply; 14+ messages in thread
From: Roland Winkler @ 2019-08-21  2:48 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 15987, Stephen Berman

On Sun Aug 18 2019 Stefan Kangas wrote:
> "Roland Winkler" <winkler@gnu.org> writes:
> > On Sun Dec 1 2013 Stephen Berman wrote:
> >> It should be possible to do this by implementing a BBDB function for
> >> diary-goto-entry-function; see todo-diary-goto-entry for an example.
> >> (In fact, diary-goto-entry-function was added when the new version of
> >> todo-mode.el was added to Emacs, precisely for this purpose; note,
> >> however, that Todo files that are meant to contain diary entries must be
> >> included in the diary by the usual #include mechanism.)
> >
> > Thanks, I'll look into this.  Hopefully, such an approach will not
> > require too dirty tricks.
> 
> Did you ever get a chance to look into this?  I'm asking since it's
> been a while (six years more or less), and it would be good if we
> could clarify if this is indeed doable and/or desirable.

Thanks for the reminder.  Some time ago, I implemented a solution to
this, see the function bbdb-anniv-goto-entry in bbdb-anniv.el that
serves as a value for diary-goto-entry-function (see BBDB in GNU
Elpa or the BBDB repository on savannah).  Despite its (current)
prefix `bbdb' the function bbdb-anniv-goto-entry is really
independent of BBDB and it should work for other packages, too.  The
idea is to give strings passed to `diary-add-to-list' a text
property `diary-goto-entry' which should be a list (FUNCTION ARG1
ARG2 ...), see the docstring of bbdb-anniv-goto-entry.  Then,
bbdb-anniv-goto-entry checks for the presence of this text property
and calls FUNCTION to locate the entry.

I believe, the cleanest, backward-compatible solution would be to
use bbdb-anniv-goto-entry as a replacement for diary-goto-entry
and declare diary-goto-entry-function obsolete.  (The obsolete
variable diary-goto-entry-function could be kept for some time
without harm.)





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

* bug#15987: 24.3; diary-add-to-list ignored by diary-mark-entries
  2019-08-21  2:48   ` Roland Winkler
@ 2019-08-21  3:06     ` Stefan Kangas
  2019-08-21  3:41       ` Roland Winkler
  0 siblings, 1 reply; 14+ messages in thread
From: Stefan Kangas @ 2019-08-21  3:06 UTC (permalink / raw)
  To: Roland Winkler; +Cc: 15987, Stephen Berman

Roland Winkler <winkler@gnu.org> writes:

> I believe, the cleanest, backward-compatible solution would be to
> use bbdb-anniv-goto-entry as a replacement for diary-goto-entry
> and declare diary-goto-entry-function obsolete.  (The obsolete
> variable diary-goto-entry-function could be kept for some time
> without harm.)

Thanks for clarifying.  Would you be willing to write that up, if
everyone agrees on the solution?

Thanks,
Stefan Kangas





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

* bug#15987: 24.3; diary-add-to-list ignored by diary-mark-entries
  2019-08-21  3:06     ` Stefan Kangas
@ 2019-08-21  3:41       ` Roland Winkler
  2019-08-21 13:29         ` Stefan Kangas
  0 siblings, 1 reply; 14+ messages in thread
From: Roland Winkler @ 2019-08-21  3:41 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 15987, Stephen Berman

On Wed Aug 21 2019 Stefan Kangas wrote:
> Roland Winkler <winkler@gnu.org> writes:
> 
> > I believe, the cleanest, backward-compatible solution would be to
> > use bbdb-anniv-goto-entry as a replacement for diary-goto-entry
> > and declare diary-goto-entry-function obsolete.  (The obsolete
> > variable diary-goto-entry-function could be kept for some time
> > without harm.)
> 
> Thanks for clarifying.  Would you be willing to write that up, if
> everyone agrees on the solution?

Sure, I can do what I said above.  (I do not know todo-mode that
currently "hijacks" diary-goto-entry-function for its purposes.
It is probably easier if someone else can do that part.)





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

* bug#15987: 24.3; diary-add-to-list ignored by diary-mark-entries
  2019-08-21  3:41       ` Roland Winkler
@ 2019-08-21 13:29         ` Stefan Kangas
  2019-08-21 14:10           ` Stephen Berman
  0 siblings, 1 reply; 14+ messages in thread
From: Stefan Kangas @ 2019-08-21 13:29 UTC (permalink / raw)
  To: Roland Winkler; +Cc: 15987, Stephen Berman

Roland Winkler <winkler@gnu.org> writes:
>
> On Wed Aug 21 2019 Stefan Kangas wrote:
> > Roland Winkler <winkler@gnu.org> writes:
> >
> > > I believe, the cleanest, backward-compatible solution would be to
> > > use bbdb-anniv-goto-entry as a replacement for diary-goto-entry
> > > and declare diary-goto-entry-function obsolete.  (The obsolete
> > > variable diary-goto-entry-function could be kept for some time
> > > without harm.)
> >
> > Thanks for clarifying.  Would you be willing to write that up, if
> > everyone agrees on the solution?
>
> Sure, I can do what I said above.  (I do not know todo-mode that
> currently "hijacks" diary-goto-entry-function for its purposes.
> It is probably easier if someone else can do that part.)

Thanks.  I'm not familiar with the code in question so if you need a
second opinion or help with todo-mode, it would have to come from
someone other than me.

Best regards,
Stefan Kangas





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

* bug#15987: 24.3; diary-add-to-list ignored by diary-mark-entries
  2019-08-21 13:29         ` Stefan Kangas
@ 2019-08-21 14:10           ` Stephen Berman
  2019-08-21 15:46             ` Roland Winkler
  0 siblings, 1 reply; 14+ messages in thread
From: Stephen Berman @ 2019-08-21 14:10 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 15987, Roland Winkler

On Wed, 21 Aug 2019 15:29:22 +0200 Stefan Kangas <stefan@marxist.se> wrote:

> Roland Winkler <winkler@gnu.org> writes:
>>
>> On Wed Aug 21 2019 Stefan Kangas wrote:
>> > Roland Winkler <winkler@gnu.org> writes:
>> >
>> > > I believe, the cleanest, backward-compatible solution would be to
>> > > use bbdb-anniv-goto-entry as a replacement for diary-goto-entry
>> > > and declare diary-goto-entry-function obsolete.  (The obsolete
>> > > variable diary-goto-entry-function could be kept for some time
>> > > without harm.)
>> >
>> > Thanks for clarifying.  Would you be willing to write that up, if
>> > everyone agrees on the solution?
>>
>> Sure, I can do what I said above.  (I do not know todo-mode that
>> currently "hijacks" diary-goto-entry-function for its purposes.
>> It is probably easier if someone else can do that part.)
>
> Thanks.  I'm not familiar with the code in question so if you need a
> second opinion or help with todo-mode, it would have to come from
> someone other than me.

If diary-goto-entry-function is replaced, I'll adapt the todo-mode code
as needed.

Steve Berman





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

* bug#15987: 24.3; diary-add-to-list ignored by diary-mark-entries
  2019-08-21 14:10           ` Stephen Berman
@ 2019-08-21 15:46             ` Roland Winkler
  2019-08-21 16:31               ` Stephen Berman
  0 siblings, 1 reply; 14+ messages in thread
From: Roland Winkler @ 2019-08-21 15:46 UTC (permalink / raw)
  To: Stephen Berman; +Cc: 15987, Stefan Kangas

On Wed Aug 21 2019 Stephen Berman wrote:
> If diary-goto-entry-function is replaced, I'll adapt the todo-mode
> code as needed.

The goal is not to replace diary-goto-entry-function with something
else, but instead diary-goto-entry becomes extensible so that
diary-goto-entry-function is not needed anymore.

For this, can you modify todo-mode such that it will put a text
property diary-goto-entry on "its" diary entries?  The value of this
text property should be a list (FUNCTION ARG1 ARG2 ...)  where
FUNCTION will handle the diary entry of todo-mode when called with
args ARG1 ARG2 ... So diary-goto-entry can branch accordingly.






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

* bug#15987: 24.3; diary-add-to-list ignored by diary-mark-entries
  2019-08-21 15:46             ` Roland Winkler
@ 2019-08-21 16:31               ` Stephen Berman
  2019-08-21 16:46                 ` Roland Winkler
  0 siblings, 1 reply; 14+ messages in thread
From: Stephen Berman @ 2019-08-21 16:31 UTC (permalink / raw)
  To: Roland Winkler; +Cc: 15987, Stefan Kangas

On Wed, 21 Aug 2019 10:46:23 -0500 "Roland Winkler" <winkler@gnu.org> wrote:

> On Wed Aug 21 2019 Stephen Berman wrote:
>> If diary-goto-entry-function is replaced, I'll adapt the todo-mode
>> code as needed.
>
> The goal is not to replace diary-goto-entry-function with something
> else, but instead diary-goto-entry becomes extensible so that
> diary-goto-entry-function is not needed anymore.
>
> For this, can you modify todo-mode such that it will put a text
> property diary-goto-entry on "its" diary entries?  The value of this
> text property should be a list (FUNCTION ARG1 ARG2 ...)  where
> FUNCTION will handle the diary entry of todo-mode when called with
> args ARG1 ARG2 ... So diary-goto-entry can branch accordingly.

Ah, now I remember you told me about this previously (more than two and
a half years ago).  As I said back then, if this requires changing how
todo-mode entries are added to the fancy diary display, it may take some
effort.  But if the consensus is that this is a good change for Emacs,
then I'm sure todo-mode can adapt to it.

Steve Berman





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

* bug#15987: 24.3; diary-add-to-list ignored by diary-mark-entries
  2019-08-21 16:31               ` Stephen Berman
@ 2019-08-21 16:46                 ` Roland Winkler
  0 siblings, 0 replies; 14+ messages in thread
From: Roland Winkler @ 2019-08-21 16:46 UTC (permalink / raw)
  To: Stephen Berman; +Cc: 15987, Stefan Kangas

On Wed Aug 21 2019 Stephen Berman wrote:
> Ah, now I remember you told me about this previously (more than two and
> a half years ago).  As I said back then, if this requires changing how
> todo-mode entries are added to the fancy diary display, it may take some
> effort.  But if the consensus is that this is a good change for Emacs,
> then I'm sure todo-mode can adapt to it.

(I believe the earlier email exchange was between you and me, and
not recorded as part of this thread.)

The problem is that diary-goto-entry-function is not easily
extensible: todo-mode is "hijacking" this variable for its purposes.
So this variable cannot easily be used anymore by another package.
What I am suggesting will allow more easily that multiple packages
can each do more easily their own thing: a text property tells
diary-goto-entry how it should branch out.

Does this make sense?  Or are there yet better solutions?





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

end of thread, other threads:[~2019-08-21 16:46 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-28 14:40 bug#15987: 24.3; diary-add-to-list ignored by diary-mark-entries Roland Winkler
2013-11-30 23:08 ` Glenn Morris
2013-12-01  1:25   ` Roland Winkler
2013-12-01 12:03     ` Stephen Berman
2013-12-02  1:46       ` Roland Winkler
2019-08-18 17:55 ` Stefan Kangas
2019-08-21  2:48   ` Roland Winkler
2019-08-21  3:06     ` Stefan Kangas
2019-08-21  3:41       ` Roland Winkler
2019-08-21 13:29         ` Stefan Kangas
2019-08-21 14:10           ` Stephen Berman
2019-08-21 15:46             ` Roland Winkler
2019-08-21 16:31               ` Stephen Berman
2019-08-21 16:46                 ` Roland Winkler

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.