emacs-devel
[Top][All Lists]
Advanced

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

Re: Last use of defadvice in Emacs


From: Alan Mackenzie
Subject: Re: Last use of defadvice in Emacs
Date: Fri, 8 Apr 2022 18:06:32 +0000

Hello, Stefan.

On Fri, Apr 08, 2022 at 13:39:58 -0400, Stefan Monnier wrote:
> >>     (defmacro url-http-ntlm--if-when-compile (cond &rest body)
> >>       (declare (debug t) (indent 1))
> >>       (when (eval cond)
> >>         `(progn ,@body)))

> >>     ;; Remove authorization after redirect.
> >>     (url-http-ntlm--if-when-compile
> >>         (and (boundp 'emacs-major-version)
> >>             (< emacs-major-version 25))
> >>       ...
> >>       ... Various code, including, incidentally, a `defadvice` ...
> >>       ...)

> > Here, a piece of `byte-code' gets compiled for the
> > url-http-ntlm--if-when-compile call.  This is useless code without any
> > useful function.  (I've just tried it.)

> That bytecode implements your #if feature.  So if we care about that
> feature, we'd remove the `url-http-ntlm--` prefix and move it to
> lisp/subr.el, indeed.

Apologies, you are right.  That piece of byte code is indeed part of the
macro's definition, not something generated by it.  I tried compiling a
source file with just (require ...) (defun foo ...)
(url-http-ntlm--if-when-compile ..) and (defun bar ...), and in the
..elc, the foo and the bar had nothing intervening between them.

> I agree that Emacs does not come with the equivalent of #if but the
> above macro shows that it can be implemented quite easily if we care to
> provide it.

Yes.  :-)

[ .... ]

>         Stefan

-- 
Alan Mackenzie (Nuremberg, Germany).



reply via email to

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