unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: 路客 <luke.yx.lee@gmail.com>
To: Juri Linkov <juri@linkov.net>
Cc: Emacs developers <emacs-devel@gnu.org>,
	martin rudalics <rudalics@gmx.at>
Subject: Re: [ELPA] Brief v5.90: neighboring window merge on deletion
Date: Sun, 24 Mar 2024 13:13:31 +0800	[thread overview]
Message-ID: <CAA=xLRNPk3WqwOjVAgE902OY1SFtPc5mpWGRg9iNuVScZxqeEg@mail.gmail.com> (raw)
In-Reply-To: <86il1cvp7o.fsf@mail.linkov.net>

> Please explain how this differs from the value 'pos'
> of 'delete-window-choose-selected'.

I will try, not sure if I can explain it well with pure texts.  You
will need fixed-fonts configuration to see my ASCII graphs below.

This paragraph explains how the MS-DOS Brief behaves, feel free to
skip if you already know.  In Brief, the `<F4> <arrow>' key command can
`delete and merge' the target window into your current selected window,
as long as the target window is aligned (of the same width or height
with your current selected window.  Well, I put a tolerance value of 1
character so that the target window and your selected window need only
to be `almost' the same width or height, instead of `exact match'
requirement of the original legacy MS-DOS Brief).  The target window is
chosen from your current cursor point of your selected window, to the
direction your <arrow> key points to.  So if you press `<F4> <right>',
it will try to `delete and merge' the right-side neighboring window into
your current selected window, not just deleting the right side window
and letting Emacs decide how to show the other affected windows.

Now we come to the difference between how Emacs' original `deletion'
behaves and the Brief `delete and merge' behavior.  Sometimes they are
identical.  If you use Emacs to divide your single window frame into
four parts by first vertically split the window via `C-x 3' and then
followed by two `C-x 2' in each of the just split window, you will get
a window layout like:
 _____
|_S|T_|
|__|__|

Say if we would like to delete the target upper-right window where I
marked as `T', in Emacs you need to select it and `C-x 0'.  Then the
window layout will become:
 _____
|_S|  |
|__|__|

because we split the frame vertically first so the `T' window is bound
to the right half side of the frame, regardless of the setting of the
variable `delete-window-choose-selected'.  `S' and `T' are of different
(internal) parent windows so they are not mergeable.

Now if we use Brief `<F4> <right>' command from the `S' (`S'elected)
window to delete the `T' (`T'arget) window, it will reconstruct the
windows by deleting all the windows keeping only `S', then re-split
the frame by first split horizontally the window, then reconstruct
the bottom two windows achieving the desired layout:
 _____
|_S___|
|__|__|

This reconstruction happens instantaneously so it's almost not
noticeable to users unless on slow terminals.  Sometimes in X windows
the affected window boundary might shift a little if the original layout
is complicated or is 1-character in width/height difference between
`S' and `T' (my default 1-character tolerance setting).

This also explains why the following `circular' layout is not possible
as we can't find a split line either vertically or horizontally.
 ______
|____| |
| |__|_|
|_|____|

Hope this is clarified.

On Sun, Mar 24, 2024 at 2:34 AM Juri Linkov <juri@linkov.net> wrote:
>
> > In case you are interested.  I've just released the Brief editor mode
> > v5.90 targeting the feature `merge neighboring window on deletion'.
> > This functionality merges two aligned adjacent windows regardless of how
> > Emacs currently splits the frame.  It meaning that even if two aligned
> > neighboring windows in the same frame belong to different parent
> > (internal) windows, they can almost always be merged by reconstructing
> > the window tree properly.
>
> Please explain how this differs from the value 'pos'
> of 'delete-window-choose-selected'.
>
> > This is probably not a big deal but for me this task had been postponed
> > for over 20 years due to not finding time to implement them until
> > recently.  It took me sometime early this year to figure out an
> > efficient algorithm.  It reconstructs window subtree reorganizing
> > vertical/horizontal spliter lines to achieve the desired window layout.
> > However, due to the restriction on how Emacs split windows there are
> > still layouts that can't be displayed by Emacs.  A typical such window
> > layout is:
> >  ______
> > |____| |
> > | |__|_|
> > |_|____|
> >
> > Any such structure within any sub-window of a frame cannot be displayed,
> > as far as I know (let me know if any of you know a simple way to do so).
> > But for regular daily use we don't really need this kind of window
> > layout so it won't be supported unless a simple approach is found.
> >
> > Notice that the atomic window is not yet properly handled and is
> > on-going, if you find any other window attribute not taken care of
> > properly, please be sure to let me know.



-- 
Best regards,
Luke Lee



  reply	other threads:[~2024-03-24  5:13 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-22 11:23 [ELPA] Brief v5.90: neighboring window merge on deletion 路客
2024-03-22 13:22 ` Emanuel Berg
2024-03-23 18:33 ` Juri Linkov
2024-03-24  5:13   ` 路客 [this message]
2024-03-24  9:54     ` martin rudalics
2024-03-24 15:51       ` 路客
2024-03-25  9:40         ` martin rudalics
2024-03-26  2:31           ` 路客
2024-03-26  9:57             ` martin rudalics
2024-03-26 12:51               ` Eli Zaretskii
2024-03-27  7:35                 ` martin rudalics
  -- strict thread matches above, loose matches on Subject: below --
2024-03-24  3:25 路客

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to='CAA=xLRNPk3WqwOjVAgE902OY1SFtPc5mpWGRg9iNuVScZxqeEg@mail.gmail.com' \
    --to=luke.yx.lee@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=juri@linkov.net \
    --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 public inbox

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

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).