emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* problem with diary sexps
@ 2022-04-01 15:44 Eric S Fraga
  2022-04-05 10:28 ` Christian Stuermer
  0 siblings, 1 reply; 10+ messages in thread
From: Eric S Fraga @ 2022-04-01 15:44 UTC (permalink / raw)
  To: org mode mailing list

Hello all,

I updated org today and now get

Bad sexp at line 461 in /home/ucecesf/s/notes/diary.org:
   (let ((entry ) (date '(4 19 2022))) (diary-float t 2 3))

for a line that looks like

<%%(diary-float t 2 3)>

This has been in my diary for a very long time with no error.  I wonder
if this has anything to do with the changes to the use of advice?
Nothing else in the recent changes in the git log seem to be relevant.

Just a quick heads up as I don't have time to debug at the moment.  It's
not mission critical...

Have a good weekend all.

-- 
: Eric S Fraga, with org release_9.5.2-423-g6d73cd in Emacs 29.0.50


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

* Re: problem with diary sexps
  2022-04-01 15:44 problem with diary sexps Eric S Fraga
@ 2022-04-05 10:28 ` Christian Stuermer
  2022-04-05 10:51   ` Eric S Fraga
  2022-04-05 11:22   ` Ihor Radchenko
  0 siblings, 2 replies; 10+ messages in thread
From: Christian Stuermer @ 2022-04-05 10:28 UTC (permalink / raw)
  To: emacs-orgmode

Hello!

Eric S Fraga writes:

