From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.devel Subject: Re: Line wrap reconsidered Date: Sat, 22 Aug 2020 16:58:00 -0400 Message-ID: <288C7A97-CEB2-41BE-BB1F-1C4A03088AA3@gmail.com> References: <83tux4jmup.fsf@gnu.org> <83lfigj6tt.fsf@gnu.org> <2E390DEE-47E6-418A-8FD2-27C6D69262DC@gmail.com> <83364nkdiy.fsf@gnu.org> <84D68543-FE50-497E-BF03-17668C2F8972@gmail.com> <83v9hjiw61.fsf@gnu.org> <86409EE4-8327-4260-912E-49ED44E07DA0@gmail.com> <83o8naisn9.fsf@gnu.org> <2F824AA1-7C77-4554-B24F-1FA483AAF0C6@gmail.com> <83pn7j9ldr.fsf@gnu.org> Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_9728DF32-A2F4-43DB-9A3E-8D1BD3AA9E0B" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15194"; mail-complaints-to="usenet@ciao.gmane.io" Cc: larsi@gnus.org, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Aug 22 22:58:41 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 1k9ab2-0003qr-Sb for ged-emacs-devel@m.gmane-mx.org; Sat, 22 Aug 2020 22:58:41 +0200 Original-Received: from localhost ([::1]:49148 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k9ab1-0001ja-TC for ged-emacs-devel@m.gmane-mx.org; Sat, 22 Aug 2020 16:58:39 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45124) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k9aaU-000166-GI for emacs-devel@gnu.org; Sat, 22 Aug 2020 16:58:06 -0400 Original-Received: from mail-qt1-x833.google.com ([2607:f8b0:4864:20::833]:44756) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k9aaS-0000Jd-NB; Sat, 22 Aug 2020 16:58:06 -0400 Original-Received: by mail-qt1-x833.google.com with SMTP id k20so155376qtq.11; Sat, 22 Aug 2020 13:58:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=0P0+rfPqTBes7P9YE87M07EMYBwNMkRmin6enYfNsE8=; b=r5avqnGvhv43coR/qf3KNFfNX0YrVhFUDiL4Z+hd1uVK1UKkC9qM7ZjSXSVknZeGNI sPtHuFR5Vuht8FCmdJz+Yez0zZubpBG3eXuOAqtA5DFvK14QMcfyPEoi1JBHhw13w+qU 8F1UtLsBcqYdxcDXpE0JNQ+hqUL5urSYlPn3eA3Cw3xkl83ka3w2qk5IDqO4STBsi1jj ofH1+sY2yKEwz2Z85E9Lc/q8JNGIOoO0rP3bt+GqBr2xBp/yQxyZvcofTZwMldozWtq0 43Qc+xm1wB86rmMcrrfSYr7TSTTFLYkshb5KOAMJFzKUQAyZ9JWtVMikAFWrKr5jS4V/ q2Qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=0P0+rfPqTBes7P9YE87M07EMYBwNMkRmin6enYfNsE8=; b=UjhA0PsJcifI7e2HJq637ccpI/rBNkkT3VYL8Hs6E2WnNtNAqOx0cY9bZsqkBhgT4K FNT64NVBtensx+YaPf6UaxXhopT5VC6MFGLfPuIONQ+Y+PGd7tyAieuaOKez742vheDR vgq7vXcUK5jUENA4zhga1zeMmDT4mQQQRw1ErBP42picHnJf3voYUtScRacjBfGRTXtj /13uAxXW6cF57B4d/kkvK2C5zwN44u16Niv2kqKVTjlNgYpvRZQ/mL8/tJU2kmvSFs1v +8d+JQSslg93Ms8K1Pifb7Cbh30yBSAhNCm8RFZdH0e3lCoA0pYA5ow18ZXHonf19qrI 9H1g== X-Gm-Message-State: AOAM532gYQZoLxrFb+iy4wWY7jRUah79HVf3goh+1A1GqS8rfVYeWHdu iyP6qi+5+ANbj/YIx25YSH3f7n4BpWxsUw== X-Google-Smtp-Source: ABdhPJzNaKZlILHPB9E12bMK/EtwMABAvqplh45wd+H3urGXXCF+HEirp8G5YzhOI2YK1fBxXORvPQ== X-Received: by 2002:ac8:43cf:: with SMTP id w15mr8283012qtn.55.1598129882655; Sat, 22 Aug 2020 13:58:02 -0700 (PDT) Original-Received: from ?IPv6:2601:98a:4200:9210:e485:5f89:b65b:1675? ([2601:98a:4200:9210:e485:5f89:b65b:1675]) by smtp.gmail.com with ESMTPSA id s5sm5507656qke.120.2020.08.22.13.58.01 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 22 Aug 2020 13:58:02 -0700 (PDT) In-Reply-To: <83pn7j9ldr.fsf@gnu.org> X-Mailer: Apple Mail (2.3608.120.23.2.1) Received-SPF: pass client-ip=2607:f8b0:4864:20::833; envelope-from=casouri@gmail.com; helo=mail-qt1-x833.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:254130 Archived-At: --Apple-Mail=_9728DF32-A2F4-43DB-9A3E-8D1BD3AA9E0B Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii > On Aug 22, 2020, at 3:42 AM, Eli Zaretskii wrote: >=20 >> From: Yuan Fu >> Date: Sun, 16 Aug 2020 13:31:56 -0400 >> Cc: larsi@gnus.org, >> emacs-devel@gnu.org >>=20 >> +@vindex{word-wrap-by-category} >> + By default, Emacs only breaks lines after whitespace >> +characters. That strategy produces bad results when CJK and Latin = text > ^^ > Two spaces between sentences, please (here and elsewhere, in > documentation and in comments). >=20 >> +are mixed together (because CJK characters don't use whitespace to >> +separate words). You can customize @code{word-wrap-by-category} to >> +allow Emacs to break lines after more characters. That way >> +word-wrapping for CJK-Latin text works right. >=20 > This should mention char-category-set and modify-category-entry (with > a hyperlink to the ELisp manual); otherwise users will not know how to > customize this feature to their needs. >=20 >> +static bool it_char_has_category(struct it *it, int cat) >=20 > Our style is to start the function's name at BOL, like this: >=20 > static bool > it_char_has_category(struct it *it, int cat) >=20 > Otherwise, LGTM, thanks. I fixed everything and added some words to the manual, please have a = look. If you have improvements over my phrasing for the manual, please = feel free to just modify and push. Thanks, Yuan --Apple-Mail=_9728DF32-A2F4-43DB-9A3E-8D1BD3AA9E0B Content-Disposition: attachment; filename=word-wrap.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="word-wrap.patch" Content-Transfer-Encoding: quoted-printable =46rom=20c54b8ebdcbabed7d4c8977b0e5da49cc680e390b=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20Yuan=20Fu=20=0ADate:=20Tue,=20= 26=20May=202020=2022:47:27=20-0400=0ASubject:=20[PATCH]=20Improve=20word=20= wrapping=20for=20CJK=20characters=0A=0ANote=20about=20the=20change=20= around=20line=209257=20and=2023372:=0A=0ABefore,=20the=20test=20for=20= whitespace=20checks=20for=20can_wrap_before=20and=0Acan_wrap_after=20= simutaniously.=20=20Now=20we=20separate=20these=20two=20checks,=20and=0A= the=20logic=20needs=20to=20change=20a=20little=20bit.=20=20However,=20= when=20we=20don't=20enable=0Athe=20new=20wrapping=20feature,=20= 'can_wrap_after'=20is=20equivalent=20to=0A'IT_DISPLAYING_WHITESPACE'=20= and=20'can_wrap_before'=20is=20equivalent=20to=0A= '!IT_DISPLAYING_WHITESPACE'.=20=20And=20the=20new=20logic=20is=20= equivalent=20with=20the=0Aold=20one=20in=20that=20case.=0A=0AOld=20= logic:=0A=0A=20=20=20=20if=20(whitespace)=20/*=20Which=20means=20can=20= wrap=20after=20&&=20can't=20wrap=0A=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20before.=20=20*/=0A=20=20=20=20=20=20= may_wrap=20=3D=20true;=0A=0A=20=20=20=20else=20if=20(may_wrap)=20/*=20= aka=20(!whitespace=20&&=20may_wrap)=0A=20=20=20=20=20=20(set=20wrap=20= point)=20=20*=20aka=20(can't=20wrap=20after=20&&=20can=20wrap=20before=0A= =20=20=20=20=20=20may_wrap=20=3D=20false=20=20*=20=20=20=20=20=20&&=20= may_wrap)=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20*/=0A=0ANew=20logic:=0A=0A=20=20=20=20if=20(can_wrap_after)=0A=20= =20=20=20=20=20next_may_wrap=20=3D=20true=0A=20=20=20=20else=0A=20=20=20=20= =20=20next_may_wrap=20=3D=20false;=0A=0A=20=20=20=20if=20(may_wrap=20&&=20= can_wrap_before)=0A=20=20=20=20=20=20(set=20wrap=20point)=0A=0A=20=20=20=20= /*=20Update=20may_wrap.=20=20*/=0A=20=20=20=20may_wrap=20=3D=20= next_may_wrap;=0A=0A*=20src/xdisp.c=20(it_char_has_category,=20= char_can_wrap_before,=0Achar_can_wrap_after):=20New=20functions.=0A= (move_it_in_display_line_to,=20display_line):=20Replace=0A= 'IT_DISPLAYING_WHITESPACE'=20with=20either=20'char_can_wrap_before'=20or=0A= 'char_can_wrap_after'.=0A(word-wrap-by-category):=20New=20variable.=0A*=20= doc/emacs/display.texi=20(Visual=20Line=20Mode):=20Add=20a=20paragraph=20= about=20the=0Anew=20feature.=0A*=20etc/NEWS:=20Add=20a=20news=20entry.=0A= *=20lisp/cus-start.el=20(minibuffer-prompt-properties--setter):=20Add=0A= 'word-wrap-by-category'=20as=20a=20custom=20variable.=0A---=0A=20= doc/emacs/display.texi=20|=20=2021=20+++++=0A=20etc/NEWS=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20|=20=20=206=20++=0A=20lisp/cus-start.el=20=20=20= =20=20=20|=20=20=205=20++=0A=20src/xdisp.c=20=20=20=20=20=20=20=20=20=20=20= =20|=20189=20++++++++++++++++++++++++++++++++---------=0A=204=20files=20= changed,=20183=20insertions(+),=2038=20deletions(-)=0A=0Adiff=20--git=20= a/doc/emacs/display.texi=20b/doc/emacs/display.texi=0Aindex=20= 536f4cb5da..4f982b58fc=20100644=0A---=20a/doc/emacs/display.texi=0A+++=20= b/doc/emacs/display.texi=0A@@=20-1801,6=20+1801,27=20@@=20Visual=20Line=20= Mode=0A=20would=20be=20visually=20distracting.=20=20You=20can=20change=20= this=20by=20customizing=20the=0A=20variable=20= @code{visual-line-fringe-indicators}.=0A=20=0A+@vindex=20= word-wrap-by-category=0A+@findex=20modify-category-entry=0A+@findex=20= char-category-set=0A+@findex=20category-set-mnemonics=0A+=20=20By=20= default,=20Emacs=20only=20breaks=20lines=20after=20whitespace=20= characters.=0A+That=20strategy=20produces=20bad=20results=20when=20CJK=20= and=20Latin=20text=20are=20mixed=0A+together=20(because=20CJK=20= characters=20don't=20use=20whitespace=20to=20separate=0A+words).=20=20= You=20can=20customize=20@code{word-wrap-by-category}=20to=20allow=20= Emacs=0A+to=20break=20lines=20after=20any=20character=20with=20``|''=20= category=0A+(@pxref{Categories,,,=20elisp,=20the=20Emacs=20Lisp=20= Reference=20Manual}),=20which=0A+includes=20CJK=20characters.=20=20Also,=20= if=20this=20variable=20is=20set=20using=0A+Customize,=20Emacs=20= automatically=20loads=20kinsoku.el.=20=20When=20kinsoku.el=20is=0A= +loaded,=20Emacs=20respects=20kinsoku=20rules=20when=20breaking=20lines.=20= =20That=20means=0A+characters=20with=20the=20``>''=20category=20don't=20= appear=20at=20the=20beginning=20of=20a=0A+line=20(e.g.,=20FULLWIDTH=20= COMMA),=20and=20characters=20with=20the=20``<''=20category=0A+don't=20= appear=20at=20the=20end=20of=20a=20line=20(e.g.,=20LEFT=20DOUBLE=20ANGLE=20= BRACKET).=0A+You=20can=20view=20the=20categories=20of=20a=20character=20= by=20@code{char-category-set}=0A+and=20@code{category-set-mnemonics},=20= or=20type=20@kbd{C-u=20C-x=20=3D}=20with=20point=0A+on=20the=20character=20= and=20look=20at=20the=20``category''=20section=20in=20the=20report.=0A= +You=20can=20add=20categories=20to=20a=20character=20by=20= @code{modify-category-entry}.=0A+=0A=20@node=20Display=20Custom=0A=20= @section=20Customization=20of=20Display=0A=20=0Adiff=20--git=20= a/etc/NEWS=20b/etc/NEWS=0Aindex=20e97755a454..9d95186866=20100644=0A---=20= a/etc/NEWS=0A+++=20b/etc/NEWS=0A@@=20-70,6=20+70,12=20@@=20specify=20= 'cursor-type'=20to=20be=20'(box=20.=20SIZE)',=20the=20cursor=20becomes=20= a=20hollow=0A=20box=20if=20the=20point=20is=20on=20an=20image=20larger=20= than=20'SIZE'=20pixels=20in=20any=0A=20dimension.=0A=20=0A+**=20New=20= custom=20option=20'word-wrap-by-category'.=0A+=0A+When=20word-wrap=20is=20= enabled,=20this=20option=20allows=20Emacs=20to=20break=20lines=0A+after=20= more=20characters=20(instead=20of=20just=20whitespace=20characters),=20= that=0A+means=20word-wrapping=20for=20CJK=20text=20mixed=20with=20Latin=20= text=20is=20improved.=0A+=0A=20=0C=0A=20*=20Editing=20Changes=20in=20= Emacs=2028.1=0A=20=0Adiff=20--git=20a/lisp/cus-start.el=20= b/lisp/cus-start.el=0Aindex=206632687da4..7ecb7b51be=20100644=0A---=20= a/lisp/cus-start.el=0A+++=20b/lisp/cus-start.el=0A@@=20-98,6=20+98,11=20= @@=20minibuffer-prompt-properties--setter=0A=20=09=20=20=20=20=20= (ctl-arrow=20display=20boolean)=0A=20=09=20=20=20=20=20(truncate-lines=20= display=20boolean)=0A=20=09=20=20=20=20=20(word-wrap=20display=20= boolean)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20= (word-wrap-by-category=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20= display=20boolean=20"28.1"=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20= :set=20(lambda=20(symbol=20value)=0A+=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20(set-default=20symbol=20value)=0A+=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(when=20value=20(load=20= "kinsoku.el"))))=0A=20=09=20=20=20=20=20(selective-display-ellipses=20= display=20boolean)=0A=20=09=20=20=20=20=20(indicate-empty-lines=20fringe=20= boolean)=0A=20=09=20=20=20=20=20(indicate-buffer-boundaries=0Adiff=20= --git=20a/src/xdisp.c=20b/src/xdisp.c=0Aindex=20cf15f579b5..efd41005e3=20= 100644=0A---=20a/src/xdisp.c=0A+++=20b/src/xdisp.c=0A@@=20-447,6=20= +447,7=20@@=20Copyright=20(C)=201985-1988,=201993-1995,=201997-2020=20= Free=20Software=20Foundation,=0A=20#include=20"termchar.h"=0A=20#include=20= "dispextern.h"=0A=20#include=20"character.h"=0A+#include=20"category.h"=0A= =20#include=20"buffer.h"=0A=20#include=20"charset.h"=0A=20#include=20= "indent.h"=0A@@=20-508,6=20+509,80=20@@=20#define=20= IT_DISPLAYING_WHITESPACE(it)=09=09=09=09=09\=0A=20=09=20=20=20&&=20= (*BYTE_POS_ADDR=20(IT_BYTEPOS=20(*it))=20=3D=3D=20'=20'=09=09=09\=0A=20=09= =20=20=20=20=20=20=20||=20*BYTE_POS_ADDR=20(IT_BYTEPOS=20(*it))=20=3D=3D=20= '\t'))))=0A=20=0A+/*=20These=20are=20the=20category=20sets=20we=20use.=20= =20They=20are=20defined=20by=0A+=20=20=20kinsoku.el=20and=20= chracters.el.=20=20*/=0A+#define=20NOT_AT_EOL=20'<'=0A+#define=20= NOT_AT_BOL=20'>'=0A+#define=20LINE_BREAKABLE=20'|'=0A+=0A+static=20bool=0A= +it_char_has_category(struct=20it=20*it,=20int=20cat)=0A+{=0A+=20=20int=20= ch=20=3D=200;=0A+=20=20if=20(it->what=20=3D=3D=20IT_CHARACTER)=0A+=20=20=20= =20ch=20=3D=20it->c;=0A+=20=20else=20if=20(STRINGP=20(it->string))=0A+=20= =20=20=20ch=20=3D=20SREF=20(it->string,=20IT_STRING_BYTEPOS=20(*it));=0A= +=20=20else=20if=20(it->s)=0A+=20=20=20=20ch=20=3D=20it->s[IT_BYTEPOS=20= (*it)];=0A+=20=20else=20if=20(IT_BYTEPOS=20(*it)=20<=20ZV_BYTE)=0A+=20=20= =20=20ch=20=3D=20*BYTE_POS_ADDR=20(IT_BYTEPOS=20(*it));=0A+=0A+=20=20if=20= (ch=20=3D=3D=200)=0A+=20=20=20=20return=20false;=0A+=20=20else=0A+=20=20=20= =20return=20CHAR_HAS_CATEGORY=20(ch,=20cat);=0A+}=0A+=0A+/*=20Return=20= true=20if=20the=20current=20character=20allows=20wrapping=20before=20it.=20= =20=20*/=0A+static=20bool=0A+char_can_wrap_before=20(struct=20it=20*it)=0A= +{=0A+=20=20if=20(!Vword_wrap_by_category)=0A+=20=20=20=20return=20= !IT_DISPLAYING_WHITESPACE=20(it);=0A+=0A+=20=20/*=20For=20CJK=20(LTR)=20= text=20in=20RTL=20paragraph,=20EOL=20and=20BOL=20are=20flipped.=0A+=20=20= =20=20=20Because=20in=20RTL=20paragraph,=20each=20glyph=20is=20prepended=20= to=20the=20last=0A+=20=20=20=20=20one,=20effectively=20drawing=20right=20= to=20left.=20=20*/=0A+=20=20int=20not_at_bol;=0A+=20=20if=20= (it->glyph_row=20&&=20it->glyph_row->reversed_p)=0A+=20=20=20=20= not_at_bol=20=3D=20NOT_AT_EOL;=0A+=20=20else=0A+=20=20=20=20not_at_bol=20= =3D=20NOT_AT_BOL;=0A+=20=20/*=20You=20cannot=20wrap=20before=20a=20space=20= or=20tab=20because=20that=20way=20you'll=0A+=20=20=20=20=20have=20space=20= and=20tab=20at=20the=20beginning=20of=20next=20line.=20=20*/=0A+=20=20= return=20(!IT_DISPLAYING_WHITESPACE=20(it)=0A+=09=20=20/*=20Can=20be=20= at=20BOL.=20=20*/=0A+=09=20=20&&=20!it_char_has_category=20(it,=20= not_at_bol));=0A+}=0A+=0A+/*=20Return=20true=20if=20the=20current=20= character=20allows=20wrapping=20after=20it.=20=20=20*/=0A+static=20bool=0A= +char_can_wrap_after=20(struct=20it=20*it)=0A+{=0A+=20=20if=20= (!Vword_wrap_by_category)=0A+=20=20=20=20return=20= IT_DISPLAYING_WHITESPACE=20(it);=0A+=0A+=20=20/*=20For=20CJK=20(LTR)=20= text=20in=20RTL=20paragraph,=20EOL=20and=20BOL=20are=20flipped.=0A+=20=20= =20=20=20Because=20in=20RTL=20paragraph,=20each=20glyph=20is=20prepended=20= to=20the=20last=0A+=20=20=20=20=20one,=20effectively=20drawing=20right=20= to=20left.=20=20*/=0A+=20=20int=20not_at_eol;=0A+=20=20if=20= (it->glyph_row=20&&=20it->glyph_row->reversed_p)=0A+=20=20=20=20= not_at_eol=20=3D=20NOT_AT_BOL;=0A+=20=20else=0A+=20=20=20=20not_at_eol=20= =3D=20NOT_AT_EOL;=0A+=0A+=20=20return=20(IT_DISPLAYING_WHITESPACE=20(it)=0A= +=09=20=20/*=20Can=20break=20after=20&&=20can=20be=20at=20EOL.=20=20*/=0A= +=09=20=20||=20(it_char_has_category=20(it,=20LINE_BREAKABLE)=0A+=09=20=20= =20=20=20=20&&=20!it_char_has_category=20(it,=20not_at_eol)));=0A+}=0A+=0A= +#undef=20IT_DISPLAYING_WHITESPACE=0A+#undef=20NOT_AT_EOL=0A+#undef=20= NOT_AT_BOL=0A+#undef=20LINE_BREAKABLE=0A+=0A=20/*=20If=20all=20the=20= conditions=20needed=20to=20print=20the=20fill=20column=20indicator=20are=0A= =20=20=20=20met,=20return=20the=20(nonnegative)=20column=20number,=20= else=20return=20a=20negative=0A=20=20=20=20value.=20=20*/=0A@@=20= -9185,13=20+9260,20=20@@=20#define=20IT_RESET_X_ASCENT_DESCENT(IT)=09=09=09= \=0A=20=09{=0A=20=09=20=20if=20(it->line_wrap=20=3D=3D=20WORD_WRAP=20&&=20= it->area=20=3D=3D=20TEXT_AREA)=0A=20=09=20=20=20=20{=0A-=09=20=20=20=20=20= =20if=20(IT_DISPLAYING_WHITESPACE=20(it))=0A-=09=09may_wrap=20=3D=20= true;=0A-=09=20=20=20=20=20=20else=20if=20(may_wrap)=0A+=20=20=20=20=20=20= =20=20=20=20=20=20=20=20bool=20next_may_wrap=20=3D=20may_wrap;=0A+=20=20=20= =20=20=20=20=20=20=20=20=20=20=20/*=20Can=20we=20wrap=20after=20this=20= character?=20=20*/=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20if=20= (char_can_wrap_after=20(it))=0A+=09=09next_may_wrap=20=3D=20true;=0A+=20=20= =20=20=20=20=20=20=20=20=20=20=20=20else=0A+=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20next_may_wrap=20=3D=20false;=0A+=09=20=20=20=20=20=20= /*=20Can=20we=20wrap=20here?=20*/=0A+=09=20=20=20=20=20=20if=20(may_wrap=20= &&=20char_can_wrap_before=20(it))=0A=20=09=09{=0A=20=09=09=20=20/*=20We=20= have=20reached=20a=20glyph=20that=20follows=20one=20or=20more=0A-=09=09=20= =20=20=20=20whitespace=20characters.=20=20If=20the=20position=20is=0A-=09= =09=20=20=20=20=20already=20found,=20we=20are=20done.=20=20*/=0A+=09=09=20= =20=20=20=20whitespace=20characters=20or=20a=20character=20that=20allows=0A= +=09=09=20=20=20=20=20wrapping=20after=20it.=20=20If=20this=20character=20= allows=0A+=09=09=20=20=20=20=20wrapping=20before=20it,=20save=20this=20= position=20as=20a=0A+=09=09=20=20=20=20=20wrapping=20point.=20=20*/=0A=20= =09=09=20=20if=20(atpos_it.sp=20>=3D=200)=0A=20=09=09=20=20=20=20{=0A=20=09= =09=20=20=20=20=20=20RESTORE_IT=20(it,=20&atpos_it,=20atpos_data);=0A@@=20= -9206,8=20+9288,10=20@@=20#define=20IT_RESET_X_ASCENT_DESCENT(IT)=09=09=09= \=0A=20=09=09=20=20=20=20}=0A=20=09=09=20=20/*=20Otherwise,=20we=20can=20= wrap=20here.=20=20*/=0A=20=09=09=20=20SAVE_IT=20(wrap_it,=20*it,=20= wrap_data);=0A-=09=09=20=20may_wrap=20=3D=20false;=0A+=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20next_may_wrap=20=3D=20false;=0A=20=09=09= }=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20/*=20Update=20may_wrap=20= for=20the=20next=20iteration.=20=20*/=0A+=20=20=20=20=20=20=20=20=20=20=20= =20=20=20may_wrap=20=3D=20next_may_wrap;=0A=20=09=20=20=20=20}=0A=20=09}=0A= =20=0A@@=20-9335,10=20+9419,10=20@@=20#define=20= IT_RESET_X_ASCENT_DESCENT(IT)=09=09=09\=0A=20=09=09=09=20=20=20=20{=0A=20= =09=09=09=20=20=20=20=20=20bool=20can_wrap=20=3D=20true;=0A=20=0A-=09=09=09= =20=20=20=20=20=20/*=20If=20we=20are=20at=20a=20whitespace=20character=0A= -=09=09=09=09=20that=20barely=20fits=20on=20this=20screen=20line,=0A-=09=09= =09=09=20but=20the=20next=20character=20is=20also=0A-=09=09=09=09=20= whitespace,=20we=20cannot=20wrap=20here.=20=20*/=0A+=09=09=09=20=20=20=20= =20=20/*=20If=20the=20previous=20character=20says=20we=20can=0A+=09=09=09= =09=20wrap=20after=20it,=20but=20the=20current=0A+=09=09=09=09=20= character=20says=20we=20can't=20wrap=20before=0A+=09=09=09=09=20it,=20= then=20we=20can't=20wrap=20here.=20=20*/=0A=20=09=09=09=20=20=20=20=20=20= if=20(it->line_wrap=20=3D=3D=20WORD_WRAP=0A=20=09=09=09=09=20=20&&=20= wrap_it.sp=20>=3D=200=0A=20=09=09=09=09=20=20&&=20may_wrap=0A@@=20= -9350,7=20+9434,7=20@@=20#define=20IT_RESET_X_ASCENT_DESCENT(IT)=09=09=09= \=0A=20=09=09=09=09=20=20SAVE_IT=20(tem_it,=20*it,=20tem_data);=0A=20=09=09= =09=09=20=20set_iterator_to_next=20(it,=20true);=0A=20=09=09=09=09=20=20= if=20(get_next_display_element=20(it)=0A-=09=09=09=09=20=20=20=20=20=20= &&=20IT_DISPLAYING_WHITESPACE=20(it))=0A+=09=09=09=09=20=20=20=20=20=20= &&=20!char_can_wrap_before=20(it))=0A=20=09=09=09=09=20=20=20=20can_wrap=20= =3D=20false;=0A=20=09=09=09=09=20=20RESTORE_IT=20(it,=20&tem_it,=20= tem_data);=0A=20=09=09=09=09}=0A@@=20-9429,19=20+9513,18=20@@=20#define=20= IT_RESET_X_ASCENT_DESCENT(IT)=09=09=09\=0A=20=09=09=20=20else=0A=20=09=09= =20=20=20=20IT_RESET_X_ASCENT_DESCENT=20(it);=0A=20=0A-=09=09=20=20/*=20= If=20the=20screen=20line=20ends=20with=20whitespace,=20and=20we=0A-=09=09= =20=20=20=20=20are=20under=20word-wrap,=20don't=20use=20wrap_it:=20it=20= is=20no=0A-=09=09=20=20=20=20=20longer=20relevant,=20but=20we=20won't=20= have=20an=20opportunity=0A-=09=09=20=20=20=20=20to=20update=20it,=20= since=20we=20are=20done=20with=20this=20screen=0A-=09=09=20=20=20=20=20= line.=20=20*/=0A+=09=09=20=20/*=20If=20the=20screen=20line=20ends=20with=20= whitespace=20(or=0A+=09=09=20=20=20=20=20wrap-able=20character),=20and=20= we=20are=20under=20word-wrap,=0A+=09=09=20=20=20=20=20don't=20use=20= wrap_it:=20it=20is=20no=20longer=20relevant,=20but=0A+=09=09=20=20=20=20=20= we=20won't=20have=20an=20opportunity=20to=20update=20it,=20since=0A+=09=09= =20=20=20=20=20we=20are=20done=20with=20this=20screen=20line.=20=20*/=0A=20= =09=09=20=20if=20(may_wrap=20&&=20IT_OVERFLOW_NEWLINE_INTO_FRINGE=20(it)=0A= =20=09=09=20=20=20=20=20=20/*=20If=20the=20character=20after=20the=20one=20= which=20set=20the=0A-=09=09=09=20may_wrap=20flag=20is=20also=20= whitespace,=20we=20can't=0A-=09=09=09=20wrap=20here,=20since=20the=20= screen=20line=20cannot=20be=0A-=09=09=09=20wrapped=20in=20the=20middle=20= of=20whitespace.=0A-=09=09=09=20Therefore,=20wrap_it=20_is_=20relevant=20= in=20that=0A-=09=09=09=20case.=20=20*/=0A-=09=09=20=20=20=20=20=20&&=20= !(moved_forward=20&&=20IT_DISPLAYING_WHITESPACE=20(it)))=0A+=09=09=09=20= may_wrap=20flag=20says=20we=20can't=20wrap=20before=20it,=0A+=09=09=09=20= we=20can't=20wrap=20here.=20=20Therefore,=20wrap_it=0A+=09=09=09=20= (previously=20found=20wrap-point)=20_is_=20relevant=0A+=09=09=09=20in=20= that=20case.=20=20*/=0A+=09=09=20=20=20=20=20=20&&=20!(moved_forward=20= &&=20char_can_wrap_before=20(it)))=0A=20=09=09=20=20=20=20{=0A=20=09=09=20= =20=20=20=20=20/*=20If=20we've=20found=20TO_X,=20go=20back=20there,=20as=20= we=20now=0A=20=09=09=09=20know=20the=20last=20word=20fits=20on=20this=20= screen=20line.=20=20*/=0A@@=20-23292,9=20+23375,14=20@@=20#define=20= RECORD_MAX_MIN_POS(IT)=09=09=09=09=09\=0A=20=0A=20=09=20=20if=20= (it->line_wrap=20=3D=3D=20WORD_WRAP=20&&=20it->area=20=3D=3D=20= TEXT_AREA)=0A=20=09=20=20=20=20{=0A-=09=20=20=20=20=20=20if=20= (IT_DISPLAYING_WHITESPACE=20(it))=0A-=09=09may_wrap=20=3D=20true;=0A-=09=20= =20=20=20=20=20else=20if=20(may_wrap)=0A+=20=20=20=20=20=20=20=20=20=20=20= =20=20=20bool=20next_may_wrap=20=3D=20may_wrap;=0A+=20=20=20=20=20=20=20=20= =20=20=20=20=20=20/*=20Can=20we=20wrap=20after=20this=20character?=20=20= */=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20if=20= (char_can_wrap_after=20(it))=0A+=09=09next_may_wrap=20=3D=20true;=0A+=20=20= =20=20=20=20=20=20=20=20=20=20=20=20else=0A+=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20next_may_wrap=20=3D=20false;=0A+=09=20=20=20=20=20=20= /*=20Can=20we=20wrap=20here?=20*/=0A+=09=20=20=20=20=20=20if=20(may_wrap=20= &&=20char_can_wrap_before=20(it))=0A=20=09=09{=0A=20=09=09=20=20SAVE_IT=20= (wrap_it,=20*it,=20wrap_data);=0A=20=09=09=20=20wrap_x=20=3D=20x;=0A@@=20= -23308,8=20+23396,9=20@@=20#define=20RECORD_MAX_MIN_POS(IT)=09=09=09=09=09= \=0A=20=09=09=20=20wrap_row_min_bpos=20=3D=20min_bpos;=0A=20=09=09=20=20= wrap_row_max_pos=20=3D=20max_pos;=0A=20=09=09=20=20wrap_row_max_bpos=20=3D= =20max_bpos;=0A-=09=09=20=20may_wrap=20=3D=20false;=0A=20=09=09}=0A+=09=20= =20=20=20=20=20/*=20Update=20may_wrap=20for=20the=20next=20iteration.=20=20= */=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20may_wrap=20=3D=20= next_may_wrap;=0A=20=09=20=20=20=20}=0A=20=09}=0A=20=0A@@=20-23433,14=20= +23522,18=20@@=20#define=20RECORD_MAX_MIN_POS(IT)=09=09=09=09=09\=0A=20=09= =09=09=20=20/*=20If=20line-wrap=20is=20on,=20check=20if=20a=20previous=0A= =20=09=09=09=20=20=20=20=20wrap=20point=20was=20found.=20=20*/=0A=20=09=09= =09=20=20if=20(!IT_OVERFLOW_NEWLINE_INTO_FRINGE=20(it)=0A-=09=09=09=20=20= =20=20=20=20&&=20wrap_row_used=20>=200=0A+=09=09=09=20=20=20=20=20=20&&=20= wrap_row_used=20>=200=20/*=20Found.=20=20*/=0A=20=09=09=09=20=20=20=20=20= =20/*=20Even=20if=20there=20is=20a=20previous=20wrap=0A=20=09=09=09=09=20= point,=20continue=20the=20line=20here=20as=0A=20=09=09=09=09=20usual,=20= if=20(i)=20the=20previous=20character=0A-=09=09=09=09=20was=20a=20space=20= or=20tab=20AND=20(ii)=20the=0A-=09=09=09=09=20current=20character=20is=20= not.=20=20*/=0A-=09=09=09=20=20=20=20=20=20&&=20(!may_wrap=0A-=09=09=09=09= =20=20||=20IT_DISPLAYING_WHITESPACE=20(it)))=0A+=09=09=09=09=20allows=20= wrapping=20after=20it,=20AND=20(ii)=0A+=09=09=09=09=20the=20current=20= character=20allows=20wrapping=0A+=09=09=09=09=20before=20it.=20=20= Because=20this=20is=20a=20valid=0A+=09=09=09=09=20break=20point,=20we=20= can=20just=20continue=20to=0A+=09=09=09=09=20the=20next=20line=20at=20= here,=20there=20is=20no=0A+=09=09=09=09=20need=20to=20wrap=20early=20at=20= the=20previous=0A+=09=09=09=09=20wrap=20point.=20=20*/=0A+=09=09=09=20=20= =20=20=20=20&&=20(!may_wrap=20||=20!char_can_wrap_before=20(it)))=0A=20=09= =09=09=20=20=20=20goto=20back_to_wrap;=0A=20=0A=20=09=09=09=20=20/*=20= Record=20the=20maximum=20and=20minimum=20buffer=0A@@=20-23468,13=20= +23561,16=20@@=20#define=20RECORD_MAX_MIN_POS(IT)=09=09=09=09=09\=0A=20=09= =09=09=20=20=20=20=20=20/*=20If=20line-wrap=20is=20on,=20check=20if=20a=0A= =20=09=09=09=09=20previous=20wrap=20point=20was=20found.=20=20*/=0A=20=09= =09=09=20=20=20=20=20=20else=20if=20(wrap_row_used=20>=200=0A-=09=09=09=09= =20=20=20=20=20=20=20/*=20Even=20if=20there=20is=20a=20previous=20wrap=0A= -=09=09=09=09=09=20=20point,=20continue=20the=20line=20here=20as=0A-=09=09= =09=09=09=20=20usual,=20if=20(i)=20the=20previous=20character=0A-=09=09=09= =09=09=20=20was=20a=20space=20or=20tab=20AND=20(ii)=20the=0A-=09=09=09=09= =09=20=20current=20character=20is=20not.=20=20*/=0A-=09=09=09=09=20=20=20= =20=20=20=20&&=20(!may_wrap=0A-=09=09=09=09=09=20=20=20||=20= IT_DISPLAYING_WHITESPACE=20(it)))=0A+=09=09=09=09=20=20=20=20=20=20=20/*=20= Even=20if=20there=20is=20a=20previous=0A+=09=09=09=09=09=20=20wrap=20= point,=20continue=20the=0A+=09=09=09=09=09=20=20line=20here=20as=20= usual,=20if=20(i)=0A+=09=09=09=09=09=20=20the=20previous=20character=20= was=20a=0A+=09=09=09=09=09=20=20space=20or=20tab=20AND=20(ii)=20the=0A+=09= =09=09=09=09=20=20current=20character=20is=20not,=0A+=09=09=09=09=09=20=20= AND=20(iii)=20the=20current=0A+=09=09=09=09=09=20=20character=20allows=20= wrapping=0A+=09=09=09=09=09=20=20before=20it.=20=20*/=0A+=09=09=09=09=20=20= =20=20=20=20=20&&=20(!may_wrap=20||=20!char_can_wrap_before=20(it)))=0A=20= =09=09=09=09goto=20back_to_wrap;=0A=20=0A=20=09=09=09=20=20=20=20}=0A@@=20= -34594,6=20+34690,23=20@@=20syms_of_xdisp=20(void)=0A=20If=20`word-wrap'=20= is=20enabled,=20you=20might=20want=20to=20reduce=20this.=20=20*/);=0A=20=20= =20Vtruncate_partial_width_windows=20=3D=20make_fixnum=20(50);=0A=20=0A+=20= =20DEFVAR_BOOL("word-wrap-by-category",=20Vword_wrap_by_category,=20doc:=20= /*=0A+=20=20=20=20Non-nil=20means=20also=20wrap=20after=20characters=20= of=20a=20certain=20category.=0A+Normally=20when=20`word-wrap'=20is=20on,=20= Emacs=20only=20breaks=20lines=20after=0A+whitespace=20characters.=20=20= When=20this=20option=20is=20turned=20on,=20Emacs=20also=0A+breaks=20= lines=20after=20characters=20that=20have=20the=20"|"=20category=20= (defined=20in=0A+characters.el).=20=20This=20is=20useful=20for=20= allowing=20breaking=20after=20CJK=0A+characters=20and=20improves=20the=20= word-wrapping=20for=20CJK=20text=20mixed=20with=0A+Latin=20text.=0A+=0A= +If=20this=20variable=20is=20set=20using=20Customize,=20Emacs=20= automatically=20loads=0A+kinsoku.el.=20=20When=20kinsoku.el=20is=20= loaded,=20Emacs=20respects=20kinsoku=20rules=0A+when=20breaking=20lines.=20= =20That=20means=20characters=20with=20the=20">"=20category=0A+don't=20= appear=20at=20the=20beginning=20of=20a=20line=20(e.g.,=20FULLWIDTH=20= COMMA),=20and=0A+characters=20with=20the=20"<"=20category=20don't=20= appear=20at=20the=20end=20of=20a=20line=0A+(e.g.,=20LEFT=20DOUBLE=20= ANGLE=20BRACKET).=20=20*/);=0A+=20=20Vword_wrap_by_category=20=3D=20= false;=0A+=0A=20=20=20DEFVAR_LISP=20("line-number-display-limit",=20= Vline_number_display_limit,=0A=20=20=20=20=20doc:=20/*=20Maximum=20= buffer=20size=20for=20which=20line=20number=20should=20be=20displayed.=0A= =20If=20the=20buffer=20is=20bigger=20than=20this,=20the=20line=20number=20= does=20not=20appear=0A--=20=0A2.27.0=0A=0A= --Apple-Mail=_9728DF32-A2F4-43DB-9A3E-8D1BD3AA9E0B--