[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: flet vs cl-flet vs compilation-start
From: |
Michael Heerdegen |
Subject: |
Re: flet vs cl-flet vs compilation-start |
Date: |
Thu, 02 Feb 2017 10:16:15 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) |
Stephen Leake <address@hidden> writes:
> I'm using compilation-mode to show results from running an external
> program; it produces output that looks like compilation errors (it's
> actually cross-reference info).
>
> Some users would like to preserve output from several calls to the
> external program.
>
> compilation-start does not provide an option for this; it calls
> (erase-buffer) unconditionally.
>
> So someone suggested this hack:
>
> (require 'cl)
> (flet ((erase-buffer nil (goto-char (point-max))))
> (compilation-start ... ))
>
> That works, but produces byte-compiler warnings about cl and flet.
>
> So I tried:
>
> (require 'cl-lib)
> (cl-flet ((erase-buffer nil (goto-char (point-max))))
> (compilation-start ... ))
>
> This does _not_ work. Apparently in the "flet" case, the local
> definition of 'erase-buffer' overrides the global one, but in the
> 'cl-flet' case it does not.
The cause is that the function bindings created by cl-flet and cl-labels
have lexical scope. And that is documented.
As already has been mentioned, as a last resort, use cl-letf in such
cases.
Michael.