From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id CJTbLXQQYGJUSQAAbAwnHQ (envelope-from ) for ; Wed, 20 Apr 2022 15:53:56 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id +N+zLXQQYGKCGQEAauVa8A (envelope-from ) for ; Wed, 20 Apr 2022 15:53:56 +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 59B07301F5 for ; Wed, 20 Apr 2022 15:53:56 +0200 (CEST) Received: from localhost ([::1]:49150 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhAmJ-0006Il-Es for larch@yhetil.org; Wed, 20 Apr 2022 09:53:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37740) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhAMA-0005cX-Om for emacs-orgmode@gnu.org; Wed, 20 Apr 2022 09:26:56 -0400 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]:54858) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhAM8-0004Ok-JM for emacs-orgmode@gnu.org; Wed, 20 Apr 2022 09:26:53 -0400 Received: by mail-pj1-x1036.google.com with SMTP id md4so1915111pjb.4 for ; Wed, 20 Apr 2022 06:26:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:in-reply-to:references:message-id:date:mime-version; bh=/AhqjaSqngHWhQj4Gq7wRyiFLNG280/zqh03PbJtebQ=; b=ctIZlW8HKv7/CiYJaWNRVFTa8mRLcBKV3Ag5AwtiGv3IdZVdBMnWHD8NAZtvD5855k bKu/qckvBEHop+ZVKT/D+tWzAvNQVFRXC7BvgfpOxUBN+x9iCS1PDdFe9JVlqUec2Y7A /EI4QC64jwtRebxUeD90jEzvP64Vp4sgJCg9VzPkV1v1KhtbDvgZmn9+26YInJvy1wkk puhVm+llYushv95zMG1BSn6003C9e8Gfk3U3p32Essupp9T2WAiGtsmEx4tZJbiRa52a HURPkbA7x6y0fhrQNqsQjB4pIdG93nrmBJ9D6reDNV95WIav0mtGeHwQRCmuFp8Ydhvq qt7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:in-reply-to:references :message-id:date:mime-version; bh=/AhqjaSqngHWhQj4Gq7wRyiFLNG280/zqh03PbJtebQ=; b=myofrZ1LnmWxzrETcoZKLyxJ/pKbu0/DdE+Uq1j+YjehRo9sBxjN81dFoCTiLMaVde w1bZStWA/QF2mvn+3BL7LYP6Vfch3Qur2HaZTSkDwAyw1v8XTAuM1bPi6B6dDjtZzK58 Qrs/Un9c58BrixD7vPLa01GsgjmKRur1EB9it1ygl3aIrlpmi5gytwtShDhIrpGM1sUn gukp5dWLuAlV83ErH5wLlyxm1e4b0aZe8kNXApyKVMEoRYDkV87lqwhw7/nDEFXSDRJ1 BTTqYEI5qBO7oon3cNYIoDhlQk1UkA6kUOmvOtFVEDdzwm7DsTJmysPnfUomc0aUgH80 Y7rQ== X-Gm-Message-State: AOAM5325PClCZuuoSj6bbQbw0K6D+v5iQ0bMm79YnrCRYhQFQ6rpyLiB UT3JCQVIGSAzgVSjzK5fvESONk5HhoqGHA== X-Google-Smtp-Source: ABdhPJwdvvPuy03OU6rO+/ZBXUg+w0fwghBmN/bPOcr4LtU1opRgyTOL6JWpGHbaViJpqXVyrXkizQ== X-Received: by 2002:a17:902:bf4c:b0:154:9f0f:fa42 with SMTP id u12-20020a170902bf4c00b001549f0ffa42mr20567899pls.120.1650461209036; Wed, 20 Apr 2022 06:26:49 -0700 (PDT) Received: from localhost ([64.32.23.62]) by smtp.gmail.com with ESMTPSA id ch10-20020a056a00288a00b0050a51a95e91sm14370684pfb.201.2022.04.20.06.26.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 06:26:48 -0700 (PDT) From: Ihor Radchenko To: emacs-orgmode@gnu.org Subject: [PATCH v2 28/38] org-string-width: Handle undefined behaviour in older Emacs In-Reply-To: References: Message-Id: <5b778db200e708b769176f0ab80a8a5d2a0c64ff.1650460489.git.yantar92@gmail.com> Date: Wed, 20 Apr 2022 21:27:42 +0800 MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::1036; envelope-from=yantar92@gmail.com; helo=mail-pj1-x1036.google.com 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, 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, 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: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1650462836; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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:dkim-signature; bh=/AhqjaSqngHWhQj4Gq7wRyiFLNG280/zqh03PbJtebQ=; b=LjRaV2Y+0p1l+hgFu2YvTxODfI3+pufUvSPRVbSeCKoMIJdkPafFOjQYBzXqRFOV0AEBXK XrD4FBpO51+XNRdB/Vz3lAdeSwg4JBXsVxTvabFMiqoDWsELH6MsZNKe9BhJuCwKUQSubg lxKoZzUpL3+f5KizkTZXmcV3nuNBkHSft/WUmmXAUqKC5DqyBbHjb2TvvpQGTabqmUd6R8 ToiN6Vj3snchrVe0YbgbktPJ4AGvjePXHl0ZNIL0cLi1RKoqpYXoV/O62bd+FSRf1cVhdM VgT5sXZn6AVttzfvhog5PqkagXU+OyGMaLCBZut+F6GWVPJ6Hgi2aEq+h4kNHw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1650462836; a=rsa-sha256; cv=none; b=dg8hkDjzg1DKUki2eRCKtEdWmSHSpVn88xvwmSvpoUuJ7MB8SoOHeMF1vArJVBLyd4QwUP HFp4Rmbc95au+e7oc4vY4U3L1982OQSrkWbUUwuTfmfKNAXjL+R/CGGWAzvwfnSWtLPAw7 gAJn3rNVD/RyJFlGQ0jcwZLc69XWB1mK46IxcSjHuAQm2IPaRLslCSw25/mET9hWlpLVe5 46t6lQ8WuMVr61RYr6t6NrE1MSaQ9vV6IX2K+747K0SNKd5AXk4dXy6E9JmnNyd7PYLPIf RkOC23zP68qVmWbpq3t6sEi7ZMydMZLBgbsXWTDqlK6unQX1g9Dnsl2oTeOqfQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=ctIZlW8H; dmarc=pass (policy=none) header.from=gmail.com; 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.04 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=ctIZlW8H; dmarc=pass (policy=none) header.from=gmail.com; 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-Queue-Id: 59B07301F5 X-Spam-Score: -3.04 X-Migadu-Scanner: scn1.migadu.com X-TUID: 3UuJ4V1hUxoP * lisp/org-macs.el (org-string-width): Force older Emacs treating invisible text with ellipsis as zero-width. Newer Emacs versions do exactly this. --- lisp/org-macs.el | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lisp/org-macs.el b/lisp/org-macs.el index 188168cdc..e56a234d3 100644 --- a/lisp/org-macs.el +++ b/lisp/org-macs.el @@ -926,7 +926,16 @@ (defun org-string-width (string &optional pixels) (with-temp-buffer (setq-local display-line-numbers nil) (setq-local buffer-invisibility-spec - current-invisibility-spec) + (if (listp current-invisibility-spec) + (mapcar (lambda (el) + ;; Consider elipsis to have 0 width. + ;; It is what Emacs 28+ does, but we have + ;; to force it in earlier Emacs versions. + (if (and (consp el) (cdr el)) + (list (car el)) + el)) + current-invisibility-spec) + current-invisibility-spec)) (setq-local char-property-alias-alist current-char-property-alias-alist) (let (pixel-width symbol-width) -- 2.35.1 -- Ihor Radchenko, PhD, Center for Advancing Materials Performance from the Nanoscale (CAMP-nano) State Key Laboratory for Mechanical Behavior of Materials, Xi'an Jiaotong University, Xi'an, China Email: yantar92@gmail.com, ihor_radchenko@alumni.sutd.edu.sg