From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Line wrap reconsidered Date: Tue, 26 May 2020 17:54:11 +0300 Message-ID: <83imgivjak.fsf@gnu.org> References: <92FF4412-04FB-4521-B6CE-52B08526E4E5@gmail.com> <878shfsq35.fsf@gnus.org> Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="55179"; mail-complaints-to="usenet@ciao.gmane.io" Cc: larsi@gnus.org, emacs-devel@gnu.org To: Yuan Fu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue May 26 16:55:00 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jdayq-000EFq-4p for ged-emacs-devel@m.gmane-mx.org; Tue, 26 May 2020 16:55:00 +0200 Original-Received: from localhost ([::1]:48272 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jdayp-00014F-70 for ged-emacs-devel@m.gmane-mx.org; Tue, 26 May 2020 10:54:59 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43180) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jdayI-0000Sh-2s for emacs-devel@gnu.org; Tue, 26 May 2020 10:54:26 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:45468) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jdayH-0005x3-Nx; Tue, 26 May 2020 10:54:25 -0400 Original-Received: from [176.228.60.248] (port=4655 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jdayH-0004Vi-54; Tue, 26 May 2020 10:54:25 -0400 In-Reply-To: (message from Yuan Fu on Mon, 25 May 2020 19:32:33 -0400) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:251452 Archived-At: > From: Yuan Fu > Date: Mon, 25 May 2020 19:32:33 -0400 > Cc: emacs-devel > > +static int char_can_wrap(struct it *it) > +{ > + Lisp_Object charpos = make_fixnum (IT_STRING_CHARPOS (*it)); > + Lisp_Object tail = Fget_text_property (charpos, Qcan_wrap, Qnil); Regardless of the bug you say you fixed in the meantime, the above is wrong: it only considers the text property on buffer text, but not on display strings and overlay strings. Those strings can also need to be wrapped on display. > + for (; CONSP (tail); tail = XCDR (tail)) > + { > + register Lisp_Object tem = XCAR (tail); > + if (EQ (Qcan_wrap, tem)) > + { > + Lisp_Object val = XCDR (tail); > + if (NILP (val)) > + { return 0; } > + else if (EQ (Qbefore_only, val)) > + { return 1; } > + else if (EQ (Qafter_only, val)) > + { return 2; } > + else if (EQ (Qt, val)) > + { return 3; } > + else > + { return 0; } > + } Why is the value of the text property a cons cell? Why not a simple symbol? > - if (IT_DISPLAYING_WHITESPACE (it)) > + /* If this character displays a whitespace or the text > + property says you can wrap after it, the next one can > + wrap. */ > + if (IT_DISPLAYING_WHITESPACE (it) || IT_CAN_WRAP_AFTER (it)) It is cleaner to define a new macro that handles both conditions, and use it instead of IT_DISPLAYING_WHITESPACE.