unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Joost Kremers <joostkremers@fastmail.fm>
Cc: emacs-devel@gnu.org
Subject: Re: Better handling of window margins
Date: Wed, 02 Dec 2015 15:41:09 +0200	[thread overview]
Message-ID: <83k2oxj7d6.fsf@gnu.org> (raw)
In-Reply-To: <87mvttsvsj.fsf@fastmail.fm>

> From: Joost Kremers <joostkremers@fastmail.fm>
> Date: Tue, 01 Dec 2015 22:28:44 +0100

I think we should consider the 2 issues separately:

 . how can multiple features each display its own stuff in the margins
   without breaking other such features

 . how to split windows that have margins

For the first issue, IMO it isn't enough to specify just one value,
the required margin width.  You need also to specify the width of the
stuff, if any, that is displayed in the margin.  (This will have to be
specified in pixels, because you can display images and pixel-granular
stretches of white space in the margins.)  For example, linum-mode
will specify a margin width of N columns, and display width of the
same N columns in pixels.  By contrast, modes such as writeroom-mode
will specify a margin width of M columns and display width of zero.

So we need to maintain, for each of the 2 margins, a list of elements
of the form:

   (SYMBOL MARGIN-WIDTH DISPLAY-WIDTH)

where SYMBOL is a unique symbol used to identify the request that came
from a specific feature/mode.  We should provide a function to return
this list, or maybe make it the value of a local public variable.  We
should also have a way for a feature to update its request.

Given such a list of requests, we compute the required margin width
using the following simple algorithm:

 . compute maximum of all MARGIN-WIDTH values
 . compute the sum of all DISPLAY-WIDTH values
 . take the maximum of the above two

(I omitted the translation from columns to pixels and back that will
be needed here.)

This solves a large portion of the interference issue, but it still
leaves at least one aspect unsolved: what if some feature wants to
limit the margin width from above?  For example, I presume that
writeroom-mode and its ilk would like to do that, because they want to
keep the text area at some constant width.  But if the width
calculated as above is greater than that, the text area will have no
alternative but to shrink.  Is that acceptable?  Or should we refuse
the request that causes this?  (In the latter case, we will have to
ask each feature to supply one more parameter with its request.)

Now regarding the split-window issue.  I believe we shouldn't try to
second-guess how to split windows in these cases.  Instead, we should
place the burden of doing TRT on the modes.  Specifically:

 . for splitting the window with "C-x 2" and "C-x 3", the mode could
   simply invoke the correct splitting function itself

 . for splitting the window as result of some command calling
   display-buffer, we could expect the modes to customize the
   display-buffer-* variables to control how the window is split (if
   there are currently no features/variables to that effect, we should
   add them)

The reason I don't believe in some general-purpose heuristics in this
case is that there's any number of possible needs of modes wrt
margins.  You are trying to classify these into "static" and
"dynamic", but the "dynamic" kind can be something very different from
what writeroom-mode and its ilk need in this regard.  So the
heuristics will fail when we have a mode whose margins are not
"static", but not like writeroom-mode, either.

Does this make sense?



  parent reply	other threads:[~2015-12-02 13:41 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-01 21:28 Better handling of window margins Joost Kremers
2015-12-02  8:23 ` martin rudalics
2015-12-02 13:41 ` Eli Zaretskii [this message]
2015-12-02 17:43   ` martin rudalics
2015-12-02 17:53     ` Eli Zaretskii
2015-12-02 18:11       ` martin rudalics
2015-12-03  6:49         ` Eli Zaretskii
2015-12-03 18:16           ` martin rudalics
2015-12-03 20:09             ` Eli Zaretskii
2015-12-03 20:43               ` Stefan Monnier
2015-12-04  8:14                 ` Eli Zaretskii
2015-12-04 13:22                   ` Stefan Monnier
2015-12-04 14:46                     ` Eli Zaretskii
2015-12-04 17:30                       ` Stefan Monnier
2015-12-04 18:45                         ` Eli Zaretskii
2015-12-04 20:55                           ` Stefan Monnier
2015-12-04 21:13                             ` Eli Zaretskii
2015-12-04 21:33                               ` Stefan Monnier
2015-12-05  7:56                                 ` Eli Zaretskii
2015-12-05 15:17                                   ` Stefan Monnier
2015-12-05 15:49                                     ` Eli Zaretskii
2015-12-06  4:27                                       ` Stefan Monnier
2015-12-06  5:02                                         ` John Wiegley
2015-12-06 16:10                                           ` Eli Zaretskii
2015-12-06 20:24                                             ` Yuri Khan
2015-12-07  3:32                                               ` Eli Zaretskii
2015-12-07 10:35                                                 ` Yuri Khan
2015-12-07 16:39                                                   ` Eli Zaretskii
2015-12-07  0:29                                             ` John Wiegley
2015-12-07 16:24                                               ` Eli Zaretskii
2015-12-07 17:35                                                 ` John Wiegley
2015-12-07 17:38                                                   ` Achim Gratz
2015-12-07 17:41                                                     ` John Wiegley
2015-12-07 17:50                                                       ` Achim Gratz
2015-12-07 17:36                                                 ` Stefan Monnier
2015-12-07 17:39                                                   ` John Wiegley
2015-12-07 18:42                                                     ` Stefan Monnier
2015-12-07 19:14                                                       ` John Wiegley
2015-12-04  8:07               ` martin rudalics
2015-12-04  9:42                 ` Eli Zaretskii
2015-12-04 10:21                   ` martin rudalics
2015-12-04 15:34                     ` Eli Zaretskii
2015-12-04 16:56                       ` martin rudalics
2015-12-04 18:34                         ` Eli Zaretskii
2015-12-04 19:23                           ` martin rudalics
2015-12-02 19:52       ` Joost Kremers
2015-12-03  7:17         ` Eli Zaretskii
2015-12-02 19:55   ` Joost Kremers
2015-12-03  7:21     ` Eli Zaretskii
2015-12-04 12:49 ` John Wiegley

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=83k2oxj7d6.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=joostkremers@fastmail.fm \
    /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).