From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id 0BJlHBt1RWQBRAAASxT56A (envelope-from ) for ; Sun, 23 Apr 2023 20:12:43 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id 4A4EHBt1RWQoOwAA9RJhRA (envelope-from ) for ; Sun, 23 Apr 2023 20:12:43 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 3604A7512 for ; Sun, 23 Apr 2023 20:12:43 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqbUP-0003MY-7F; Sun, 23 Apr 2023 11:18:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pqbUN-0003MG-Uo for emacs-orgmode@gnu.org; Sun, 23 Apr 2023 11:18:55 -0400 Received: from netyu.xyz ([152.44.41.246] helo=mail.netyu.xyz) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pqbUL-0003D3-Iq for emacs-orgmode@gnu.org; Sun, 23 Apr 2023 11:18:55 -0400 Received: from fw.net.yu.netyu.xyz ( [222.248.4.98]) by netyu.xyz (OpenSMTPD) with ESMTPSA id 7e0d013b (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Sun, 23 Apr 2023 15:18:51 +0000 (UTC) References: <87ildmuavp.fsf@localhost> <87y1misv5l.fsf@localhost> <877cu24p5b.fsf@localhost> User-agent: mu4e 1.9.22; emacs 30.0.50 To: Ihor Radchenko Cc: Axel Kielhorn , emacs-orgmode@gnu.org Subject: Re: [DRAFT PATCH v2] Decouple LANG= and testing (was: Test failure due to LANG) Date: Sun, 23 Apr 2023 23:15:27 +0800 In-reply-to: <877cu24p5b.fsf@localhost> Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=152.44.41.246; envelope-from=ruijie@netyu.xyz; helo=mail.netyu.xyz X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Ruijie Yu From: Ruijie Yu via "General discussions about Org-mode." Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Seal: i=1; s=key1; d=yhetil.org; t=1682273563; a=rsa-sha256; cv=none; b=juAxFqwZPF8T3vhNv+UB8QQf8B5PdxTHosK9sYqAEsD6+4TRWg5UcFVQeAXqy9jz3TL0dj 0/Ukb/7K70WJJYiz/pRJxHJSve1x0iQkzcAQs1wrLz9d07uUXe/RfTm7QN32RGRBh+nSDg oNWDCxlTp3yUYJZ2wyL5p4vKUES7UJ614PoIQ67OaMBQOY+aWmMfr+vXWFE7+IoxGFHlj9 aglqU9zejWDkOFq+cUGb/72s1l4Zn0rCWCj8XY6j54MsjKfMm0fEseAZPdJ67XjaHp37BC oA8FoX+Xe8NABVuPZDXYih/P7bekQJlcNbdQnXYEvBxB/BCIAhobH+5VFpGP/w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1682273563; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=r/LVJYlQ5ZgHSUujbNNrV7dcRr4umFFl1ipkxyplgHw=; b=m83NH3Cr+lYOKmKBYohL9jcO6ysnWLzOlsCUnV0xXk7qPyybkiRs9VRrsWzVFtTN/2/DsF /S3kKSrBUfXYdar8cjcXTK+q4xRi2/8ccvdQySs/JLZXuyx0sPJ2LRWYkJKpuoawHICtyY RMEDE87rwqEXG+2B5KSxwWTKCdAl/+hhGBgW7jT1TuROBRrDqPrMVLL4rdC2ZdIaa+bEdg FxfMF8vchlSdWTkTnGsIG6Z+KEIRyw0yjmCHXUthkBkaPtCP1ovixxg69JwtpjLf+5VqkS ezCMtPjF2zNXA6TGQs5ax1kPEnQkS8fM54CSoCNpSbWmFq70FMSrBIDC0Lj5rg== X-Migadu-Scanner: scn1.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -3.51 X-Spam-Score: -3.51 X-Migadu-Queue-Id: 3604A7512 X-TUID: 7ea71WwmF+l/ --=-=-= Content-Type: text/plain Ihor Radchenko writes: > Ruijie Yu writes: > >>> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=63029 >> >> From my understanding of Eli's response, org-colview is at fault here, by >> calling `length' instead of `string-width' in >> `org-columns-add-ellipses'. Changing this function call might be all it >> needs to fix the colview test failure? > > This is tricky because string width may be different depending on > in-buffer settings, fonts used, etc. > > We can try to be a tiny little bit more accurate using > `truncate-string-to-width', `string-width', or `org-string-width'. Just had a try at this, fully untested code (other than starting a LANG=zh_CN.UTF-8 Emacs session and running this substring function to see its effects). It is a bit too late for me now, so I'll call it a day (literally) for coding today. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=org-colview.diff diff --git a/lisp/org-colview.el b/lisp/org-colview.el index 92a3b473d..e8106f9cd 100644 --- a/lisp/org-colview.el +++ b/lisp/org-colview.el @@ -452,14 +452,30 @@ DATELINE is non-nil when the face used should be "Type \\`\\[org-columns-edit-value]' \ to edit property"))))))) +(defun org-columns--substring-below-width (string start width) + "Similar to `substring', but use `string-width' to check width. +The returned value is a substring of STRING, starting at START, +and is the largest possible substring whose width does not exceed +WIDTH." + (let ((end (min (+ start width) (length string))) res) + (while (and end (>= end start)) + (let* ((curr (string-width string start end)) + (excess (- curr width))) + (if (cl-plusp excess) + (cl-decf end (max 1 (/ excess 2))) + (setq res (substring string start end) end nil)))) + res)) + (defun org-columns-add-ellipses (string width) "Truncate STRING with WIDTH characters, with ellipses." (cond - ((<= (length string) width) string) - ((<= width (length org-columns-ellipses)) - (substring org-columns-ellipses 0 width)) - (t (concat (substring string 0 (- width (length org-columns-ellipses))) - org-columns-ellipses)))) + ((<= (string-width string) width) string) + ((<= width (string-width org-columns-ellipses)) + (org-columns--substring-below-width org-columns-ellipses 0 width)) + (t (concat + (org-columns--substring-below-width + string 0 (- width (length org-columns-ellipses))) + org-columns-ellipses)))) (defvar org-columns-full-header-line-format nil "The full header line format, will be shifted by horizontal scrolling." ) --=-=-= Content-Type: text/plain -- Best, RY [Please note that this mail might go to spam due to some misconfiguration in my mail server -- still investigating.] --=-=-=--