all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Shingo Tanaka <shingo.fg8@gmail.com>
To: 48148@debbugs.gnu.org
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	[thread overview]
Message-ID: <87h7jm2es2.wl-shingo.fg8@gmail.com> (raw)

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





             reply	other threads:[~2021-05-01 23:52 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-01 23:52 Shingo Tanaka [this message]
2021-05-02  7:03 ` bug#48148: 27.2; ox-ascii breaks TITLE line wrongly when 2 width char is used Eli Zaretskii
2021-05-02  8:23   ` Nicolas Goaziou
2021-05-02  9:11     ` Eli Zaretskii
2021-05-02 11:33       ` Shingo Tanaka
2021-05-02 12:43         ` Eli Zaretskii
2021-05-02 12:18       ` Nicolas Goaziou
2021-05-02 12:48         ` Eli Zaretskii
2021-05-02 15:56           ` Nicolas Goaziou
2021-05-02 16:11             ` Eli Zaretskii

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87h7jm2es2.wl-shingo.fg8@gmail.com \
    --to=shingo.fg8@gmail.com \
    --cc=48148@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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.