unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Ivan Shmakov <ivan@siamics.net>
To: 19661@debbugs.gnu.org
Subject: bug#19661: wrapping before window-width (new wrap-column text property?)
Date: Fri, 23 Jan 2015 19:45:31 +0000	[thread overview]
Message-ID: <87wq4dmgbo.fsf_-_@violet.siamics.net> (raw)
In-Reply-To: <8361bxtr33.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 23 Jan 2015 18:11:12 +0200")

>>>>> Eli Zaretskii <eliz@gnu.org> writes:

 >> From: Ivan Shmakov  Date: Fri, 23 Jan 2015 13:17:08 +0000

 >> Please provide support for window-width-independent wrapping in the
 >> Emacs display engine; possibly by the means of a new wrap-column
 >> text property (and still perhaps complemented by a eponymous
 >> buffer-local variable), treated similarly to the likes of
 >> wrap-prefix.

	… Or that could rather be wrap-width, given that Emacs supports
	pixelwise resize now (not to mention variable-width fonts, etc…)

 >> This feature could be used to display format=flowed (RFC 3676) MIME
 >> parts, as well as enriched-mode documents, documents using MediaWiki
 >> markup, SHR-rendered HTML documents, and pretty much any other kind
 >> of text which allows for /both/ wrappable and preformatted parts at
 >> the same time.

 > format=flowed etc. is already supported by word-wrap, isn't it?

	Not in its entirety; consider, e. g. (section 4.1 of RFC 3676):

   If the line ends in a space, the line is flowed.  Otherwise it is
   fixed.  The exception to this rule is a signature separator line,
   described in Section 4.3.  Such lines end in a space but are neither
   flowed nor fixed.

	I know of no way to make the Emacs display engine wrap one line
	but not the other in the very same buffer.

 >> I admit that I know very little of the current Emacs display
 >> implementation.

 > How about biting the bullet and trying to do this yourself?  I can
 > provide guidance and advice, if needed.

	I guess I can, but most probably /not/ in the next few months.

	(The biggest problem for me would be the change of the tools and
	the workflow.  Say, nothing like eval-defun is going to be
	available while working on the C code.  Also, I’m not really
	keen when it comes to non-tty Emacs frames, – never felt those
	as of being of much value for my tasks.)

[…]

 > The fundamental problem here is that the Emacs display engine is
 > based on an "iterator" object that basically walks a buffer and
 > generates "glyph" objects that are then given to the display back-end
 > for actual display.  The iterator object has only a very myopic view
 > of the text it walks through.  Before Emacs 24, that view was
 > one-character long -- we only looked at the next character in the
 > logical order.  With Emacs 24's bidirectional display, the field of
 > view became slightly wider, but it is still limited to a single
 > physical line, and most of the display doesn't even know about that,
 > the single exception being bidi.c.

	“Physical” as in “display” or “buffer”?

 > With your suggestion, once the width of the laid out glyphs reaches
 > some pixel value, the next display element will need to come from a
 > different part of the buffer.  But how to know where in the buffer is
 > that?  You cannot know that until you are done with layout of the
 > entire visible portion of the left-side pane, the one that in the
 > above example ends with "set to 23."

 > So either we need a deep surgery of display_line, so that it acquires
 > the ability to produce layout of each screen line in several parts,
 > or we write some tricky code that would perform all the necessary
 > calculations to find the buffer position of "This yet another
 > example" when we are done producing "This is an example" and want to
 > continue with the same screen line.

	Basically, yes, I thought about the display engine keeping track
	of the latest “wasted” rectangular chunk of screen space, and
	allowing for it to be occupied by the text coming later in the
	“buffer” order.  (Or perhaps up to two such chunks: one to the
	right and one to the left of the text being drawn.)

	IIUC, display_line would potentially have to be called several
	times to draw a single display line.

	And all this behavior only triggered when the text being drawn
	has some specific property; once the property value changes, —
	the state is reset.

 > The former alternative means significant changes all over the display
 > engine, the latter means redisplay will be slower (not sure by how
 > much).  So both are highly non-trivial.

	ACK; thanks for the detailed explanation.

 >> As already imagined in the preceding discussion, forward- and
 >> backward-char commands would then still follow the logical order of
 >> text in the buffer (that is: the “23” sentence, then the “25” one),
 >> while left-char, etc. would follow the visual order (assuming
 >> visual-order-cursor-movement.)

 > That's the least of our trouble: the function that finds the place to
 > put the cursor (set_cursor_from_row) already thoroughly analyzes the
 > window display, and in Emacs 24 was rewritten to make it independent
 > of many assumptions that were broken by bidirectional display.

 > Perhaps you think that Emacs moves cursor visually, in which case it
 > would have had problems when the logical flow of text is broken like
 > that.  But that's not what Emacs does to move cursor: it moves point,
 > updates the display, and then figures out where in the new display to
 > put the cursor.

	That was a pure UI consideration.  (And not even one I’ve
	personally thought of.)

