Hi,

On Thu, 02 Jun 2016 02:34:31 +0900,
Nicolas Goaziou wrote:
> 
> > Would you remove the extra section marker (";;; Tags") thing when
> > merge to master?  It merges cleanly from maint to master but leaves
> > the marker.
> 
> I'll take care of the merging back to master.

Thank you.

> > please pull from:
> >
> >   https://github.com/yashi/org-mode tag-width-fix
> 
> I'd rather have the patch with the commit message as an attachment, if
> you don't mind.

Sure.  Attached.

Thanks,
-- 
         yashi

From b57dee1c44d8dd6979c5a6953ad12fdb487d5092 Mon Sep 17 00:00:00 2001
From: Yasushi SHOJI <ya...@atmark-techno.com>
Date: Tue, 31 May 2016 16:25:42 +0900
Subject: [PATCH 1/2] org: Fix tag width calculation for multi-column chars
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Some characters have multiple column width.  Calculating string width
with points gives a wrong value than actual display width.  Use
`string-width' instead.

Here is an ECM for this problem.  `M-x org-update-statistics-cookies` or
`C-c #` on bar moves the tag on the headline.

* foo [0/0]                                                             :abc:
** child
* bar [0/0]                                                          :日本語:
** child
12345678901234567890123456789012345678901234567890123456789012345678901234567890
         1         2         3         4         5         6         7         8
---
 lisp/org.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/org.el b/lisp/org.el
index a9412ea..15f851d 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -14923,7 +14923,7 @@ If ONOFF is `on' or `off', don't toggle but set to this 
state."
     (if        (and (looking-at (org-re ".*?\\([ 
\t]+\\)\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$"))
             (< pos (match-beginning 2)))
        (progn
-         (setq tags-l (- (match-end 2) (match-beginning 2)))
+         (setq tags-l (string-width (match-string 2)))
          (goto-char (match-beginning 1))
          (insert " ")
          (delete-region (point) (1+ (match-beginning 2)))
-- 
2.8.1

From 4cbd72931e7982878334c92abb08272f11ae0f32 Mon Sep 17 00:00:00 2001
From: Yasushi SHOJI <ya...@atmark-techno.com>
Date: Tue, 31 May 2016 16:25:42 +0900
Subject: [PATCH 2/2] org: Add test for tag width calculation

This is a simple unit test case for the previous fix.
---
 testing/lisp/test-org.el | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index db7e525..4873fc2 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -4132,6 +4132,28 @@ Paragraph<point>"
        (org-occur "A" nil (lambda () (equal (org-get-heading) "H2")))))))
 
 
+;;; Tags
+
+(ert-deftest test-org/tag-align ()
+  "Test `org-align-tags-here' with different display width."
+  (should
+   ;;      12345678901234567890
+   (equal "* Test         :abc:"
+         (org-test-with-temp-text "* Test :abc:"
+           (let ((org-tags-column -20)
+                 (indent-tabs-mode nil))
+            (org-fix-tags-on-the-fly))
+           (buffer-string))))
+  (should
+   ;;      12345678901234567890
+   (equal "* Test      :日本語:"
+         (org-test-with-temp-text "* Test :日本語:"
+           (let ((org-tags-column -20)
+                 (indent-tabs-mode nil))
+            (org-fix-tags-on-the-fly))
+           (buffer-string)))))
+
+
 ;;; Timestamps API
 
 (ert-deftest test-org/time-stamp ()
-- 
2.8.1

Reply via email to