From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Shingo Tanaka Newsgroups: gmane.emacs.bugs Subject: bug#48148: 27.2; ox-ascii breaks TITLE line wrongly when 2 width char is used Date: Sun, 02 May 2021 08:52:13 +0900 Message-ID: <87h7jm2es2.wl-shingo.fg8@gmail.com> Mime-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=ISO-2022-JP Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10196"; mail-complaints-to="usenet@ciao.gmane.io" 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) To: 48148@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun May 02 01:53:11 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1lczQ6-0002Vo-Ae for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 02 May 2021 01:53:10 +0200 Original-Received: from localhost ([::1]:60620 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lczQ5-0001VK-Dy for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 01 May 2021 19:53:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58924) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lczPy-0001Ud-JG for bug-gnu-emacs@gnu.org; Sat, 01 May 2021 19:53:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:55827) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lczPy-0002j4-Bj for bug-gnu-emacs@gnu.org; Sat, 01 May 2021 19:53:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lczPy-0007GG-BM for bug-gnu-emacs@gnu.org; Sat, 01 May 2021 19:53:02 -0400 X-Loop: help-debbugs@gnu.org 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-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.161991314527898 (code B ref -1); Sat, 01 May 2021 23:53:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 1 May 2021 23:52:25 +0000 Original-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 Original-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 Original-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 Original-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 Original-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) Original-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) 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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:205372 Archived-At: 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