-- 
FSF associate member #7257  http://boycottsystemd.org/  … 3013 B6A0 230E 334A





  parent reply	other threads:[~2015-01-23 19:45 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAP1yDHYm2uJ1fnObdN3F4X44w+9nVxHCaFULH9bM-M8Dz207Mw@mail.gmail.com>
     [not found] ` <87ioh4nf8k.fsf@ferrier.me.uk>
     [not found]   ` <83y4pzptpx.fsf@gnu.org>
     [not found]     ` <871tnr1gqo.fsf@ferrier.me.uk>
     [not found]       ` <83bnmvowdb.fsf@gnu.org>
     [not found]         ` <jwvppbab8xb.fsf-monnier+emacs@gnu.org>
     [not found]           ` <83ppbanqhe.fsf@gnu.org>
     [not found]             ` <87vbl2xigp.fsf@ferrier.me.uk>
     [not found]               ` <83ioh2nlow.fsf@gnu.org>
     [not found]                 ` <87sig6xech.fsf@ferrier.me.uk>
     [not found]                   ` <83fvc5ni0u.fsf@gnu.org>
     [not found]                     ` <E1Y4AVO-00035n-PI@fencepost.gnu.org>
     [not found]                       ` <87k31fwwyv.fsf@ferrier.me.uk>
     [not found]                         ` <E1Y4Snj-0004wy-PF@fencepost.gnu.org>
     [not found]                           ` <87bnmq9ibf.fsf@ferrier.me.uk>
     [not found]                             ` <E1Y50Fd-0003BE-GC@fencepost.gnu.org>
     [not found]                               ` <jwv3880fumd.fsf-monnier+emacs@gnu.org>
     [not found]                                 ` <87lhlrx5fc.fsf@building.gnus.org>
     [not found]                                   ` <jwvfvbzh54s.fsf-monnier+emacs@gnu.org>
     [not found]                                     ` <878uhrcr5l.fsf@building.gnus.org>
     [not found]                                       ` <83sifzjflk.fsf@gnu.org>
2014-12-29  7:55                                         ` bug#19462: shr: use wrap-prefix when possible, instead of filling the text Ivan Shmakov
     [not found]                                         ` <87egric2ki.fsf_-_@violet.siamics.net>
2014-12-29  9:55                                           ` Ivan Shmakov
     [not found]                                           ` <jwvtx0eee66.fsf-monnier+emacs@gnu.org>
     [not found]                                             ` <877fxaa49w.fsf@violet.siamics.net>
     [not found]                                               ` <831tnicji7.fsf@gnu.org>
     [not found]                                                 ` <jwviogtdei4.fsf-monnier+emacs@gnu.org>
     [not found]                                                   ` <83y4pp9dku.fsf@gnu.org>
     [not found]                                                     ` <87387w8r2j.fsf@violet.siamics.net>
2015-01-23 13:17                                                       ` bug#19661: wrapping before window-width (new wrap-column text property?) Ivan Shmakov
2015-01-23 16:11                                                         ` Eli Zaretskii
2015-01-23 16:55                                                           ` martin rudalics
2015-01-23 19:11                                                             ` Ivan Shmakov
2015-01-24  9:08                                                               ` martin rudalics
2015-01-23 20:22                                                             ` Eli Zaretskii
2015-01-24  9:08                                                               ` martin rudalics
2015-01-24  9:47                                                                 ` Eli Zaretskii
2015-01-25 10:38                                                                   ` martin rudalics
2015-01-25 15:50                                                                     ` Eli Zaretskii
2015-01-25 17:46                                                                       ` martin rudalics
2015-01-25 18:00                                                                         ` Eli Zaretskii
2015-01-23 19:45                                                           ` Ivan Shmakov [this message]
2015-01-23 21:17                                                             ` Eli Zaretskii
2015-01-27 22:47                                                               ` Ivan Shmakov
2015-12-25 17:34                                           ` bug#19462: shr: use wrap-prefix when possible, instead of filling the text Lars Ingebrigtsen
2015-12-26  9:13                                             ` Ivan Shmakov
     [not found]                                           ` <87bn9ezb2h.fsf@gnus.org>
     [not found]                                             ` <567D8E43.8030408@gmail.com>
     [not found]                                               ` <87y4ciwe6g.fsf@gnus.org>
     [not found]                                                 ` <567DC781.8040306@gmail.com>
2015-12-25 22:51                                                   ` Lars Ingebrigtsen
2015-12-26 16:53                                                     ` Clément Pit--Claudel
2015-12-27  3:36                                                       ` Clément Pit--Claudel
2015-12-27  4:19                                                         ` Clément Pit--Claudel
2015-12-27  6:22                                                           ` Lars Ingebrigtsen
2015-12-27 11:16                                                             ` Clément Pit--Claudel
2015-12-27  6:19                                                         ` Lars Ingebrigtsen

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=87wq4dmgbo.fsf_-_@violet.siamics.net \
    --to=ivan@siamics.net \
    --cc=19661@debbugs.gnu.org \
    /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).