From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.bugs Subject: bug#49995: 28.0.50; EBDB Anniversaries do not appear marked in calendar Date: Tue, 17 Aug 2021 12:45:58 -0700 Message-ID: <87y28zua6h.fsf@ericabrahamsen.net> References: <87h7ft5ea2.fsf@ericabrahamsen.net> <877dgogihz.fsf@web.de> <87y293527m.fsf@ericabrahamsen.net> <87bl5zxso8.fsf@ericabrahamsen.net> <871r6uhmn9.fsf@web.de> <87y292wzmy.fsf@ericabrahamsen.net> <87tujqwvi9.fsf@ericabrahamsen.net> <87k0kmwjie.fsf@ericabrahamsen.net> <87r1es56wf.fsf@web.de> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11514"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 49995@debbugs.gnu.org, Pankaj Jangid To: Michael Heerdegen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Aug 17 21:47:30 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mG53a-0002kH-6a for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 17 Aug 2021 21:47:30 +0200 Original-Received: from localhost ([::1]:55170 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mG53Z-00018b-60 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 17 Aug 2021 15:47:29 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53672) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mG539-0000jx-0b for bug-gnu-emacs@gnu.org; Tue, 17 Aug 2021 15:47:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:42621) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mG538-0004zM-QN for bug-gnu-emacs@gnu.org; Tue, 17 Aug 2021 15:47:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mG538-0000Pu-FA for bug-gnu-emacs@gnu.org; Tue, 17 Aug 2021 15:47:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eric Abrahamsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 17 Aug 2021 19:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49995 X-GNU-PR-Package: emacs Original-Received: via spool by 49995-submit@debbugs.gnu.org id=B49995.16292295711540 (code B ref 49995); Tue, 17 Aug 2021 19:47:02 +0000 Original-Received: (at 49995) by debbugs.gnu.org; 17 Aug 2021 19:46:11 +0000 Original-Received: from localhost ([127.0.0.1]:54167 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mG52J-0000Ol-0c for submit@debbugs.gnu.org; Tue, 17 Aug 2021 15:46:11 -0400 Original-Received: from mail.ericabrahamsen.net ([52.70.2.18]:34290) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mG52E-0000O6-Ml for 49995@debbugs.gnu.org; Tue, 17 Aug 2021 15:46:09 -0400 Original-Received: from localhost (75-172-126-110.tukw.qwest.net [75.172.126.110]) (Authenticated sender: eric@ericabrahamsen.net) by mail.ericabrahamsen.net (Postfix) with ESMTPSA id A76F7FA07F; Tue, 17 Aug 2021 19:45:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericabrahamsen.net; s=mail; t=1629229559; bh=AyYfmt2pg+mNtgzd3t8OcshQPgtzEUVREaA3yLI6u20=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=X0SQ2/SUdbFheOofZIikv0X0x6E0EegXqiQy0xzHnk+uiWEWFLBdjJ0Gao3IxtusL zZGfnvVxHN7K/x14tphS6l72R4LE35BslzH6c4pRmBYU6gopGTLG7YUkQtYGD1W1c0 PeAUrISAczCHWHIZcZe/Vw7u8yLqfWbps+q4H3EA= In-Reply-To: <87r1es56wf.fsf@web.de> (Michael Heerdegen's message of "Tue, 17 Aug 2021 19:16:00 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:212109 Archived-At: On 08/17/21 19:16 PM, Michael Heerdegen wrote: > Eric Abrahamsen writes: > >> And, because I apparently have nothing else to do on a weekend, here's a >> version that just calls a function directly, nothing fancy. Some overlap >> with `diary-anniversary', but nothing terrible. This is probably the >> best approach. > > Yes, looks like more or less what I had suggested. Hope it turns out it > was the right advice. I'm sure it will, I just had to waste a few hours trying out alternate approaches first :) >> -;; `ebdb-field-anniv-diary-entry' is defined below. >> +(defun ebdb-diary-anniversaries (&optional mark) >> + (with-no-warnings >> + (defvar date) >> + (defvar original-date)) >> + (when-let ((entries (gethash (seq-subseq date 0 2) ebdb-diary-entries))) >> + (cons mark >> + (mapconcat (pcase-lambda (`(,field ,record)) >> + (if (bound-and-true-p original-date) >> + ;; If we have `original-date', we're >> + ;; displaying the diary list, so we need >> + ;; the detailed string. >> + (ebdb-field-anniv-diary-entry >> + field record (nth 2 date)) >> + ;; If not, we're just marking dates on the >> + ;; calendar, so any non-nil response value is >> + ;; fine. >> + entry)) >> + entries "; ")))) > > Do you really expect that this if-clause has a measurable effect on > performance? Most people will not have thousands of anniversaries in > their database (and even then, they probably don't want to have them all > listed). OTOH you now need to rely on an internal aspect of the > implementation. Dunno, I just figured that, when marking, the function gets called ~90 times in a row, potentially over and over again as the user scrolls the Calendar. Other diary functions come with warnings about potential slowdowns during marking, and the user might have a large number of these various functions, so I thought I'd just try to make this as polite as possible. Probably I'm over-thinking it, but on the other hand, the code's already written... > Some more thoughts about this matter: > > Do have a version for the Org agenda? I see BBDB has > `org-bbdb-anniversaries'. It handles the 2/29 problem btw. Oops, I've already handled the 2/29 problem, it just didn't make it into the diff because I hadn't committed that bit yet. There's nothing explicit for the agenda, I guess `ebdb-diary-anniversaries' behaves pretty much the same as `org-bbdb-anniversaries': you can either stick it in your diary file, if you use the diary, or in an Org file, if you don't. > What I as a user would wish (for the Diary and Org) would be a way to > control on a per-field basis (1) which anniversaries are listed, (2) how > they are presented and (3) a way to allow reminders for some (I might > need some weeks time to buy a present for some people, while I only want > to congratulate others so I don't need a reminder for most). Okay, thanks for these suggestions! There are many, many aspects of EBDB where I know I could be doing more, and it's great to have some explicit requests. I'm thinking about how best to separate concerns. The user might want notifications about EBDB contacts, and might be using the diary, or Org, or maybe neither of those. EBDB fields should store basic information like: notify or don't notify, an optional custom notification string, and an optional number of days in advance to notify. If a field has a number of advance days, it puts itself in the hash table twice: on its own date, and on its advance date. Then there's a `ebdb-use-notifications' option: if non-nil, EBDB displays messages itself, at load time and also record display time. Otherwise, `ebdb-diary-anniversaries' works the way it does now, for only the diary, or in Org. Maybe, additionally, we provide a `ebdb-export-to-org' command that writes an Org file holding all our anniversaries as headings, with advance notifications implemented as DEADLINE lines with a warning period. I could use custom properties to identify headlines, so running the command multiple times would only add headings that aren't there already, allowing the user to edit the headlines or add more stuff after export. How does all of that sound? In the meantime, I'll get this code in and a new EBDB version released. I'm sure Pankaj has been thrilled to get dragged through this long thread, but that's no reason to delay :) Eric