[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
flet vs cl-flet vs compilation-start
From: |
Stephen Leake |
Subject: |
flet vs cl-flet vs compilation-start |
Date: |
Wed, 01 Feb 2017 17:33:28 -0600 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.1.91 (windows-nt) |
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.
I'm running emacs-25 compiled from the branch with mingw64.
This is consistent with the doc strings:
cl-flet says:
Make local function definitions.
flet says:
Make temporary overriding function definitions.
and goes on to say "use cl-flet".
Perhaps the doc string of flet should be improved to point out that
cl-flet does not produce _overriding_ function definitions, and suggest
workarounds.
I could try applying and removing advice on erase-buffer, but a simpler
workaround is to copy the buffer content into a local string var, then
paste it back.
Is there any support for introducing a parameter to compilation-start
that says "don't erase the buffer"?
--
-- Stephe
- flet vs cl-flet vs compilation-start,
Stephen Leake <=