emacs-devel
[Top][All Lists]
Advanced

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

Re: Adding use-package to ELPA


From: Philip Kaludercic
Subject: Re: Adding use-package to ELPA
Date: Mon, 07 Mar 2022 23:12:17 +0000

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> True, because the above examples just expands to
>>
>>       (setq smtpmail-smtp-service 587)
>>
>> I'd usually recommend to use a local macro to avoid these issues,
>> because something like
>>
>>       (setup smtpmail
>>         (:option smtpmail-smtp-service 587))
>>
>> would expand to a `customize-set-variable'-like code, where
>> `smtpmail-smtp-service' would appear as a quoted symbol.
>
> If it expands to `customize-set-variable`, then presumably you wouldn't
> get the warning, indeed (that's good) but you also wouldn't get
> a warning if you mistype the var (less good).
>
> I want both: absence of warnings when the var name is right, and
> presence of a warning when it isn't (and presence of a warning when the
> var is obsolete).

True, so this is certainly worth investigating.  Yet this is only part
of the problem, as function have a similar pattern, but they cannot
reliably be detected in this way.  E.g.

  (setup foo (:hook bar))

wouldn't be able to infer that bar is a function that exists, just
because it is being added to foo-bar-mode.

>>> So `setup.el` could maybe do something like:
>>>
>>>     (defmacro setup (pkg &rest args)
>>>       (when (we-are-byte-compiling-p)
>>>         (require (byte-run-strip-symbol-positions pkg)))
>>>       ...)
>>
>> What is the point of using byte-run-strip-symbol-positions here?
>
> Macros receive source code as input, which can/should come with
> source-position information.  Before we can safely run that code we need
> to strip the position info.

I'm glad to see that there are always some details about macros one
doesn't know about.

>> I just tried something like this, but it doesn't seem to work.
>
> I'm glad to see that I'm still able to write incorrect code.

Eh, my bad, I had used (macroexp-compiling-p) that apparently didn't do
the right job.  Without that check, it works in principle, but of course
doesn't do the intended thing.

-- 
        Philip Kaludercic



reply via email to

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