From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.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 8CIVMv4MYGLQQQAAbAwnHQ (envelope-from ) for ; Wed, 20 Apr 2022 15:39:10 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id CEkOMv4MYGLNGAAA9RJhRA (envelope-from ) for ; Wed, 20 Apr 2022 15:39:10 +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 5FD5617995 for ; Wed, 20 Apr 2022 15:39:10 +0200 (CEST) Received: from localhost ([::1]:44320 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhAY1-0000Fy-GA for larch@yhetil.org; Wed, 20 Apr 2022 09:39:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36984) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhAKH-0004Bv-F0 for emacs-orgmode@gnu.org; Wed, 20 Apr 2022 09:24:58 -0400 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]:54051) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhAKE-0003bR-3v for emacs-orgmode@gnu.org; Wed, 20 Apr 2022 09:24:55 -0400 Received: by mail-pj1-x1036.google.com with SMTP id bx5so1916029pjb.3 for ; Wed, 20 Apr 2022 06:24:53 -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=9EjZKHycTOqjTN70YaSgnDJCIZcC21Fi8NuMBcg9lU0=; b=qeMhKIpYgZD862KOsWe/s4yHTNQf3WhGpiHzQ4GU5TJ1NutIH9aGE0MjgJGZCOFCMK QCN+0cQoa8TMyeSak85aSMBFqkJwTw5Toy2C9hi/k8LAvdBbwV1ldyk+qQLmDYCLbcMr cUV+HK6CxNtqKAmdBW4m8rGjwtFUzqkxpu/gW8nP5dtHf9jx1+QGOOvc4u8yNdD0HsUf KA4JBWinGulBO8cwbfVMkM5H1CUr5T+jFaH4wdkooqTEvCt8FdMzeszKtOn+VTEDiPNm j+tPbmU5ADih2SaBDHQVpk9Ce6axd37x8G+SWs31Ul0w96dL72GYZNRJz349XBF3b7ag qV+g== 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=9EjZKHycTOqjTN70YaSgnDJCIZcC21Fi8NuMBcg9lU0=; b=WpbtH8CoAZPvabE+mICZxGE6EqDFhaZ1jBlKxqHjSpHMfOnO1MubjtiITOrc+kKhPc 2p/eCWp1y7KrOgX95syWZG9a256FG3Df68pdOAIZbvV2rflWiEBVhFiUzS3Y6ZHDxCZa 853NAUzIaFdsTDBJy0/nzE3XUHbNmTmHjm6hVaL+RKrSx6Y8Lu9F4idO/ndr1yANoHZv 0JqhjLILd9tIb6YpEL9iOQ8cgKmWCAl7CM61wrbHzk3On0LGlA14OuKj4SEo29T/j2/z +AqvCa7+bhG+KcMfpRhX9V7FNdl9QJvH7lkC7shyi7K6gnxFmVut6yn916yFxTKZcNDv ch2w== X-Gm-Message-State: AOAM5339q13VOFWkoRBf55jvjwXO9rdRZg4NdcgGAvVBGMYDBVe6UsPx VD9ZAcAabJx1Hi+yR5iwX8N8rpj+DlsMZw== X-Google-Smtp-Source: ABdhPJzz9l0ZcxdQzLi+26x4qAiW4c1dKdogmzR7Mrv3DVEcpZZCb3XCCAYSK9IMKv8eflQTcmtKsg== X-Received: by 2002:a17:90b:4d10:b0:1d2:bb47:d171 with SMTP id mw16-20020a17090b4d1000b001d2bb47d171mr4496437pjb.74.1650461092406; Wed, 20 Apr 2022 06:24:52 -0700 (PDT) Received: from localhost ([64.32.23.62]) by smtp.gmail.com with ESMTPSA id j13-20020a17090a840d00b001ca89db9e6esm20241690pjn.19.2022.04.20.06.24.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 06:24:51 -0700 (PDT) From: Ihor Radchenko To: emacs-orgmode@gnu.org Subject: [PATCH v2 14/38] Support extra org-fold optimisations for huge buffers In-Reply-To: References: Message-Id: <6905c740f03e122a1e09faa4dfd648175b7e2196.1650460489.git.yantar92@gmail.com> Date: Wed, 20 Apr 2022 21:25:45 +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=1650461950; 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=9EjZKHycTOqjTN70YaSgnDJCIZcC21Fi8NuMBcg9lU0=; b=DB9cgBlJVsbfnSgWtTriRdplAvz0rofm/KxP1A8m613nLg+EDzz7DUdrGlWU1ZDxRRlzej C784BXZT0VZ606ZWcPmjaEfgUhAXL9naBjh8KkjXt+640cMt080Uc5QinEfxnZPZFaNrEP dxee54v0J4afrrQBt3ajUaacDkxe3gXtqGj86NRImfN4jIe84GsGW/r8uI9tyC4uDjLpVW LVl92k4ZHvNC7fx04RDWOIjiTCyyHCVXB9XRURgglXEU4s0F+fE7f6vXkni0LBJEOPOdpi 1WjbdfgzPkWU1BnirfdB/lvP7nPUuvNku1l/xdOC6NBNW88RkPrVc1aHwgo/ug== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1650461950; a=rsa-sha256; cv=none; b=R59xBQmQnKPBd+/Y6EUxyrBLxsqy/GwmPRURLDnvgbmODQIpIKS2ubVuFn2mz9+6cvzGqh fR6SisYMuN4xwuWB1JL+DxHTdQ9nchPeZ9vA419z5y3Dppp3T/UMTbsPm5Eo1SRsDKU7fK AyMhpnVKpMF87vYjb/yD8BNVl4p5AX8rWplR3QhIe88KSpFo1VRj6nzQhyPEwxb2vMtGHn gG5apJSMbp6x5mfmn4av1ziqeojBX4zuAUCNwfMVMOKIuNFLO/GDtWh1HYHPIFluSXXck7 uXmGemyqG22c75LwR7SVDCuh039dMUTWZKLyjIO86AAhk18iIeK2bMpmZidKYw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=qeMhKIpY; 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=qeMhKIpY; 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: 5FD5617995 X-Spam-Score: -3.04 X-Migadu-Scanner: scn1.migadu.com X-TUID: D7tftuNdyVyL --- lisp/org.el | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index ca0a99681..f5936b67c 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -5788,6 +5788,7 @@ (defun org-unfontify-region (beg end &optional _maybe_loudly) '(mouse-face t keymap t org-linked-text t invisible t intangible t org-emphasis t)) + (org-fold-core-update-optimisation beg end) (org-remove-font-lock-display-properties beg end))) (defconst org-script-display '(((raise -0.3) (height 0.7)) @@ -6158,7 +6159,11 @@ (defun org-get-heading (&optional no-tags no-todo no-priority no-comment) (org-back-to-heading t) (let ((case-fold-search nil)) (looking-at org-complex-heading-regexp) - (let ((todo (and (not no-todo) (match-string 2))) + ;; When using `org-fold-core--optimise-for-huge-buffers', + ;; returned text may be invisible. Clear it up. + (save-match-data + (org-fold-core-remove-optimisation (match-beginning 0) (match-end 0))) + (let ((todo (and (not no-todo) (match-string 2))) (priority (and (not no-priority) (match-string 3))) (headline (pcase (match-string 4) (`nil "") @@ -6169,6 +6174,8 @@ (defun org-get-heading (&optional no-tags no-todo no-priority no-comment) "" h)) (h h))) (tags (and (not no-tags) (match-string 5)))) + ;; Restore cleared optimisation. + (org-fold-core-update-optimisation (match-beginning 0) (match-end 0)) (mapconcat #'identity (delq nil (list todo priority headline tags)) " ")))))) @@ -6185,18 +6192,21 @@ (defun org-heading-components () (save-excursion (org-back-to-heading t) (when (let (case-fold-search) (looking-at org-complex-heading-regexp)) - (list (length (match-string 1)) - (org-reduced-level (length (match-string 1))) - (match-string-no-properties 2) - (and (match-end 3) (aref (match-string 3) 2)) - (match-string-no-properties 4) - (match-string-no-properties 5))))) + (org-fold-core-remove-optimisation (match-beginning 0) (match-end 0)) + (prog1 + (list (length (match-string 1)) + (org-reduced-level (length (match-string 1))) + (match-string-no-properties 2) + (and (match-end 3) (aref (match-string 3) 2)) + (match-string-no-properties 4) + (match-string-no-properties 5)) + (org-fold-core-update-optimisation (match-beginning 0) (match-end 0)))))) (defun org-get-entry () "Get the entry text, after heading, entire subtree." (save-excursion (org-back-to-heading t) - (buffer-substring (point-at-bol 2) (org-end-of-subtree t)))) + (filter-buffer-substring (point-at-bol 2) (org-end-of-subtree t)))) (defun org-edit-headline (&optional heading) "Edit the current headline. -- 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