> I updated org today and now get
> 
> Bad sexp at line 461 in /home/ucecesf/s/notes/diary.org:
>     (let ((entry ) (date '(4 19 2022))) (diary-float t 2 3))
> 
> for a line that looks like
> 
> <%%(diary-float t 2 3)>
> 
> This has been in my diary for a very long time with no error.  I wonder
> if this has anything to do with the changes to the use of advice?
> Nothing else in the recent changes in the git log seem to be relevant.


I've had the same problem after updating org from git with entries like

%%(org-anniversary 2000 4 4) X is %d years old


The commit introducing it is
https://github.com/bzg/org-mode/commit/6d73cd34a07796c33f9435bfc8c9a19e67656c7a

And the problem is gone, after reverting

	 (result (if calendar-debug-sexp (eval sexp t)
		   (condition-case nil
		       (eval sexp t)

back to

	 (result (if calendar-debug-sexp (eval sexp)
		   (condition-case nil
		       (eval sexp)

in org-diary-sexp-entry in org.el.

I wrote about in on Reddit:
https://www.reddit.com/r/orgmode/comments/tvwxv0/the_commit_on_apr_1_2022_broke_organniversary_for/

Kind regards,
Christian


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

* Re: problem with diary sexps
  2022-04-05 10:28 ` Christian Stuermer
@ 2022-04-05 10:51   ` Eric S Fraga
  2022-04-05 11:22   ` Ihor Radchenko
  1 sibling, 0 replies; 10+ messages in thread
From: Eric S Fraga @ 2022-04-05 10:51 UTC (permalink / raw)
  To: Christian Stuermer; +Cc: emacs-orgmode

On Tuesday,  5 Apr 2022 at 12:28, Christian Stuermer wrote:
> I've had the same problem after updating org from git with entries like
> The commit introducing it is
> https://github.com/bzg/org-mode/commit/6d73cd34a07796c33f9435bfc8c9a19e67656c7a
>
> And the problem is gone, after reverting
>
>         (result (if calendar-debug-sexp (eval sexp t)
>                   (condition-case nil
>                       (eval sexp t)
>
> back to
>
>         (result (if calendar-debug-sexp (eval sexp)
>                   (condition-case nil
>                       (eval sexp)
>
> in org-diary-sexp-entry in org.el.

Confirmed.  Reverting this particular change makes diary sexps work
again properly (i.e. without complaint).

Thank you,
eric

-- 
: Eric S Fraga, with org release_9.5.2-423-g6d73cd in Emacs 29.0.50


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

* Re: problem with diary sexps
  2022-04-05 10:28 ` Christian Stuermer
  2022-04-05 10:51   ` Eric S Fraga
@ 2022-04-05 11:22   ` Ihor Radchenko
  2022-04-05 11:39     ` Eric S Fraga
  2022-04-05 16:06     ` Max Nikulin
  1 sibling, 2 replies; 10+ messages in thread
From: Ihor Radchenko @ 2022-04-05 11:22 UTC (permalink / raw)
  To: Christian Stuermer; +Cc: emacs-orgmode

Christian Stuermer <orgmode-ml@recentlyrezzed.de> writes:

> And the problem is gone, after reverting
>
> 	 (result (if calendar-debug-sexp (eval sexp t)
> 		   (condition-case nil
> 		       (eval sexp t)
>
> back to
>
> 	 (result (if calendar-debug-sexp (eval sexp)
> 		   (condition-case nil
> 		       (eval sexp)
>
> in org-diary-sexp-entry in org.el.

More accurate error can be found after setting calendar-debug-sexp to t.
I got the following backtrace clearly indicating lexical scope issue:

Debugger entered--Lisp error: (void-variable entry)
  (diary-float t 2 1)
  (let ((entry "") (date '(4 5 2022))) (diary-float t 2 1))
  (eval (let ((entry "") (date '(4 5 2022))) (diary-float t 2 1)) t)

Best,
Ihor


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

* Re: problem with diary sexps
  2022-04-05 11:22   ` Ihor Radchenko
@ 2022-04-05 11:39     ` Eric S Fraga
  2022-04-08  2:59       ` Ihor Radchenko
  2022-04-05 16:06     ` Max Nikulin
  1 sibling, 1 reply; 10+ messages in thread
From: Eric S Fraga @ 2022-04-05 11:39 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Christian Stuermer, emacs-orgmode

On Tuesday,  5 Apr 2022 at 19:22, Ihor Radchenko wrote:
> More accurate error can be found after setting calendar-debug-sexp to t.
> I got the following backtrace clearly indicating lexical scope issue:

Which makes sense.  The diary code does use entry and date as global
variables so really needs updating...

-- 
: Eric S Fraga, with org release_9.5.2-423-g6d73cd in Emacs 29.0.50


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

* Re: problem with diary sexps
  2022-04-05 11:22   ` Ihor Radchenko
  2022-04-05 11:39     ` Eric S Fraga
@ 2022-04-05 16:06     ` Max Nikulin
  2022-10-19  2:30       ` [PATCH] Bind calendar-debug-sexp to non-nil when running tests (was: problem with diary sexps) Ihor Radchenko
  1 sibling, 1 reply; 10+ messages in thread
From: Max Nikulin @ 2022-04-05 16:06 UTC (permalink / raw)
  To: emacs-orgmode

On 05/04/2022 18:22, Ihor Radchenko wrote:
> Christian Stuermer writes:
> 
>> And the problem is gone, after reverting
>>
>> 	 (result (if calendar-debug-sexp (eval sexp t)
>> 		   (condition-case nil
>> 		       (eval sexp t)
>>
>> back to
>>
>> 	 (result (if calendar-debug-sexp (eval sexp)
>> 		   (condition-case nil
>> 		       (eval sexp)
>>
>> in org-diary-sexp-entry in org.el.
> 
> More accurate error can be found after setting calendar-debug-sexp to t.
> I got the following backtrace clearly indicating lexical scope issue:
> 
> Debugger entered--Lisp error: (void-variable entry)
>    (diary-float t 2 1)
>    (let ((entry "") (date '(4 5 2022))) (diary-float t 2 1))
>    (eval (let ((entry "") (date '(4 5 2022))) (diary-float t 2 1)) t)

It looks like the source of the problem with unit tests that I faced 
yesterday trying to look closer at the bug with daylight saving time in 
agenda.

Bad sexp at line 25 in /home/ubuntu/src/org-mode/testing/examples
/agenda-file.org: (let ((entry ) (date '(3 25 2022))) (diary-date 3 25 
2022))

      ((should
        (= 3
           (count-lines ... ...)))
       :form

    FAILED  255/900  test-org-agenda/property-timestamp (2.018120 sec)

Emacs-27.3



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

* Re: problem with diary sexps
  2022-04-05 11:39     ` Eric S Fraga
@ 2022-04-08  2:59       ` Ihor Radchenko
  2022-04-08 10:46         ` Eric S Fraga
  0 siblings, 1 reply; 10+ messages in thread
From: Ihor Radchenko @ 2022-04-08  2:59 UTC (permalink / raw)
  To: Eric S Fraga; +Cc: Christian Stuermer, emacs-orgmode

Eric S Fraga <e.fraga@ucl.ac.uk> writes:

> On Tuesday,  5 Apr 2022 at 19:22, Ihor Radchenko wrote:
>> More accurate error can be found after setting calendar-debug-sexp to t.
>> I got the following backtrace clearly indicating lexical scope issue:
>
> Which makes sense.  The diary code does use entry and date as global
> variables so really needs updating...

Should be fixed now in f6813dbe. See https://orgmode.org/list/87zgkxjb0m.fsf@gnu.org

Best,
Ihor


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

* Re: problem with diary sexps
  2022-04-08  2:59       ` Ihor Radchenko
@ 2022-04-08 10:46         ` Eric S Fraga
  0 siblings, 0 replies; 10+ messages in thread
From: Eric S Fraga @ 2022-04-08 10:46 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Christian Stuermer, emacs-orgmode

On Friday,  8 Apr 2022 at 10:59, Ihor Radchenko wrote:
> Should be fixed now in f6813dbe. See

Confirmed.  Thank you!

-- 
: Eric S Fraga, with org release_9.5.2-426-gf6813d in Emacs 29.0.50


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

* [PATCH] Bind calendar-debug-sexp to non-nil when running tests (was: problem with diary sexps)
  2022-04-05 16:06     ` Max Nikulin
@ 2022-10-19  2:30       ` Ihor Radchenko
  2022-11-11  3:36         ` Ihor Radchenko
  0 siblings, 1 reply; 10+ messages in thread
From: Ihor Radchenko @ 2022-10-19  2:30 UTC (permalink / raw)
  To: Max Nikulin; +Cc: emacs-orgmode

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

Max Nikulin <manikulin@gmail.com> writes:

>> More accurate error can be found after setting calendar-debug-sexp to t.
>> I got the following backtrace clearly indicating lexical scope issue:
>> 
>> Debugger entered--Lisp error: (void-variable entry)
>>    (diary-float t 2 1)
>>    (let ((entry "") (date '(4 5 2022))) (diary-float t 2 1))
>>    (eval (let ((entry "") (date '(4 5 2022))) (diary-float t 2 1)) t)
>
> It looks like the source of the problem with unit tests that I faced 
> yesterday trying to look closer at the bug with daylight saving time in 
> agenda.

I guess we can permanently bind calendar-debug-sexp to non-nil in tests.
It should help if we encounter diary-related issues in future.

WDYT?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-testing-Provide-more-debug-info-for-diary-sexps.patch --]
[-- Type: text/x-patch, Size: 1610 bytes --]

From e86bbe12b79f9958fcd5ccf1586e9d9c829ee8c2 Mon Sep 17 00:00:00 2001
Message-Id: <e86bbe12b79f9958fcd5ccf1586e9d9c829ee8c2.1666146565.git.yantar92@posteo.net>
From: Ihor Radchenko <yantar92@posteo.net>
Date: Wed, 19 Oct 2022 10:28:40 +0800
Subject: [PATCH] testing: Provide more debug info for diary sexps

* testing/org-test.el (org-test-run-batch-tests):
(org-test-run-all-tests): Bind `calendar-debug-sexp' to non-nil when
running tests.

See https://orgmode.org/list/t2hpe9$119m$1@ciao.gmane.io
---
 testing/org-test.el | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/testing/org-test.el b/testing/org-test.el
index 9f7bab9ea..65d157bca 100644
--- a/testing/org-test.el
+++ b/testing/org-test.el
@@ -457,7 +457,9 @@ (defun org-test-run-batch-tests (&optional org-test-selector)
   (let ((org-id-track-globally t)
 	(org-test-selector
 	 (if org-test-selector org-test-selector "\\(org\\|ob\\)"))
-	org-confirm-babel-evaluate org-startup-folded vc-handled-backends)
+	org-confirm-babel-evaluate org-startup-folded vc-handled-backends
+        ;; Catch errors in diary sexps better.
+        (calendar-debug-sexp t))
     (org-test-touch-all-examples)
     (org-test-update-id-locations)
     (org-test-load)
@@ -471,7 +473,9 @@ (defun org-test-run-all-tests ()
   (org-test-touch-all-examples)
   (org-test-update-id-locations)
   (org-test-load)
-  (ert "\\(org\\|ob\\)")
+  (let (;; Catch errors in diary sexps better.
+        (calendar-debug-sexp t))
+    (ert "\\(org\\|ob\\)"))
   (org-test-kill-all-examples))
 
 (defmacro org-test-at-time (time &rest body)
-- 
2.35.1


[-- Attachment #3: Type: text/plain, Size: 225 bytes --]



-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

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

* Re: [PATCH] Bind calendar-debug-sexp to non-nil when running tests (was: problem with diary sexps)
  2022-10-19  2:30       ` [PATCH] Bind calendar-debug-sexp to non-nil when running tests (was: problem with diary sexps) Ihor Radchenko
@ 2022-11-11  3:36         ` Ihor Radchenko
  0 siblings, 0 replies; 10+ messages in thread
From: Ihor Radchenko @ 2022-11-11  3:36 UTC (permalink / raw)
  To: Max Nikulin; +Cc: emacs-orgmode

Ihor Radchenko <yantar92@posteo.net> writes:

> I guess we can permanently bind calendar-debug-sexp to non-nil in tests.
> It should help if we encounter diary-related issues in future.

Applied onto main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=c41a2198f2d7a3fbae5953f4b25c84cbe6692e2e

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


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

end of thread, other threads:[~2022-11-11  3:36 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-01 15:44 problem with diary sexps Eric S Fraga
2022-04-05 10:28 ` Christian Stuermer
2022-04-05 10:51   ` Eric S Fraga
2022-04-05 11:22   ` Ihor Radchenko
2022-04-05 11:39     ` Eric S Fraga
2022-04-08  2:59       ` Ihor Radchenko
2022-04-08 10:46         ` Eric S Fraga
2022-04-05 16:06     ` Max Nikulin
2022-10-19  2:30       ` [PATCH] Bind calendar-debug-sexp to non-nil when running tests (was: problem with diary sexps) Ihor Radchenko
2022-11-11  3:36         ` Ihor Radchenko

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