From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.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 QLOALA4XYGIFEAEAbAwnHQ (envelope-from ) for ; Wed, 20 Apr 2022 16:22:06 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id eCJsKw4XYGKyhQEAG6o9tA (envelope-from ) for ; Wed, 20 Apr 2022 16:22:06 +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 1765331A16 for ; Wed, 20 Apr 2022 16:22:06 +0200 (CEST) Received: from localhost ([::1]:34004 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhBDZ-0004dl-4N for larch@yhetil.org; Wed, 20 Apr 2022 10:22:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38338) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhAN1-0006mR-M4 for emacs-orgmode@gnu.org; Wed, 20 Apr 2022 09:27:49 -0400 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]:38609) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhAN0-0004Zm-0S for emacs-orgmode@gnu.org; Wed, 20 Apr 2022 09:27:47 -0400 Received: by mail-pf1-x42a.google.com with SMTP id b15so1935402pfm.5 for ; Wed, 20 Apr 2022 06:27:45 -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=J7PaUvFQMmFZUIQgS/PVTd/7a6BzM2v+tXcEU04s+F4=; b=AO7kTEV4B/inD4sAOBJp5VfpivrSLmIgNAfxJGddehDMxX85b2cneUGSnihpwBF58S PzJjz1Nj+Ei1ZmAZJNHJwd8pSgyRpsePNLNr6rTWs4cDxPYDDRU4tG1eZFMysZZQUfdn XynpF0gZFqypPBD+GdRPhV0tjrrG+lmww7eMDJ/TA2O2F1Xs6sDOU8bI5brwW6fQHJUp +S5JB+4pZO3M5w8PvLp/l/tilL3QfTfnS5gjyH8FPBPxW198sn5QjhJVFpLd19e+zHUD 5HmLV5HuXLSoSrYd0LBqGHlNvr7vzoGvNrSN0imRmCZt0NZMA4lQRZhF2X8PVo3nbsfK KQZQ== 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=J7PaUvFQMmFZUIQgS/PVTd/7a6BzM2v+tXcEU04s+F4=; b=tTThl/QcScmyQCJIYJ8JEgNV+ZCispW2Bm4/ObO/U1dRipdhj8+9dy7CNsl06qtCix Vm5Ij3wJ+A7cOM/TZ633qzmAWpoZFU+fks2PpbFRs5gwz+wNXewsk5GVxr58WIAtlKaf pFEi679j8p57rb+BOAsOz8q+Uh0GGe4WonCX6QvO48qXs4RW3lByxVqir/a9zEQaFeXS YeeTow72Hb+6ZIa9QwAMkLEEFdvQPJ/Rj0l0mmhlF86udchlaAHbNwRrT+QuXhJaBwhA On3KAEfnZ2QvgGP7K6w0uWq04JwUL4CAGRjvA/SRENdbdsUfGu86m8XDIBR/jStAoPO/ tlAA== X-Gm-Message-State: AOAM530MHwphi5mgJcIqGEUdcRVCsLH1Cbb+I9gGdiqPalpgeEOu1eLn CKnCdtKqlaUng80af0wydHjf1ueeVF4YIQ== X-Google-Smtp-Source: ABdhPJwti/8VDUsrc+RZNFwzxueoUP49lnxPRpjpEoQPghxWcIcS5zz+tKLro6sobx3s6dry16swWQ== X-Received: by 2002:a63:1b5e:0:b0:3aa:593c:9392 with SMTP id b30-20020a631b5e000000b003aa593c9392mr4441030pgm.470.1650461264329; Wed, 20 Apr 2022 06:27:44 -0700 (PDT) Received: from localhost ([64.32.23.62]) by smtp.gmail.com with ESMTPSA id f16-20020a056a00239000b004fa7103e13csm21327782pfc.41.2022.04.20.06.27.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 06:27:43 -0700 (PDT) From: Ihor Radchenko To: emacs-orgmode@gnu.org Subject: [PATCH v2 37/38] org-fold-core-fontify-region: Fix cases when fontification is not registered In-Reply-To: References: Message-Id: Date: Wed, 20 Apr 2022 21:28:37 +0800 MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::42a; envelope-from=yantar92@gmail.com; helo=mail-pf1-x42a.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=1650464526; 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=J7PaUvFQMmFZUIQgS/PVTd/7a6BzM2v+tXcEU04s+F4=; b=fatnq6lxbMJ0pWGHOJ3YKGJNitQvef4146zv04BUGZox0RhWADIbzpi7KYLLbblCo6cQZE ixxZGWbM5KyXgEIS3QStnRwDsNNlfe+0ex7h3011S55gns7wW30//uy2LnLHQ8z/pa2Iok U28bt5dmvbA6lrAsJ4fizut0ZBT4KDsq3hkJkFIfeHGHb9OFfhnzFpvnLrYlfOPTPFn238 iXV3Rg46w7oK1doghvxpwxXDdPyz4fZvgf3gKdt7QulPgAKIkU3Og/LI7XotqbDhkB2Mu6 gTw3W2LWmnHg4M+67NkjlP3vD+725J9cXutAHGpJvC/mfF2bh/k5HSvh/9EqCA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1650464526; a=rsa-sha256; cv=none; b=D8+UMhXQaUm+ewolSEprs19opv3q2ExQDNt6jfPQvgWIac3e7x8CvpERu92TlAizd/EF5B lkEmG+KcfYueYeK08rth9kPeUoURFEpui6GoRYF7II9joT+s/gDqyKug4JHrMaLoexf1Ut 2RRk0fUS8Dkwu33L5WfHKkxrdOtTggTvUoEMz8eYG8eVN7FHg7d5XupGCY96fBJMDD61hs 5e7XtQJdDkMA6zK3VZiWZe4/jYH8W66ktDY9xQCsf1iUIZDxotGPFvX5ko16akhQe0BSJK Kgi38uhzrIE75/PsasfEepr02LSU/6vE6q66FFYi/nRunGbm+t/17OuzhZhHOQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=AO7kTEV4; 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: -6.54 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=AO7kTEV4; 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: 1765331A16 X-Spam-Score: -6.54 X-Migadu-Scanner: scn0.migadu.com X-TUID: myU/kLdSYYoQ * lisp/org-fold-core.el (org-fold-core-fontify-region): Handle FORCE argument better. Skip unnecessary code parts when FORCE is non-nil. Assign `fontified' text property manually in the actually fontified regions. We cannot just supply correct return value since jit-lock does not allow piecewise fontification. --- lisp/org-fold-core.el | 51 +++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/lisp/org-fold-core.el b/lisp/org-fold-core.el index edae316ff..d98eb6358 100644 --- a/lisp/org-fold-core.el +++ b/lisp/org-fold-core.el @@ -1436,40 +1436,43 @@ (defvar org-fold-core--force-fontification nil (defun org-fold-core-fontify-region (beg end loudly &optional force) "Run `font-lock-default-fontify-region' in visible regions." (with-silent-modifications - (let ((pos beg) next - (force (or force org-fold-core--force-fontification)) - (org-fold-core--fontifying t) - (skip-specs - (let (result) - (dolist (spec (org-fold-core-folding-spec-list)) - (when (and (not (org-fold-core-get-folding-spec-property spec :visible)) - (org-fold-core-get-folding-spec-property spec :font-lock-skip)) - (push spec result))) - result))) + (let* ((pos beg) next + (force (or force org-fold-core--force-fontification)) + (org-fold-core--fontifying t) + (skip-specs + (unless force + (let (result) + (dolist (spec (org-fold-core-folding-spec-list)) + (when (and (not (org-fold-core-get-folding-spec-property spec :visible)) + (org-fold-core-get-folding-spec-property spec :font-lock-skip)) + (push spec result))) + result)))) ;; Move POS to first visible point within BEG..END. - (while (and (catch :found - (dolist (spec (org-fold-core-get-folding-spec 'all pos)) - (when (org-fold-core-get-folding-spec-property spec :font-lock-skip) - (throw :found spec)))) - (< pos end)) - (setq pos (org-fold-core-next-folding-state-change nil pos end))) + (unless force + (while (and (catch :found + (dolist (spec (org-fold-core-get-folding-spec 'all pos)) + (when (org-fold-core-get-folding-spec-property spec :font-lock-skip) + (throw :found spec)))) + (< pos end)) + (setq pos (org-fold-core-next-folding-state-change nil pos end)))) (when force (setq pos beg next end)) (while (< pos end) (unless force - (setq next (org-fold-core-next-folding-state-change skip-specs pos end))) - ;; Move to the end of the region to be fontified. - (while (and (not (catch :found - (dolist (spec (org-fold-core-get-folding-spec 'all next)) - (when (org-fold-core-get-folding-spec-property spec :font-lock-skip) - (throw :found spec))))) - (< next end)) - (setq next (org-fold-core-next-folding-state-change nil next end))) + (setq next (org-fold-core-next-folding-state-change skip-specs pos end)) + ;; Move to the end of the region to be fontified. + (while (and (not (catch :found + (dolist (spec (org-fold-core-get-folding-spec 'all next)) + (when (org-fold-core-get-folding-spec-property spec :font-lock-skip) + (throw :found spec))))) + (< next end)) + (setq next (org-fold-core-next-folding-state-change nil next end)))) (save-excursion (font-lock-default-fontify-region pos next loudly) (save-match-data (unless (<= pos (point) next) (run-hook-with-args 'org-fold-core-first-unfold-functions pos next)))) (put-text-property pos next 'org-fold-core-fontified t) + (put-text-property pos next 'fontified t) (setq pos next))))) (defun org-fold-core-update-optimisation (beg end) -- 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