From unknown Tue Jun 17 01:43:49 2025 X-Loop: help-debbugs@gnu.org Subject: bug#48148: 27.2; ox-ascii breaks TITLE line wrongly when 2 width char is used Resent-From: Shingo Tanaka Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 01 May 2021 23:53:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 48148 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 48148@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.161991314527898 (code B ref -1); Sat, 01 May 2021 23:53:02 +0000 Received: (at submit) by debbugs.gnu.org; 1 May 2021 23:52:25 +0000 Received: from localhost ([127.0.0.1]:39138 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lczPN-0007Fu-7G for submit@debbugs.gnu.org; Sat, 01 May 2021 19:52:25 -0400 Received: from lists.gnu.org ([209.51.188.17]:33894) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lczPL-0007Fo-IF for submit@debbugs.gnu.org; Sat, 01 May 2021 19:52:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58834) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lczPL-0001Ou-AJ for bug-gnu-emacs@gnu.org; Sat, 01 May 2021 19:52:23 -0400 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]:45980) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lczPH-0002Gt-Jv for bug-gnu-emacs@gnu.org; Sat, 01 May 2021 19:52:23 -0400 Received: by mail-pg1-x52c.google.com with SMTP id d10so1141849pgf.12 for ; Sat, 01 May 2021 16:52:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:from:to:subject:user-agent:mime-version; bh=hPWIBgjnTfQryIjpr/KLTYOqXCYv9wpOSGTRXBYm55w=; b=ODTOlDA19WxakEi2YtdCCkDYrFPPptSJjRa4nTAPrTvZfGVvqcHX33E8lWQI6WxGiv 8WhcLFlQEA9JfQRhPdcKwlyZycgU2JqSYrCPJXbTlN8KMUIIc6ttVtmiDvwB0VcxUoBF xDw0YiRLYzVLTMXb0LjO40iaRnGLBVmU0POASbmnescRK+3uVmQKGRBU2g+bZAyA++so akYtuTYLKZsBVPDPkCO6C6gkdL1yH/mydbU2K6T2jfCAcWq9hudNolqBHqX1uYrYhErR 3B68aZjfg7g+ymQD5xruha8IUzDOyHNbzzJZO5Gi74jFrNFs6Yk/WaDTHCjro5K9M8pB G31Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:from:to:subject:user-agent :mime-version; bh=hPWIBgjnTfQryIjpr/KLTYOqXCYv9wpOSGTRXBYm55w=; b=KNSLPifJ3IJUp3fobjXaGhZ71DtW4K7XUfH5UPLwADrsCQ/hWsqRl+rqs4MDZAFMFv x7KXv9O1LSDqTNfWHeaPOFhxhAXD3LAtTMhpTTdA2jqV9D/Y4PwFESw7sHfE68D6JX8K NHkkAXvPj9vyjzV+TGP67Kws5cDdbCy/9fUNo8TZamZ2WSEic3KthfHsgbhEk2KtDgbK McBKezGi1IkVwAUG+LG0/+UkIY+3H2YFzmCAVxyyMB7CU7HV8/4LFO4IGpmp0yCjFpQQ Xc2M5Eaik2Q2nS0CQV2Bg8oWOVZNbURslg+Jt0ZhDhrW49OrvrVIEn6KWQPa5tbShAFT Lzmw== X-Gm-Message-State: AOAM530seNTdVde1XcpxXQgNBro4L8E05rJlLbWz6bq5+gTrl/wmBEr4 6KQBDXIza05jppzv9druFR2h8zNHmTkX+w== X-Google-Smtp-Source: ABdhPJxCF1fNwThwV415Dxikm3A9xCV0fL/fR/iy12XG5Ol7hrbkWRAFExP9TwUb7S9nLfmevn4/UA== X-Received: by 2002:a63:130f:: with SMTP id i15mr11101467pgl.151.1619913137128; Sat, 01 May 2021 16:52:17 -0700 (PDT) Received: from shingo-desktop.gmail.com ([240d:1a:6f4:6b00:5514:ce7d:f5f9:375b]) by smtp.gmail.com with ESMTPSA id s13sm5296845pfd.79.2021.05.01.16.52.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 May 2021 16:52:16 -0700 (PDT) Date: Sun, 02 May 2021 08:52:13 +0900 Message-ID: <87h7jm2es2.wl-shingo.fg8@gmail.com> From: Shingo Tanaka User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?Q?Goj=C5=8D?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.2 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=ISO-2022-JP Received-SPF: pass client-ip=2607:f8b0:4864:20::52c; envelope-from=shingo.fg8@gmail.com; helo=mail-pg1-x52c.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, 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-Spam-Score: -1.1 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.1 (--) Hi, When exporting org-mode document to plain text (either ascii/unicode/utf-8) with `org-export-dispatch', Emacs translates the document title with `org-ascii-template--document-title'. However, when 2 width character is used, it detects the title line's width wrongly and breaks it even if the width is not too long. For example, when the title is "ABCDEF" (each character has width of 2), expected title would be like: ━━━━━━━━━━━━━━━ ABCDEF ━━━━━━━━━━━━━━━ However, the reality is: ━━━━━━━━━━━━━━━ ABC DEF ━━━━━━━━━━━━━━━ This is because it uses `length' to detects the width, which only returns the number of characters (6 in this case) but not the actual width displayed (12 in this case), and it tries to fill the line with that half width. `string-width' should be used instead. Here is a potential patch. --- ox-ascii.el.org 2021-03-26 09:28:44.000000000 +0900 +++ ox-ascii.el 2021-05-02 08:11:57.657347150 +0900 @@ -1033,7 +1033,7 @@ ;; Format TITLE. It may be filled if it is too wide, ;; that is wider than the two thirds of the total width. (title-len (min (apply #'max - (mapcar #'length + (mapcar #'string-width (org-split-string (concat title "\n" subtitle) "\n"))) (/ (* 2 text-width) 3))) --- Shingo Tanaka From unknown Tue Jun 17 01:43:49 2025 X-Loop: help-debbugs@gnu.org Subject: bug#48148: 27.2; ox-ascii breaks TITLE line wrongly when 2 width char is used Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: emacs-orgmode@gnu.org Resent-Date: Sun, 02 May 2021 07:05:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48148 X-GNU-PR-Package: org-mode X-GNU-PR-Keywords: To: Shingo Tanaka Cc: 48148@debbugs.gnu.org Received: via spool by 48148-submit@debbugs.gnu.org id=B48148.161993904419156 (code B ref 48148); Sun, 02 May 2021 07:05:02 +0000 Received: (at 48148) by debbugs.gnu.org; 2 May 2021 07:04:04 +0000 Received: from localhost ([127.0.0.1]:40978 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ld696-0004yu-7m for submit@debbugs.gnu.org; Sun, 02 May 2021 03:04:04 -0400 Received: from eggs.gnu.org ([209.51.188.92]:43304) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ld693-0004yJ-RN for 48148@debbugs.gnu.org; Sun, 02 May 2021 03:04:02 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:57126) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ld68y-0008F6-MW; Sun, 02 May 2021 03:03:56 -0400 Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:1554 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1ld68x-0007i3-Of; Sun, 02 May 2021 03:03:56 -0400 Date: Sun, 02 May 2021 10:03:36 +0300 Message-Id: <83bl9t8vnb.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: <87h7jm2es2.wl-shingo.fg8@gmail.com> (message from Shingo Tanaka on Sun, 02 May 2021 08:52:13 +0900) References: <87h7jm2es2.wl-shingo.fg8@gmail.com> MIME-version: 1.0 Content-type: text/plain; charset=iso-2022-jp Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Date: Sun, 02 May 2021 08:52:13 +0900 > From: Shingo Tanaka > > For example, when the title is "ABCDEF" (each character has width of > 2), expected title would be like: > > ━━━━━━━━━━━━━━━ > ABCDEF > ━━━━━━━━━━━━━━━ > > However, the reality is: > > ━━━━━━━━━━━━━━━ > ABC > DEF > ━━━━━━━━━━━━━━━ > > This is because it uses `length' to detects the width, which only returns the > number of characters (6 in this case) but not the actual width displayed (12 > in this case), and it tries to fill the line with that half width. > `string-width' should be used instead. > > Here is a potential patch. > > --- ox-ascii.el.org 2021-03-26 09:28:44.000000000 +0900 > +++ ox-ascii.el 2021-05-02 08:11:57.657347150 +0900 > @@ -1033,7 +1033,7 @@ > ;; Format TITLE. It may be filled if it is too wide, > ;; that is wider than the two thirds of the total width. > (title-len (min (apply #'max > - (mapcar #'length > + (mapcar #'string-width > (org-split-string > (concat title "\n" subtitle) "\n"))) > (/ (* 2 text-width) 3))) Thanks, but the change you propose will not work reliably on GUI frames, because the actual width of double-width characters on display is not necessarily twice the width of a "normal" character. Especially if this is done in a non-CJK locale, where the default font is likely to be different from the font used for double-width characters. The accurate method of lining up in these cases is to use window-text-pixel-size instead. That function will return the exact width of a string as it will displayed, in pixels, because it uses the same code as the display engine. From unknown Tue Jun 17 01:43:49 2025 X-Loop: help-debbugs@gnu.org Subject: bug#48148: 27.2; ox-ascii breaks TITLE line wrongly when 2 width char is used Resent-From: Nicolas Goaziou Original-Sender: "Debbugs-submit" Resent-CC: emacs-orgmode@gnu.org Resent-Date: Sun, 02 May 2021 08:24:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48148 X-GNU-PR-Package: org-mode X-GNU-PR-Keywords: To: Eli Zaretskii Cc: Shingo Tanaka , 48148@debbugs.gnu.org Received: via spool by 48148-submit@debbugs.gnu.org id=B48148.161994382423346 (code B ref 48148); Sun, 02 May 2021 08:24:02 +0000 Received: (at 48148) by debbugs.gnu.org; 2 May 2021 08:23:44 +0000 Received: from localhost ([127.0.0.1]:41430 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ld7OC-00064U-DF for submit@debbugs.gnu.org; Sun, 02 May 2021 04:23:44 -0400 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:33359) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ld7O9-00064O-B9 for 48148@debbugs.gnu.org; Sun, 02 May 2021 04:23:43 -0400 X-Originating-IP: 185.131.40.67 Received: from localhost (40-67.ipv4.commingeshautdebit.fr [185.131.40.67]) (Authenticated sender: admin@nicolasgoaziou.fr) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 18C671C0004; Sun, 2 May 2021 08:23:34 +0000 (UTC) From: Nicolas Goaziou References: <87h7jm2es2.wl-shingo.fg8@gmail.com> <83bl9t8vnb.fsf@gnu.org> Date: Sun, 02 May 2021 10:23:34 +0200 In-Reply-To: <83bl9t8vnb.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 02 May 2021 10:03:36 +0300") Message-ID: <87h7jla6ih.fsf@nicolasgoaziou.fr> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Hello, Eli Zaretskii writes: >> Date: Sun, 02 May 2021 08:52:13 +0900 >> From: Shingo Tanaka >>=20 >> For example, when the title is "=EF=BC=A1=EF=BC=A2=EF=BC=A3=EF=BC=A4=EF= =BC=A5=EF=BC=A6" (each character has width of >> 2), expected title would be like: >>=20 >> =E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94= =81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81= =E2=94=81 >> =EF=BC=A1=EF=BC=A2=EF=BC=A3=EF=BC=A4=EF=BC= =A5=EF=BC=A6 >> =E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94= =81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81= =E2=94=81 >>=20 >> However, the reality is: >>=20 >> =E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94= =81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81= =E2=94=81 >> =EF=BC=A1=EF=BC=A2=EF=BC=A3 >> =EF=BC=A4=EF=BC=A5=EF=BC=A6 >> =E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94= =81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81= =E2=94=81 >>=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 >> This is because it uses `length' to detects the width, which only return= s the >> number of characters (6 in this case) but not the actual width displayed= (12 >> in this case), and it tries to fill the line with that half width. >> `string-width' should be used instead. >>=20 >> Here is a potential patch. >>=20 >> --- ox-ascii.el.org 2021-03-26 09:28:44.000000000 +0900 >> +++ ox-ascii.el 2021-05-02 08:11:57.657347150 +0900 >> @@ -1033,7 +1033,7 @@ >> ;; Format TITLE. It may be filled if it is too wide, >> ;; that is wider than the two thirds of the total width. >> (title-len (min (apply #'max >> - (mapcar #'length >> + (mapcar #'string-width >> (org-split-string >> (concat title "\n" subtitle) "\n"))) >> (/ (* 2 text-width) 3))) > > Thanks, but the change you propose will not work reliably on GUI > frames, because the actual width of double-width characters on display > is not necessarily twice the width of a "normal" character. > Especially if this is done in a non-CJK locale, where the default font > is likely to be different from the font used for double-width > characters. > > The accurate method of lining up in these cases is to use > window-text-pixel-size instead. That function will return the exact > width of a string as it will displayed, in pixels, because it uses the > same code as the display engine. Would you mind giving an example about `window-text-pixel-size' usage in this situation? AFAIU, `window-text-pixel-size' returns the size of the window, but I fail to see how it is relevant here. Note that `text-width' in the code above is not related to the width of the window, but is a maximum number of allowed characters on a line. Thank you! Regards, --=20 Nicolas Goaziou From unknown Tue Jun 17 01:43:49 2025 X-Loop: help-debbugs@gnu.org Subject: bug#48148: 27.2; ox-ascii breaks TITLE line wrongly when 2 width char is used Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: emacs-orgmode@gnu.org Resent-Date: Sun, 02 May 2021 09:13:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48148 X-GNU-PR-Package: org-mode X-GNU-PR-Keywords: To: Nicolas Goaziou Cc: shingo.fg8@gmail.com, 48148@debbugs.gnu.org Received: via spool by 48148-submit@debbugs.gnu.org id=B48148.16199467369468 (code B ref 48148); Sun, 02 May 2021 09:13:01 +0000 Received: (at 48148) by debbugs.gnu.org; 2 May 2021 09:12:16 +0000 Received: from localhost ([127.0.0.1]:41707 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ld899-0002Se-Kt for submit@debbugs.gnu.org; Sun, 02 May 2021 05:12:15 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58418) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ld897-0002SX-Dv for 48148@debbugs.gnu.org; Sun, 02 May 2021 05:12:13 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:58296) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ld891-0008UB-AO; Sun, 02 May 2021 05:12:07 -0400 Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:1715 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1ld88v-0001a6-HH; Sun, 02 May 2021 05:12:06 -0400 Date: Sun, 02 May 2021 12:11:41 +0300 Message-Id: <8335v58ppu.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: <87h7jla6ih.fsf@nicolasgoaziou.fr> (message from Nicolas Goaziou on Sun, 02 May 2021 10:23:34 +0200) References: <87h7jm2es2.wl-shingo.fg8@gmail.com> <83bl9t8vnb.fsf@gnu.org> <87h7jla6ih.fsf@nicolasgoaziou.fr> X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Nicolas Goaziou > Cc: Shingo Tanaka , 48148@debbugs.gnu.org > Date: Sun, 02 May 2021 10:23:34 +0200 > > > The accurate method of lining up in these cases is to use > > window-text-pixel-size instead. That function will return the exact > > width of a string as it will displayed, in pixels, because it uses the > > same code as the display engine. > > Would you mind giving an example about `window-text-pixel-size' usage in > this situation? I'm not sure what kind of example is necessary. How about if you ask specific questions about the arguments of that function which you don't understand clearly how to use? > AFAIU, `window-text-pixel-size' returns the size of the window No, it returns the size of _text_ when displayed in a window. > Note that `text-width' in the code above is not related to the width > of the window, but is a maximum number of allowed characters on a > line. I didn't mean text-width, I meant the use of string-width: it should be replaced by a call to window-text-pixel-size. From unknown Tue Jun 17 01:43:49 2025 X-Loop: help-debbugs@gnu.org Subject: bug#48148: 27.2; ox-ascii breaks TITLE line wrongly when 2 width char is used Resent-From: Shingo Tanaka Original-Sender: "Debbugs-submit" Resent-CC: emacs-orgmode@gnu.org Resent-Date: Sun, 02 May 2021 11:34:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48148 X-GNU-PR-Package: org-mode X-GNU-PR-Keywords: To: Eli Zaretskii Cc: shingo.fg8@gmail.com, 48148@debbugs.gnu.org, Nicolas Goaziou Received: via spool by 48148-submit@debbugs.gnu.org id=B48148.161995521823936 (code B ref 48148); Sun, 02 May 2021 11:34:01 +0000 Received: (at 48148) by debbugs.gnu.org; 2 May 2021 11:33:38 +0000 Received: from localhost ([127.0.0.1]:42316 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ldALy-0006E0-12 for submit@debbugs.gnu.org; Sun, 02 May 2021 07:33:38 -0400 Received: from mail-pj1-f47.google.com ([209.85.216.47]:44757) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ldALt-0006Dt-FQ for 48148@debbugs.gnu.org; Sun, 02 May 2021 07:33:36 -0400 Received: by mail-pj1-f47.google.com with SMTP id m6-20020a17090a8586b02901507e1acf0fso1736594pjn.3 for <48148@debbugs.gnu.org>; Sun, 02 May 2021 04:33:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:from:to:cc:subject:in-reply-to:references :user-agent:mime-version; bh=4ApH+q2Zp2obokxxuo0jKg+l+Jo0XHaISOIIPtjMLyo=; b=vcuyVvW5x+lQThwTnJsdclsym9V1z8t/3oc35uvhp7wuXcfNISXr+mT+cDcTTXYDUD PhA4GIcxgamTlXbgo/sHg84Je0w48mvo4klmYxeBIBJVKtG2KlA6ibRHZdmkpEFiBJRx bvPLE4HdzaKfX/PqUcbZBWqNOInY8PFP4RmfRXT4S33mzQfNAPMzn/cYYu/L++hVyLBs e/Gp2U5+kLn3Iw1Zm9B5JGiO/HCcd0wMgRp6XLApk9E9VoYX/Cs5L62CUk137mnGBL1J HiINTY0JWD5IBkUDHCH819KPY1v8f9WoPqDNipaTTuAUFxsdfiFvoTY/508F+ii8rijp TQng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:from:to:cc:subject:in-reply-to :references:user-agent:mime-version; bh=4ApH+q2Zp2obokxxuo0jKg+l+Jo0XHaISOIIPtjMLyo=; b=U8JnBNgIOz23gzWtd6+H/Zz9ROt+BBpEGAY2/HKZ0zm976ksMN+MYUcfoQXtb36zRj 2nmYqsjJHtFi4YBk2XCneoPSq/Khda7cc9XSi+AwAvVIJ4bnG9XQg/nujAovOx1xb2so HXBC5b4iE/rts5mmP8woeiP9ha70vBK5uZZHGUULaiTAqD+asV1H8LEyhSslAHGvxwLx 7J6TTd4xwxl829zuybWpErVQUgfxYjLDK0FpOyF+kdouBo5yLwJ0QLdPQYHDKt0JMevx TypMEPF1hCQMbk5EiaIqxnrdcKER/I09JbZ/SzUHi29HjveqX6hyxbZGr1Y2Y717cXMR 7AKw== X-Gm-Message-State: AOAM5313DMG+S6TorsVLG4adpFTtQGfhBmzRRIjG5Oj1XzxPEViHdoCG dGZcSlM+Y291bUenMMIBBf8= X-Google-Smtp-Source: ABdhPJwcPSgn+3+LQdkplZmWvMw8wzwp1UQRFhVaEmvYUs9ge/yq2MsSOSwqWu+vjZBZFDLiZN6TPw== X-Received: by 2002:a17:902:c38b:b029:ed:442a:276e with SMTP id g11-20020a170902c38bb02900ed442a276emr15172936plg.51.1619955207686; Sun, 02 May 2021 04:33:27 -0700 (PDT) Received: from shingo-desktop.gmail.com ([240d:1a:6f4:6b00:5514:ce7d:f5f9:375b]) by smtp.gmail.com with ESMTPSA id j7sm6382731pfd.129.2021.05.02.04.33.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 May 2021 04:33:27 -0700 (PDT) Date: Sun, 02 May 2021 20:33:23 +0900 Message-ID: <87pmy9pdz0.wl-shingo.fg8@gmail.com> From: Shingo Tanaka In-Reply-To: <8335v58ppu.fsf@gnu.org> References: <87h7jm2es2.wl-shingo.fg8@gmail.com> <83bl9t8vnb.fsf@gnu.org> <87h7jla6ih.fsf@nicolasgoaziou.fr> <8335v58ppu.fsf@gnu.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?Q?Goj=C5=8D?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.2 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-Spam-Score: 0.2 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.8 (/) Thank you for the advice. I see that `window-text-pixel-size' returns true displayed width but I think that's TRT for only the other bug I reported (bug#48149). These two bugs looks similar but the root causes are completed different. This bug (bug#48148) is actually caused by the difference of the width detection methods between line 1036 in ox-ascii.el (`length') and `fill-region'. This is because `org-ascii-template--document-title' first detects the title width by `length' and then tries to fill it by `org-ascii--fill-string' which does the action by `fill-region' inside. And since the filling point in `fill-region' is based on `move-to-column' and it looks like giving the same result as `string-width', I think `string-width' is TRT for this bug. In other words, specific to this bug, only the same width detection method as `fill-region' is required, even if it doesn't give you the precise width displayed. Please correct me if I am wrong. --- Shingo Tanaka On Sun, 02 May 2021 18:11:41 +0900, Eli Zaretskii wrote: > > > From: Nicolas Goaziou > > Cc: Shingo Tanaka , 48148@debbugs.gnu.org > > Date: Sun, 02 May 2021 10:23:34 +0200 > > > > > The accurate method of lining up in these cases is to use > > > window-text-pixel-size instead. That function will return the exact > > > width of a string as it will displayed, in pixels, because it uses the > > > same code as the display engine. > > > > Would you mind giving an example about `window-text-pixel-size' usage in > > this situation? > > I'm not sure what kind of example is necessary. How about if you ask > specific questions about the arguments of that function which you > don't understand clearly how to use? > > > AFAIU, `window-text-pixel-size' returns the size of the window > > No, it returns the size of _text_ when displayed in a window. > > > Note that `text-width' in the code above is not related to the width > > of the window, but is a maximum number of allowed characters on a > > line. > > I didn't mean text-width, I meant the use of string-width: it should > be replaced by a call to window-text-pixel-size. From unknown Tue Jun 17 01:43:49 2025 X-Loop: help-debbugs@gnu.org Subject: bug#48148: 27.2; ox-ascii breaks TITLE line wrongly when 2 width char is used Resent-From: Nicolas Goaziou Original-Sender: "Debbugs-submit" Resent-CC: emacs-orgmode@gnu.org Resent-Date: Sun, 02 May 2021 12:19:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48148 X-GNU-PR-Package: org-mode X-GNU-PR-Keywords: To: Eli Zaretskii Cc: shingo.fg8@gmail.com, 48148@debbugs.gnu.org Received: via spool by 48148-submit@debbugs.gnu.org id=B48148.161995791625470 (code B ref 48148); Sun, 02 May 2021 12:19:01 +0000 Received: (at 48148) by debbugs.gnu.org; 2 May 2021 12:18:36 +0000 Received: from localhost ([127.0.0.1]:42500 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ldB3U-0006ck-Hq for submit@debbugs.gnu.org; Sun, 02 May 2021 08:18:36 -0400 Received: from relay8-d.mail.gandi.net ([217.70.183.201]:50715) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ldB3Q-0006ca-9d for 48148@debbugs.gnu.org; Sun, 02 May 2021 08:18:35 -0400 X-Originating-IP: 185.131.40.67 Received: from localhost (40-67.ipv4.commingeshautdebit.fr [185.131.40.67]) (Authenticated sender: admin@nicolasgoaziou.fr) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 4638B1BF207; Sun, 2 May 2021 12:18:24 +0000 (UTC) From: Nicolas Goaziou References: <87h7jm2es2.wl-shingo.fg8@gmail.com> <83bl9t8vnb.fsf@gnu.org> <87h7jla6ih.fsf@nicolasgoaziou.fr> <8335v58ppu.fsf@gnu.org> Date: Sun, 02 May 2021 14:18:24 +0200 In-Reply-To: <8335v58ppu.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 02 May 2021 12:11:41 +0300") Message-ID: <871rap9vn3.fsf@nicolasgoaziou.fr> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Eli Zaretskii writes: > I'm not sure what kind of example is necessary. How about if you ask > specific questions about the arguments of that function which you > don't understand clearly how to use? Fair enough. However, i don't think my misunderstanding is related to arguments of that function. >> AFAIU, `window-text-pixel-size' returns the size of the window > > No, it returns the size of _text_ when displayed in a window. True. My problem is that I have some string, _which is not displayed anywhere_ yet. I need to obtain its real width along with the width of a single character in order to compute the length argument in `make-string'. I may be missing something obvious. > I didn't mean text-width, I meant the use of string-width: it should > be replaced by a call to window-text-pixel-size. `string-width' applies to a string. `window-text-pixel-size' doesn't. This is the root of my misunderstanding, I guess. Regards, From unknown Tue Jun 17 01:43:49 2025 X-Loop: help-debbugs@gnu.org Subject: bug#48148: 27.2; ox-ascii breaks TITLE line wrongly when 2 width char is used Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: emacs-orgmode@gnu.org Resent-Date: Sun, 02 May 2021 12:44:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48148 X-GNU-PR-Package: org-mode X-GNU-PR-Keywords: To: Shingo Tanaka Cc: shingo.fg8@gmail.com, 48148@debbugs.gnu.org, mail@nicolasgoaziou.fr Received: via spool by 48148-submit@debbugs.gnu.org id=B48148.161995943526385 (code B ref 48148); Sun, 02 May 2021 12:44:02 +0000 Received: (at 48148) by debbugs.gnu.org; 2 May 2021 12:43:55 +0000 Received: from localhost ([127.0.0.1]:42618 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ldBRz-0006rV-83 for submit@debbugs.gnu.org; Sun, 02 May 2021 08:43:55 -0400 Received: from eggs.gnu.org ([209.51.188.92]:55782) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ldBRx-0006rP-4e for 48148@debbugs.gnu.org; Sun, 02 May 2021 08:43:54 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:60107) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ldBRq-0000gx-RE; Sun, 02 May 2021 08:43:46 -0400 Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:2766 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1ldBRq-0001Tc-9Z; Sun, 02 May 2021 08:43:46 -0400 Date: Sun, 02 May 2021 15:43:28 +0300 Message-Id: <83v98171cf.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: <87pmy9pdz0.wl-shingo.fg8@gmail.com> (message from Shingo Tanaka on Sun, 02 May 2021 20:33:23 +0900) References: <87h7jm2es2.wl-shingo.fg8@gmail.com> <83bl9t8vnb.fsf@gnu.org> <87h7jla6ih.fsf@nicolasgoaziou.fr> <8335v58ppu.fsf@gnu.org> <87pmy9pdz0.wl-shingo.fg8@gmail.com> X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Date: Sun, 02 May 2021 20:33:23 +0900 > From: Shingo Tanaka > Cc: Nicolas Goaziou , > shingo.fg8@gmail.com, > 48148@debbugs.gnu.org > > This bug (bug#48148) is actually caused by the difference of the width > detection methods between line 1036 in ox-ascii.el (`length') and > `fill-region'. This is because `org-ascii-template--document-title' first > detects the title width by `length' and then tries to fill it by > `org-ascii--fill-string' which does the action by `fill-region' inside. And > since the filling point in `fill-region' is based on `move-to-column' and it > looks like giving the same result as `string-width', I think `string-width' > is TRT for this bug. > > In other words, specific to this bug, only the same width detection method as > `fill-region' is required, even if it doesn't give you the precise width > displayed. > > Please correct me if I am wrong. I think you are right, thanks. From unknown Tue Jun 17 01:43:49 2025 X-Loop: help-debbugs@gnu.org Subject: bug#48148: 27.2; ox-ascii breaks TITLE line wrongly when 2 width char is used Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: emacs-orgmode@gnu.org Resent-Date: Sun, 02 May 2021 12:49:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48148 X-GNU-PR-Package: org-mode X-GNU-PR-Keywords: To: Nicolas Goaziou Cc: shingo.fg8@gmail.com, 48148@debbugs.gnu.org Received: via spool by 48148-submit@debbugs.gnu.org id=B48148.161995972026569 (code B ref 48148); Sun, 02 May 2021 12:49:01 +0000 Received: (at 48148) by debbugs.gnu.org; 2 May 2021 12:48:40 +0000 Received: from localhost ([127.0.0.1]:42638 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ldBWZ-0006uT-RD for submit@debbugs.gnu.org; Sun, 02 May 2021 08:48:40 -0400 Received: from eggs.gnu.org ([209.51.188.92]:56162) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ldBWX-0006uL-SU for 48148@debbugs.gnu.org; Sun, 02 May 2021 08:48:38 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:60126) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ldBWS-0003ZT-Kk; Sun, 02 May 2021 08:48:32 -0400 Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:3054 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1ldBWS-0001lO-3g; Sun, 02 May 2021 08:48:32 -0400 Date: Sun, 02 May 2021 15:48:14 +0300 Message-Id: <83tunl714h.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: <871rap9vn3.fsf@nicolasgoaziou.fr> (message from Nicolas Goaziou on Sun, 02 May 2021 14:18:24 +0200) References: <87h7jm2es2.wl-shingo.fg8@gmail.com> <83bl9t8vnb.fsf@gnu.org> <87h7jla6ih.fsf@nicolasgoaziou.fr> <8335v58ppu.fsf@gnu.org> <871rap9vn3.fsf@nicolasgoaziou.fr> X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Nicolas Goaziou > Cc: shingo.fg8@gmail.com, 48148@debbugs.gnu.org > Date: Sun, 02 May 2021 14:18:24 +0200 > > My problem is that I have some string, _which is not displayed anywhere_ > yet. I need to obtain its real width along with the width of a single > character in order to compute the length argument in `make-string'. The width of any text on display is meaningless unless you also tell in what window will it be displayed. That's because some of the factors that affect the display width depend on the window and the buffer shown by that window. So assuming the string you have will eventually be displayed in some window -- and most strings in Emacs are of that kind -- you should use that window up front. Otherwise, the value you get from other methods can only be an approximation, which will sometimes be close, and sometimes quite far from the truth. From unknown Tue Jun 17 01:43:49 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Shingo Tanaka Subject: bug#48148: closed (Re: bug#48148: 27.2; ox-ascii breaks TITLE line wrongly when 2 width char is used) Message-ID: References: <87eeep86zv.fsf@nicolasgoaziou.fr> <87h7jm2es2.wl-shingo.fg8@gmail.com> X-Gnu-PR-Message: they-closed 48148 X-Gnu-PR-Package: org-mode Reply-To: 48148@debbugs.gnu.org Date: Sun, 02 May 2021 15:57:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1619971022-16664-1" This is a multi-part message in MIME format... ------------=_1619971022-16664-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #48148: 27.2; ox-ascii breaks TITLE line wrongly when 2 width char is used which was filed against the org-mode package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 48148@debbugs.gnu.org. --=20 48148: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D48148 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1619971022-16664-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 48148-done) by debbugs.gnu.org; 2 May 2021 15:56:14 +0000 Received: from localhost ([127.0.0.1]:43434 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ldES6-0004KZ-IY for submit@debbugs.gnu.org; Sun, 02 May 2021 11:56:14 -0400 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:58271) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ldES4-0004KT-Mw for 48148-done@debbugs.gnu.org; Sun, 02 May 2021 11:56:13 -0400 X-Originating-IP: 185.131.40.67 Received: from localhost (40-67.ipv4.commingeshautdebit.fr [185.131.40.67]) (Authenticated sender: admin@nicolasgoaziou.fr) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 8D72A60006; Sun, 2 May 2021 15:56:05 +0000 (UTC) From: Nicolas Goaziou To: Eli Zaretskii Subject: Re: bug#48148: 27.2; ox-ascii breaks TITLE line wrongly when 2 width char is used References: <87h7jm2es2.wl-shingo.fg8@gmail.com> <83bl9t8vnb.fsf@gnu.org> <87h7jla6ih.fsf@nicolasgoaziou.fr> <8335v58ppu.fsf@gnu.org> <871rap9vn3.fsf@nicolasgoaziou.fr> <83tunl714h.fsf@gnu.org> Date: Sun, 02 May 2021 17:56:04 +0200 In-Reply-To: <83tunl714h.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 02 May 2021 15:48:14 +0300") Message-ID: <87eeep86zv.fsf@nicolasgoaziou.fr> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 48148-done Cc: shingo.fg8@gmail.com, 48148-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Eli Zaretskii writes: >> From: Nicolas Goaziou >> Cc: shingo.fg8@gmail.com, 48148@debbugs.gnu.org >> Date: Sun, 02 May 2021 14:18:24 +0200 >> >> My problem is that I have some string, _which is not displayed anywhere_ >> yet. I need to obtain its real width along with the width of a single >> character in order to compute the length argument in `make-string'. > > The width of any text on display is meaningless unless you also tell > in what window will it be displayed. That's because some of the > factors that affect the display width depend on the window and the > buffer shown by that window. I understand. More than the width of the text, I'm interested in the ratio between the width of the text and the width of an underline character (assuming monospace). > So assuming the string you have will eventually be displayed in some > window -- and most strings in Emacs are of that kind -- you should use > that window up front. Otherwise, the value you get from other methods > can only be an approximation, which will sometimes be close, and > sometimes quite far from the truth. The string may not be displayed at all. Since it is the output of an export process, it could, e.g., be written to a file. I applied Shingo Tanaka's suggestion using `string-width', which is the best we can do considering our requirements. Thank you for your answer, and to Shingo Tanaka for the report an the patch. Regards, ------------=_1619971022-16664-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 1 May 2021 23:52:25 +0000 Received: from localhost ([127.0.0.1]:39138 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lczPN-0007Fu-7G for submit@debbugs.gnu.org; Sat, 01 May 2021 19:52:25 -0400 Received: from lists.gnu.org ([209.51.188.17]:33894) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lczPL-0007Fo-IF for submit@debbugs.gnu.org; Sat, 01 May 2021 19:52:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58834) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lczPL-0001Ou-AJ for bug-gnu-emacs@gnu.org; Sat, 01 May 2021 19:52:23 -0400 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]:45980) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lczPH-0002Gt-Jv for bug-gnu-emacs@gnu.org; Sat, 01 May 2021 19:52:23 -0400 Received: by mail-pg1-x52c.google.com with SMTP id d10so1141849pgf.12 for ; Sat, 01 May 2021 16:52:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:from:to:subject:user-agent:mime-version; bh=hPWIBgjnTfQryIjpr/KLTYOqXCYv9wpOSGTRXBYm55w=; b=ODTOlDA19WxakEi2YtdCCkDYrFPPptSJjRa4nTAPrTvZfGVvqcHX33E8lWQI6WxGiv 8WhcLFlQEA9JfQRhPdcKwlyZycgU2JqSYrCPJXbTlN8KMUIIc6ttVtmiDvwB0VcxUoBF xDw0YiRLYzVLTMXb0LjO40iaRnGLBVmU0POASbmnescRK+3uVmQKGRBU2g+bZAyA++so akYtuTYLKZsBVPDPkCO6C6gkdL1yH/mydbU2K6T2jfCAcWq9hudNolqBHqX1uYrYhErR 3B68aZjfg7g+ymQD5xruha8IUzDOyHNbzzJZO5Gi74jFrNFs6Yk/WaDTHCjro5K9M8pB G31Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:from:to:subject:user-agent :mime-version; bh=hPWIBgjnTfQryIjpr/KLTYOqXCYv9wpOSGTRXBYm55w=; b=KNSLPifJ3IJUp3fobjXaGhZ71DtW4K7XUfH5UPLwADrsCQ/hWsqRl+rqs4MDZAFMFv x7KXv9O1LSDqTNfWHeaPOFhxhAXD3LAtTMhpTTdA2jqV9D/Y4PwFESw7sHfE68D6JX8K NHkkAXvPj9vyjzV+TGP67Kws5cDdbCy/9fUNo8TZamZ2WSEic3KthfHsgbhEk2KtDgbK McBKezGi1IkVwAUG+LG0/+UkIY+3H2YFzmCAVxyyMB7CU7HV8/4LFO4IGpmp0yCjFpQQ Xc2M5Eaik2Q2nS0CQV2Bg8oWOVZNbURslg+Jt0ZhDhrW49OrvrVIEn6KWQPa5tbShAFT Lzmw== X-Gm-Message-State: AOAM530seNTdVde1XcpxXQgNBro4L8E05rJlLbWz6bq5+gTrl/wmBEr4 6KQBDXIza05jppzv9druFR2h8zNHmTkX+w== X-Google-Smtp-Source: ABdhPJxCF1fNwThwV415Dxikm3A9xCV0fL/fR/iy12XG5Ol7hrbkWRAFExP9TwUb7S9nLfmevn4/UA== X-Received: by 2002:a63:130f:: with SMTP id i15mr11101467pgl.151.1619913137128; Sat, 01 May 2021 16:52:17 -0700 (PDT) Received: from shingo-desktop.gmail.com ([240d:1a:6f4:6b00:5514:ce7d:f5f9:375b]) by smtp.gmail.com with ESMTPSA id s13sm5296845pfd.79.2021.05.01.16.52.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 May 2021 16:52:16 -0700 (PDT) Date: Sun, 02 May 2021 08:52:13 +0900 Message-ID: <87h7jm2es2.wl-shingo.fg8@gmail.com> From: Shingo Tanaka To: bug-gnu-emacs@gnu.org Subject: 27.2; ox-ascii breaks TITLE line wrongly when 2 width char is used User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.2 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=ISO-2022-JP Received-SPF: pass client-ip=2607:f8b0:4864:20::52c; envelope-from=shingo.fg8@gmail.com; helo=mail-pg1-x52c.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, 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-Spam-Score: -1.1 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.1 (--) Hi, When exporting org-mode document to plain text (either ascii/unicode/utf-8) with `org-export-dispatch', Emacs translates the document title with `org-ascii-template--document-title'. However, when 2 width character is used, it detects the title line's width wrongly and breaks it even if the width is not too long. For example, when the title is "ABCDEF" (each character has width of 2), expected title would be like: ━━━━━━━━━━━━━━━ ABCDEF ━━━━━━━━━━━━━━━ However, the reality is: ━━━━━━━━━━━━━━━ ABC DEF ━━━━━━━━━━━━━━━ This is because it uses `length' to detects the width, which only returns the number of characters (6 in this case) but not the actual width displayed (12 in this case), and it tries to fill the line with that half width. `string-width' should be used instead. Here is a potential patch. --- ox-ascii.el.org 2021-03-26 09:28:44.000000000 +0900 +++ ox-ascii.el 2021-05-02 08:11:57.657347150 +0900 @@ -1033,7 +1033,7 @@ ;; Format TITLE. It may be filled if it is too wide, ;; that is wider than the two thirds of the total width. (title-len (min (apply #'max - (mapcar #'length + (mapcar #'string-width (org-split-string (concat title "\n" subtitle) "\n"))) (/ (* 2 text-width) 3))) --- Shingo Tanaka ------------=_1619971022-16664-1-- From unknown Tue Jun 17 01:43:49 2025 X-Loop: help-debbugs@gnu.org Subject: bug#48148: 27.2; ox-ascii breaks TITLE line wrongly when 2 width char is used Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: emacs-orgmode@gnu.org Resent-Date: Sun, 02 May 2021 16:13:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48148 X-GNU-PR-Package: org-mode X-GNU-PR-Keywords: To: Nicolas Goaziou Cc: shingo.fg8@gmail.com, 48148@debbugs.gnu.org Received: via spool by 48148-submit@debbugs.gnu.org id=B48148.161997193617288 (code B ref 48148); Sun, 02 May 2021 16:13:01 +0000 Received: (at 48148) by debbugs.gnu.org; 2 May 2021 16:12:16 +0000 Received: from localhost ([127.0.0.1]:43517 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ldEhc-0004Um-5Y for submit@debbugs.gnu.org; Sun, 02 May 2021 12:12:16 -0400 Received: from eggs.gnu.org ([209.51.188.92]:55210) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ldEha-0004Ug-0e for 48148@debbugs.gnu.org; Sun, 02 May 2021 12:12:15 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:34069) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ldEhU-0005lQ-Qi; Sun, 02 May 2021 12:12:08 -0400 Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:3888 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1ldEhU-0002ge-14; Sun, 02 May 2021 12:12:08 -0400 Date: Sun, 02 May 2021 19:11:49 +0300 Message-Id: <83k0oh6rp6.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: <87eeep86zv.fsf@nicolasgoaziou.fr> (message from Nicolas Goaziou on Sun, 02 May 2021 17:56:04 +0200) References: <87h7jm2es2.wl-shingo.fg8@gmail.com> <83bl9t8vnb.fsf@gnu.org> <87h7jla6ih.fsf@nicolasgoaziou.fr> <8335v58ppu.fsf@gnu.org> <871rap9vn3.fsf@nicolasgoaziou.fr> <83tunl714h.fsf@gnu.org> <87eeep86zv.fsf@nicolasgoaziou.fr> X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Nicolas Goaziou > Cc: shingo.fg8@gmail.com, 48148-done@debbugs.gnu.org > Date: Sun, 02 May 2021 17:56:04 +0200 > > More than the width of the text, I'm interested in the > ratio between the width of the text and the width of an underline > character (assuming monospace). And that is rarely 2 for double-width characters. Especially if the underline and the double-width characters are displayed using different fonts. > The string may not be displayed at all. Since it is the output of an > export process, it could, e.g., be written to a file. If that text file can be displayed using some software you know nothing about, then this problem doesn't have an accurate solution, only approximate ones.