From: Stefan Monnier <monnier@iro.umontreal.ca>
To: martin rudalics <rudalics@gmx.at>
Cc: Juanma Barranquero <lekktu@gmail.com>,
Chong Yidong <cyd@stupidchicken.com>,
Emacs developers <emacs-devel@gnu.org>
Subject: Re: [Emacs-diffs] /srv/bzr/emacs/trunk r103444: * lisp/facemenu.el (list-colors-display): Use with-help-window (Bug#8048).
Date: Sun, 06 Mar 2011 00:22:05 -0500 [thread overview]
Message-ID: <jwvk4gcsu2k.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <4D7225C4.4080300@gmx.at> (martin rudalics's message of "Sat, 05 Mar 2011 13:00:04 +0100")
> Suppose we rewrote `with-output-to-temp-buffer' in Elisp then we would
Find below the definition of with-output-to-temp-buffer on the
lexbind branch (which BTW is getting pretty close to ready for
inclusion).
Stefan
(defmacro with-output-to-temp-buffer (bufname &rest body)
"Bind `standard-output' to buffer BUFNAME, eval BODY, then show that buffer.
This construct makes buffer BUFNAME empty before running BODY.
It does not make the buffer current for BODY.
Instead it binds `standard-output' to that buffer, so that output
generated with `prin1' and similar functions in BODY goes into
the buffer.
At the end of BODY, this marks buffer BUFNAME unmodifed and displays
it in a window, but does not select it. The normal way to do this is
by calling `display-buffer', then running `temp-buffer-show-hook'.
However, if `temp-buffer-show-function' is non-nil, it calls that
function instead (and does not run `temp-buffer-show-hook'). The
function gets one argument, the buffer to display.
The return value of `with-output-to-temp-buffer' is the value of the
last form in BODY. If BODY does not finish normally, the buffer
BUFNAME is not displayed.
This runs the hook `temp-buffer-setup-hook' before BODY,
with the buffer BUFNAME temporarily current. It runs the hook
`temp-buffer-show-hook' after displaying buffer BUFNAME, with that
buffer temporarily current, and the window that was used to display it
temporarily selected. But it doesn't run `temp-buffer-show-hook'
if it uses `temp-buffer-show-function'."
(let ((old-dir (make-symbol "old-dir"))
(buf (make-symbol "buf")))
`(let ((,old-dir default-directory))
(with-current-buffer (get-buffer-create ,bufname)
(kill-all-local-variables)
;; FIXME: delete_all_overlays
(setq default-directory ,old-dir)
(setq buffer-read-only nil)
(setq buffer-file-name nil)
(setq buffer-undo-list t)
(let ((,buf (current-buffer)))
(let ((inhibit-read-only t)
(inhibit-modification-hooks t))
(erase-buffer)
(run-hooks 'temp-buffer-setup-hook))
(let ((standard-output ,buf))
(prog1 (progn ,@body)
(internal-temp-output-buffer-show ,buf))))))))
next prev parent reply other threads:[~2011-03-06 5:22 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <E1Ptqqn-0006fU-TE@internal.in.savannah.gnu.org>
2011-02-28 4:15 ` [Emacs-diffs] /srv/bzr/emacs/trunk r103444: * lisp/facemenu.el (list-colors-display): Use with-help-window (Bug#8048) Juanma Barranquero
2011-02-28 9:28 ` martin rudalics
2011-02-28 12:34 ` Juanma Barranquero
2011-02-28 14:57 ` Stefan Monnier
2011-02-28 17:10 ` martin rudalics
2011-02-28 18:39 ` Chong Yidong
2011-02-28 19:43 ` Eli Zaretskii
2011-02-28 19:58 ` Chong Yidong
2011-02-28 20:53 ` Johan Bockgård
2011-03-01 3:40 ` Chong Yidong
2011-03-01 4:53 ` Stefan Monnier
2011-03-01 18:51 ` Eli Zaretskii
2011-03-02 8:09 ` martin rudalics
2011-03-02 18:43 ` Eli Zaretskii
2011-03-02 19:56 ` martin rudalics
2011-03-04 17:49 ` Tom Tromey
2011-03-05 12:00 ` martin rudalics
2011-03-02 17:03 ` Stefan Monnier
2011-03-02 18:51 ` Eli Zaretskii
2011-03-01 21:43 ` Chong Yidong
2011-03-01 9:47 ` martin rudalics
2011-03-01 15:23 ` Drew Adams
2011-03-01 17:43 ` martin rudalics
2011-03-01 19:00 ` Eli Zaretskii
2011-03-01 21:42 ` Chong Yidong
2011-03-01 22:19 ` Eli Zaretskii
2011-03-02 8:09 ` martin rudalics
2011-03-02 0:13 ` Juanma Barranquero
2011-03-02 8:09 ` martin rudalics
2011-03-02 8:09 ` martin rudalics
2011-02-28 20:57 ` Eli Zaretskii
2011-03-05 12:00 ` martin rudalics
2011-03-06 5:22 ` Stefan Monnier [this message]
2011-03-06 9:13 ` martin rudalics
2011-03-06 19:44 ` Stefan Monnier
2011-03-07 10:16 ` martin rudalics
2011-03-07 16:38 ` Stefan Monnier
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=jwvk4gcsu2k.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=cyd@stupidchicken.com \
--cc=emacs-devel@gnu.org \
--cc=lekktu@gmail.com \
--cc=rudalics@gmx.at \
/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.