diff --git a/lisp/org.el b/lisp/org.el index 28b4d52b6..e015a777f 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -14937,7 +14937,7 @@ If ONOFF is `on' or `off', don't toggle but set to this state." (if (and (looking-at ".*?\\([ \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))) diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index d40b86fc8..6884c2426 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -4452,6 +4452,25 @@ Paragraph" (org-tag-alist-to-groups '((:startgroup) ("group") ("t1") ("t2") (:endgroup))))) +(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