all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* flet vs cl-flet vs compilation-start
@ 2017-02-01 23:33 Stephen Leake
  2017-02-01 23:49 ` John Mastro
  2017-02-02  9:16 ` Michael Heerdegen
  0 siblings, 2 replies; 3+ messages in thread
From: Stephen Leake @ 2017-02-01 23:33 UTC (permalink / raw)
  To: emacs-devel

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



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-02-02  9:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-01 23:33 flet vs cl-flet vs compilation-start Stephen Leake
2017-02-01 23:49 ` John Mastro
2017-02-02  9:16 ` Michael Heerdegen

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.