all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stephen Leake <stephen_leake@stephe-leake.org>
To: emacs-devel <emacs-devel@gnu.org>
Subject: flet vs cl-flet vs compilation-start
Date: Wed, 01 Feb 2017 17:33:28 -0600	[thread overview]
Message-ID: <86mve51o6v.fsf@stephe-leake.org> (raw)

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



             reply	other threads:[~2017-02-01 23:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-01 23:33 Stephen Leake [this message]
2017-02-01 23:49 ` flet vs cl-flet vs compilation-start John Mastro
2017-02-02  9:16 ` Michael Heerdegen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86mve51o6v.fsf@stephe-leake.org \
    --to=stephen_leake@stephe-leake.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.