* Scratch buffer on either side of current buffer
@ 2020-11-21 1:41 Christopher Dimech
2020-11-21 5:02 ` Jamie Beardslee
0 siblings, 1 reply; 9+ messages in thread
From: Christopher Dimech @ 2020-11-21 1:41 UTC (permalink / raw)
To: Help Gnu Emacs
I want to have a window-buffer (containing *scratch*) on each side of my current buffer.
All by pressing one key.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Scratch buffer on either side of current buffer
2020-11-21 1:41 Scratch buffer on either side of current buffer Christopher Dimech
@ 2020-11-21 5:02 ` Jamie Beardslee
2020-11-21 14:09 ` Christopher Dimech
0 siblings, 1 reply; 9+ messages in thread
From: Jamie Beardslee @ 2020-11-21 5:02 UTC (permalink / raw)
To: help-gnu-emacs
Christopher Dimech <dimech@gmx.com> writes:
> I want to have a window-buffer (containing *scratch*) on each side of
> my current buffer.
Here, try this:
(defun weird-window-configuration-please (&optional width)
"Split the frame into three windows.
The current buffer is placed in the middle, and the \"*scratch\"
buffer is placed on either side, with WIDTH columns. WIDTH is 80
by default, and can be specified by a prefix argument (C-u)."
(interactive (list (when current-prefix-arg
(prefix-numeric-value current-prefix-arg))))
(let ((buffer (current-buffer))
(scratch (get-buffer-create "*scratch*"))
(width (or width 80)))
(delete-other-windows)
(with-selected-window (split-window nil (- width) 'left)
(switch-to-buffer scratch))
(with-selected-window (split-window nil width 'right)
(switch-to-buffer scratch))))
--
Jamie
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Scratch buffer on either side of current buffer
2020-11-21 5:02 ` Jamie Beardslee
@ 2020-11-21 14:09 ` Christopher Dimech
2020-11-21 14:52 ` Yuri Khan
0 siblings, 1 reply; 9+ messages in thread
From: Christopher Dimech @ 2020-11-21 14:09 UTC (permalink / raw)
To: Jamie Beardslee; +Cc: help-gnu-emacs
Have modified it like below, but is not weird enough yet.
I would like only to set the size of the two scratch buffers to
be small by default (e.ge size 8), and my working buffer to stay
in as my working buffer and take the remaining space in the middle
of the screen.
(defun gungadin-buffer (&optional width)
(interactive
(list (when current-prefix-arg
(prefix-numeric-value current-prefix-arg))) )
(let ((buffer (current-buffer))
;; ----- body of let -----
(scratch (get-buffer-create "*scratch*"))
(width (or width 8)))
(delete-other-windows)
(with-selected-window
(split-window nil (- width) 'left)
(switch-to-buffer scratch))
(with-selected-window
(split-window nil width 'right)
(switch-to-buffer scratch)) ))
> Sent: Saturday, November 21, 2020 at 6:02 AM
> From: "Jamie Beardslee" <jdb@jamzattack.xyz>
> To: help-gnu-emacs@gnu.org
> Subject: Re: Scratch buffer on either side of current buffer
>
> Christopher Dimech <dimech@gmx.com> writes:
>
> > I want to have a window-buffer (containing *scratch*) on each side of
> > my current buffer.
>
> Here, try this:
>
> (defun weird-window-configuration-please (&optional width)
> "Split the frame into three windows.
> The current buffer is placed in the middle, and the \"*scratch\"
> buffer is placed on either side, with WIDTH columns. WIDTH is 80
> by default, and can be specified by a prefix argument (C-u)."
> (interactive (list (when current-prefix-arg
> (prefix-numeric-value current-prefix-arg))))
> (let ((buffer (current-buffer))
> (scratch (get-buffer-create "*scratch*"))
> (width (or width 80)))
> (delete-other-windows)
> (with-selected-window (split-window nil (- width) 'left)
> (switch-to-buffer scratch))
> (with-selected-window (split-window nil width 'right)
> (switch-to-buffer scratch))))
>
> --
> Jamie
>
>
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Scratch buffer on either side of current buffer
2020-11-21 14:09 ` Christopher Dimech
@ 2020-11-21 14:52 ` Yuri Khan
2020-11-21 15:43 ` Christopher Dimech
0 siblings, 1 reply; 9+ messages in thread
From: Yuri Khan @ 2020-11-21 14:52 UTC (permalink / raw)
To: Christopher Dimech; +Cc: help-gnu-emacs, Jamie Beardslee
On Sat, 21 Nov 2020 at 21:09, Christopher Dimech <dimech@gmx.com> wrote:
> I would like only to set the size of the two scratch buffers to
> be small by default (e.ge size 8), and my working buffer to stay
> in as my working buffer and take the remaining space in the middle
> of the screen.
You’re sure you want what you asked for, and not something like
(set-window-margins nil 8 8)?
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Scratch buffer on either side of current buffer
2020-11-21 14:52 ` Yuri Khan
@ 2020-11-21 15:43 ` Christopher Dimech
2020-11-21 16:03 ` Yuri Khan
0 siblings, 1 reply; 9+ messages in thread
From: Christopher Dimech @ 2020-11-21 15:43 UTC (permalink / raw)
To: Yuri Khan; +Cc: help-gnu-emacs, Jamie Beardslee
> Sent: Saturday, November 21, 2020 at 3:52 PM
> From: "Yuri Khan" <yuri.v.khan@gmail.com>
> To: "Christopher Dimech" <dimech@gmx.com>
> Cc: "help-gnu-emacs" <help-gnu-emacs@gnu.org>, "Jamie Beardslee" <jdb@jamzattack.xyz>
> Subject: Re: Scratch buffer on either side of current buffer
>
> On Sat, 21 Nov 2020 at 21:09, Christopher Dimech <dimech@gmx.com> wrote:
>
> > I would like only to set the size of the two scratch buffers to
> > be small by default (e.ge size 8), and my working buffer to stay
> > in as my working buffer and take the remaining space in the middle
> > of the screen.
>
> You’re sure you want what you asked for, and not something like
> (set-window-margins nil 8 8)?
That was my hack. The plan was that the result would be your one
liner. Astonishing!
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Scratch buffer on either side of current buffer
2020-11-21 15:43 ` Christopher Dimech
@ 2020-11-21 16:03 ` Yuri Khan
2020-11-21 16:12 ` Christopher Dimech
2020-11-21 19:50 ` Drew Adams
0 siblings, 2 replies; 9+ messages in thread
From: Yuri Khan @ 2020-11-21 16:03 UTC (permalink / raw)
To: Christopher Dimech; +Cc: help-gnu-emacs, Jamie Beardslee
On Sat, 21 Nov 2020 at 22:43, Christopher Dimech <dimech@gmx.com> wrote:
> > > I would like only to set the size of the two scratch buffers to
> > > be small by default (e.ge size 8), and my working buffer to stay
> > > in as my working buffer and take the remaining space in the middle
> > > of the screen.
> >
> > You’re sure you want what you asked for, and not something like
> > (set-window-margins nil 8 8)?
>
> That was my hack. The plan was that the result would be your one
> liner. Astonishing!
My point is that you should ask for the thing you need or want, not
for the approach that first comes into your head. Inferring the want
from the ask is not always easy.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Scratch buffer on either side of current buffer
2020-11-21 16:03 ` Yuri Khan
@ 2020-11-21 16:12 ` Christopher Dimech
2020-11-21 16:43 ` Christopher Dimech
2020-11-21 19:50 ` Drew Adams
1 sibling, 1 reply; 9+ messages in thread
From: Christopher Dimech @ 2020-11-21 16:12 UTC (permalink / raw)
To: Yuri Khan; +Cc: help-gnu-emacs, Jamie Beardslee
> Sent: Saturday, November 21, 2020 at 5:03 PM
> From: "Yuri Khan" <yuri.v.khan@gmail.com>
> To: "Christopher Dimech" <dimech@gmx.com>
> Cc: "help-gnu-emacs" <help-gnu-emacs@gnu.org>, "Jamie Beardslee" <jdb@jamzattack.xyz>
> Subject: Re: Scratch buffer on either side of current buffer
>
> On Sat, 21 Nov 2020 at 22:43, Christopher Dimech <dimech@gmx.com> wrote:
>
> > > > I would like only to set the size of the two scratch buffers to
> > > > be small by default (e.ge size 8), and my working buffer to stay
> > > > in as my working buffer and take the remaining space in the middle
> > > > of the screen.
> > >
> > > You’re sure you want what you asked for, and not something like
> > > (set-window-margins nil 8 8)?
> >
> > That was my hack. The plan was that the result would be your one
> > liner. Astonishing!
>
> My point is that you should ask for the thing you need or want, not
> for the approach that first comes into your head. Inferring the want
> from the ask is not always easy.
You got that right! Ok, so now I have got the new code below.
How can I set a default for optional WIDTH?
(defun abuffer (&optional width)
"Accomodates window margins with WIDTH columns.
WIDTH is 5 by default, and can be set using the Universal Prefix
Argument \"C-u N M-x gungadin-buffer\"."
(interactive)
(set-window-margins nil width width) )
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Scratch buffer on either side of current buffer
2020-11-21 16:12 ` Christopher Dimech
@ 2020-11-21 16:43 ` Christopher Dimech
0 siblings, 0 replies; 9+ messages in thread
From: Christopher Dimech @ 2020-11-21 16:43 UTC (permalink / raw)
To: Christopher Dimech; +Cc: help-gnu-emacs, Jamie Beardslee, Yuri Khan
For default I have done it this way
(defun abuffer (&optional width)
"Accomodates window margins with WIDTH columns.
WIDTH is 5 by default, and can be set using the Universal Prefix
Argument \"C-u N M-x abuffer\"."
(interactive)
(unless width (setq width 3)) ; Defaults width
(set-window-margins nil width width) )
> Sent: Saturday, November 21, 2020 at 5:12 PM
> From: "Christopher Dimech" <dimech@gmx.com>
> To: "Yuri Khan" <yuri.v.khan@gmail.com>
> Cc: "help-gnu-emacs" <help-gnu-emacs@gnu.org>, "Jamie Beardslee" <jdb@jamzattack.xyz>
> Subject: Re: Scratch buffer on either side of current buffer
>
>
> > Sent: Saturday, November 21, 2020 at 5:03 PM
> > From: "Yuri Khan" <yuri.v.khan@gmail.com>
> > To: "Christopher Dimech" <dimech@gmx.com>
> > Cc: "help-gnu-emacs" <help-gnu-emacs@gnu.org>, "Jamie Beardslee" <jdb@jamzattack.xyz>
> > Subject: Re: Scratch buffer on either side of current buffer
> >
> > On Sat, 21 Nov 2020 at 22:43, Christopher Dimech <dimech@gmx.com> wrote:
> >
> > > > > I would like only to set the size of the two scratch buffers to
> > > > > be small by default (e.ge size 8), and my working buffer to stay
> > > > > in as my working buffer and take the remaining space in the middle
> > > > > of the screen.
> > > >
> > > > You’re sure you want what you asked for, and not something like
> > > > (set-window-margins nil 8 8)?
> > >
> > > That was my hack. The plan was that the result would be your one
> > > liner. Astonishing!
> >
> > My point is that you should ask for the thing you need or want, not
> > for the approach that first comes into your head. Inferring the want
> > from the ask is not always easy.
>
> You got that right! Ok, so now I have got the new code below.
> How can I set a default for optional WIDTH?
>
> (defun abuffer (&optional width)
> "Accomodates window margins with WIDTH columns.
> WIDTH is 5 by default, and can be set using the Universal Prefix
> Argument \"C-u N M-x gungadin-buffer\"."
> (interactive)
> (set-window-margins nil width width) )
>
>
>
>
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: Scratch buffer on either side of current buffer
2020-11-21 16:03 ` Yuri Khan
2020-11-21 16:12 ` Christopher Dimech
@ 2020-11-21 19:50 ` Drew Adams
1 sibling, 0 replies; 9+ messages in thread
From: Drew Adams @ 2020-11-21 19:50 UTC (permalink / raw)
To: Yuri Khan, Christopher Dimech; +Cc: help-gnu-emacs, Jamie Beardslee
> > Astonishing!
>
> My point is that you should ask for the thing you need or want, not
> for the approach that first comes into your head. Inferring the want
> from the ask is not always easy.
Yup. That makes things easier for the questioner,
and easier for answerers.
https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem
And because it avoids wasted energy it often means
that you get more or better help in the future.
Just like the frustration of a moving goal post
(the ever-evolving/moving question), going X-Y
can lead to people giving up on helping the X-Yer.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2020-11-21 19:50 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-21 1:41 Scratch buffer on either side of current buffer Christopher Dimech
2020-11-21 5:02 ` Jamie Beardslee
2020-11-21 14:09 ` Christopher Dimech
2020-11-21 14:52 ` Yuri Khan
2020-11-21 15:43 ` Christopher Dimech
2020-11-21 16:03 ` Yuri Khan
2020-11-21 16:12 ` Christopher Dimech
2020-11-21 16:43 ` Christopher Dimech
2020-11-21 19:50 ` Drew Adams
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).