* Setting mode to a temporary buffer
@ 2022-08-25 6:30 uzibalqa
2022-08-25 9:28 ` Jean Louis
2022-08-25 13:35 ` Stefan Monnier via Users list for the GNU Emacs text editor
0 siblings, 2 replies; 4+ messages in thread
From: uzibalqa @ 2022-08-25 6:30 UTC (permalink / raw)
To: uzibalqa via Users list for the GNU Emacs text editor
I am using the following function to write a message to a temporary buffer. To set the mode
of the buffer I call (with-current-buffer bfname (org-mode)). Another alternative is to
add (org-mode) after (pop-to-buffer bfname).
switch-to-buffer uses pop-to-buffer under the hood. What is the way to do this? Use
(pop-to-buffer bfname) followed by (org-mode)?
(defun galaxy-help-show (bfname msg)
"Makes temporary buffer BFNAME and prints message MSG."
(when (stringp msg)
(with-output-to-temp-buffer bfname
(princ msg))
(with-current-buffer bfname (org-mode))
(pop-to-buffer bfname)))
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Setting mode to a temporary buffer
2022-08-25 6:30 Setting mode to a temporary buffer uzibalqa
@ 2022-08-25 9:28 ` Jean Louis
2022-08-25 10:43 ` uzibalqa
2022-08-25 13:35 ` Stefan Monnier via Users list for the GNU Emacs text editor
1 sibling, 1 reply; 4+ messages in thread
From: Jean Louis @ 2022-08-25 9:28 UTC (permalink / raw)
To: uzibalqa; +Cc: uzibalqa via Users list for the GNU Emacs text editor
* uzibalqa <uzibalqa@proton.me> [2022-08-25 09:33]:
>
> I am using the following function to write a message to a temporary buffer. To set the mode
> of the buffer I call (with-current-buffer bfname (org-mode)). Another alternative is to
> add (org-mode) after (pop-to-buffer bfname).
>
> switch-to-buffer uses pop-to-buffer under the hood. What is the way to do this? Use
> (pop-to-buffer bfname) followed by (org-mode)?
If it works, why not? Does it work?
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Setting mode to a temporary buffer
2022-08-25 9:28 ` Jean Louis
@ 2022-08-25 10:43 ` uzibalqa
0 siblings, 0 replies; 4+ messages in thread
From: uzibalqa @ 2022-08-25 10:43 UTC (permalink / raw)
To: Jean Louis; +Cc: uzibalqa via Users list for the GNU Emacs text editor
------- Original Message -------
On Thursday, August 25th, 2022 at 9:28 AM, Jean Louis <bugs@gnu.support> wrote:
> * uzibalqa uzibalqa@proton.me [2022-08-25 09:33]:
>
> > I am using the following function to write a message to a temporary buffer. To set the mode
> > of the buffer I call (with-current-buffer bfname (org-mode)). Another alternative is to
> > add (org-mode) after (pop-to-buffer bfname).
> >
> > switch-to-buffer uses pop-to-buffer under the hood. What is the way to do this? Use
> > (pop-to-buffer bfname) followed by (org-mode)?
>
>
> If it works, why not? Does it work?
>
> --
> Jean
Works both ways. But, if a function ultimately uses another one, it would be better
to use the one that is ultimately used. Avoids debugging complexity.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Setting mode to a temporary buffer
2022-08-25 6:30 Setting mode to a temporary buffer uzibalqa
2022-08-25 9:28 ` Jean Louis
@ 2022-08-25 13:35 ` Stefan Monnier via Users list for the GNU Emacs text editor
1 sibling, 0 replies; 4+ messages in thread
From: Stefan Monnier via Users list for the GNU Emacs text editor @ 2022-08-25 13:35 UTC (permalink / raw)
To: help-gnu-emacs
> (with-current-buffer bfname (org-mode))
> (pop-to-buffer bfname)))
`pop-to-buffer` and its friends obey `display-buffer-alist` which can
specify different behaviors depending on the buffer's state such as its
contents and its major mode.
So it's much better to set the major mode before calling `pop-to-buffer`
(like you've done above) than the reverse.
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-08-25 13:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-25 6:30 Setting mode to a temporary buffer uzibalqa
2022-08-25 9:28 ` Jean Louis
2022-08-25 10:43 ` uzibalqa
2022-08-25 13:35 ` Stefan Monnier via Users list for the GNU Emacs text editor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).