[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trying to cope with Calendar's dynamic scoping

From: Glenn Morris
Subject: Re: Trying to cope with Calendar's dynamic scoping
Date: Thu, 05 Sep 2013 00:58:35 -0400
User-agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/)

This looks really neat. Was there any particular aspect you thought
might not work? If not, I suggest moving to the traditional Emacs
testing phase of "install it and see what breaks".

Some minor comments follow.

> --- lisp/calendar/calendar.el 2013-08-07 00:06:43 +0000
> +++ lisp/calendar/calendar.el 2013-08-20 21:47:27 +0000

> +(defmacro calendar--eval (exp-exp env)

You've marked this as internal, but a third-party library might need to
use it. Eg if someone writes cal-foo.el for the foo calendar, it may
need to use this.

> +  "Eval the value of EXP-EXP in the context ENV.
> +ENV is a let-style list of bindings."

Is there any value in making such a macro generally available?
It seems to recreate "evaluate a user-supplied expression with access to
certain dynamically bound variables" in a lexical environment.
I imagine calendar is not the only package doing that.

(Also, it seems to use the internal details of how closures are
implemented, which the lisp manual says is a no-no.)

> +(defmacro calendar--evalconcat (env exp-list sep)
> +  "Concatenate the result of evaluating the expressions in EXP-LIST.
> +Each expression in the list returned by EXP-LIST is evaluated in the context
> +ENV, while is a let-style list of bindings.  SEP is the string to place 
> between


>  Inserts STRING so that it ends at INDENT.  STRING is either a
>  literal string, or a sexp to evaluate to return such.  Truncates
>  STRING to length TRUNCATE, and ensures a trailing space."
> -  (if (not (ignore-errors (stringp (setq string (eval string)))))
> +  (if (not (ignore-errors (stringp string)))

It doesn't evaluate STRING any more, so the doc is wrong and the
ignore-errors is not needed.

calendar-string-spread does not evaluate its arg any more either.

You changed all the internal uses of both of these so that the eval
happens in the caller, so that's fine, but I think third-party libs
might be using these. So could they eval their arguments once more, with
day/month/year available?

> --- lisp/calendar/diary-lib.el        2013-08-05 14:26:57 +0000
> +++ lisp/calendar/diary-lib.el        2013-08-20 21:52:49 +0000

>  (defun diary-list-entries-1 (months symbol absfunc)
>    "List diary entries of a certain type.
>  MONTHS is an array of month names.  SYMBOL marks diary entries of the type
>  in question.  ABSFUNC is a function that converts absolute dates to dates
>  of the appropriate type."
> +  (defvar original-date)
> +  (defvar number)

What's the significance of a defvar within a defun in this way?

> +Both ENTRY and DATE are available (as `entry' resp. `date') when the SEXP

"(as `entry' and `date', respectively)"?

otodo-mode.el still uses `date' and `entry' rather than `diary-date',
and may need updating.

Thanks again for doing this!

reply via email to

[Prev in Thread] Current Thread [Next in Thread]