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 ms5.migadu.com with LMTPS id WCl5I4Oyx2IfnQAAbAwnHQ (envelope-from ) for ; Fri, 08 Jul 2022 06:28:51 +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 +IFYI4Oyx2L/0wAA9RJhRA (envelope-from ) for ; Fri, 08 Jul 2022 06:28:51 +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 064B710B80 for ; Fri, 8 Jul 2022 06:28:51 +0200 (CEST) Received: from localhost ([::1]:44538 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9fbm-0000nb-6E for larch@yhetil.org; Fri, 08 Jul 2022 00:28:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36364) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9fXB-0003IU-7e for emacs-orgmode@gnu.org; Fri, 08 Jul 2022 00:24:06 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]:46592) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o9fX9-00015l-0B for emacs-orgmode@gnu.org; Fri, 08 Jul 2022 00:24:04 -0400 Received: by mail-pf1-x429.google.com with SMTP id a15so22519371pfv.13 for ; Thu, 07 Jul 2022 21:24:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=W2bQBbmMLkVkCyLWQqTV3xO3GouJ0cqIHx4qTv8onCg=; b=nHpHv7JQ0PSm9ZTFpWj4pGUZF2es5Ikfqqqf9Z20gUarp80gGFCHTyY0ld7IVJf14/ VqXMEzZW0a3yGUNVX2bzeLqJjgI/IW29kg7pucNq6Gzi32OmcQkAqu0PTH8mR5N5n934 tiPGaPnm11oS1d9mdkql7aNKAJxQNdUS5nogPJbyMB6LeI6S7n24Zv9evPzeClb82GW9 dUso+80fF+8d0novL3wsL3hwNfj8wd2g19gwZMqGVcQZBmGAy0abo9FuOLiPFFNp70Wg n6wIIvmroymrp0atdgfB+R9wXCjwEft4OVQiEVBt2oj/TW8yByR0+jGQ/PByA/4+6awT gREA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=W2bQBbmMLkVkCyLWQqTV3xO3GouJ0cqIHx4qTv8onCg=; b=jfwq5fUDhtuRApwbIcFgXvAx+Wo/idSXooeRUTyV0KZYJhzeAzBr5m5LgMaCyU/G/9 FMs1Yu2TZ3qyMWf8oX+wUE2GERfc4F9cN40Y9Kp6RuuytXPwGZ2IQddaiZZgJFH5Njxl tTgc2pcjBXDYBy2WcgRhiVKLzN9AgwvilAu/0d40Y/LnzGm0ecWRcglpZWvSTsiIYIas ElOHA9UzdL/N5s75FxpMdbz1fhYonn4FGqAtILnMDDVpAuU4+jaY3g3g/tG5ivy7gqKR RJdJZBMho8NbH233KGeUj9rboxuRpdwfwOgBCTIOW5/6jKebiPnt9K5dUs4a4KO0zPms OEIQ== X-Gm-Message-State: AJIora+jYpNz1n5ozeFEAyl25MuiCFIlctFTBbawCmfFB9eudri51zid S8ejvVoHmzM/X+3louMAeR6c9vsICLMfOYtu/Ps= X-Google-Smtp-Source: AGRyM1vQ8Ayv2Fe8AS1FZb3PFlkD9mkB/HhPqE5gUCPxMYfHR+hQeQReF5cVjOct32uvpoPfshXdqg== X-Received: by 2002:a05:6a00:1c94:b0:527:c49a:3249 with SMTP id y20-20020a056a001c9400b00527c49a3249mr1676488pfw.18.1657254241499; Thu, 07 Jul 2022 21:24:01 -0700 (PDT) Received: from localhost ([155.94.207.39]) by smtp.gmail.com with ESMTPSA id c126-20020a621c84000000b005252defb016sm27827690pfc.122.2022.07.07.21.23.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 21:24:00 -0700 (PDT) From: Ihor Radchenko To: Gregor Zattler Cc: emacs-orgmode@gnu.org Subject: Re: Warning (org-element-cache): org-element--cache: Warning( *helm-org-rifle-fontify*): Unregistered buffer modifications detected. Resetting. In-Reply-To: <87tu7tdljo.fsf@no.workgroup> References: <87tu7tdljo.fsf@no.workgroup> Date: Fri, 08 Jul 2022 12:25:07 +0800 Message-ID: <877d4o44f0.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::429; envelope-from=yantar92@gmail.com; helo=mail-pf1-x429.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=1657254531; h=from:from:sender:sender: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:dkim-signature; bh=W2bQBbmMLkVkCyLWQqTV3xO3GouJ0cqIHx4qTv8onCg=; b=Nz9tBFB3yaqekViIom7Sn1MUehDcCExQMC2X9ExoSBBxmfSP+92m91o7YbX1xI5CnTgqE5 vNkCrj/ngCEvQTZKQhjNLkPmr79NHHqIKF5alrzVGCExBFJfeG5jaf3gcgqB15eaWGUBCG ne5X/S1S33YDz/gZcSkcr58sFsOy0MYc3bmEdwZw238qCKNH5ogUX4djctzFuxETnrbQWX Z86YbWJpLBAUvGj/Q1adcPeOE/AKT3qVQ3CoMB2Uox9tfgmQw0epNomYLmzdPwZW3Ocn+j 8yUoIeZ6/Y/gqfp+FRVmAnEFETa+hWQv8aaNpPKQ0kvCGnXm6w4rp6zUvB/d1w== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1657254531; a=rsa-sha256; cv=none; b=hRiPrJJfJlD/naRaYXMcp0jkW4Cf4wGAhfQHSGuWXSQpiYJCWOEex91cBahpd4m+YEWcHG 9+Y5jiX9QmJgknmptdtshUCkAYbCezbU1WkRR544vXhs6Wsdg8f6ojodIHVBPAWsylOP21 U1vEit3sdwiFri7zLxGPySfPMtCMKSSjElT7lUwRAZ6qNzgCr7siLY4QhTayNxPS11Dvem XmGGrLsbFYYZ4QMBYW0f4kE1TV/ckm9VRg1LNolpcYsAKGJmSwMYq5uxFBxxhEsWoFonvL 47gdLKENNrbx+akgRxcSd35a5tbjsuyFYoYhypFnWzl1zLjC3kQ/hmEpMy9Kjw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=nHpHv7JQ; 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.44 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=nHpHv7JQ; 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: 064B710B80 X-Spam-Score: -3.44 X-Migadu-Scanner: scn1.migadu.com X-TUID: z8YXTV9FYrNz --=-=-= Content-Type: text/plain Gregor Zattler writes: > Dear org-mode developers, Ihor, I got these warnings > immediately after I purged ~/.cache/org-persist, started > emacs/org-mode and tried to find some node via org-rifle. > Backtrace: > org-element-cache diagnostics( *helm-org-rifle-fontify*): nil is about to modify text: warning t > org-element-cache diagnostics( *helm-org-rifle-fontify*): nil is about to modify text: warning t > ... Thanks for reporting! The backtrace is very helpful. Can you please try the attached patch and let me know if it helps? Best, Ihor --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-org-element-Do-not-try-to-sync-element-cache-in-the-.patch >From 6bd34950429b37b4db8471015edc84d949bc40db Mon Sep 17 00:00:00 2001 Message-Id: <6bd34950429b37b4db8471015edc84d949bc40db.1657254235.git.yantar92@gmail.com> From: Ihor Radchenko Date: Fri, 8 Jul 2022 12:22:16 +0800 Subject: [PATCH] org-element: Do not try to sync element cache in the middle of a change * lisp/org-element.el (org-element--cache-sync): Do not sync between `before-change-functions' and `after-change-functions'. Fixes https://orgmode.org/list/87tu7tdljo.fsf@no.workgroup --- lisp/org-element.el | 122 +++++++++++++++++++++++--------------------- 1 file changed, 63 insertions(+), 59 deletions(-) diff --git a/lisp/org-element.el b/lisp/org-element.el index 8964770f0..d0345410d 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -5946,67 +5946,71 @@ (defun org-element--cache-sync (buffer &optional threshold future-change offset) actually submitted." (when (buffer-live-p buffer) (with-current-buffer (or (buffer-base-buffer buffer) buffer) - ;; Check if the buffer have been changed outside visibility of - ;; `org-element--cache-before-change' and `org-element--cache-after-change'. - (if (/= org-element--cache-last-buffer-size (buffer-size)) - (progn - (org-element--cache-warn - "Unregistered buffer modifications detected. Resetting. + ;; Do not sync when, for example, in the middle of + ;; `combine-change-calls'. See the commentary inside + ;; `org-element--cache-active-p'. + (when (org-element--cache-active-p) + ;; Check if the buffer have been changed outside visibility of + ;; `org-element--cache-before-change' and `org-element--cache-after-change'. + (if (/= org-element--cache-last-buffer-size (buffer-size)) + (progn + (org-element--cache-warn + "Unregistered buffer modifications detected. Resetting. If this warning appears regularly, please report the warning text to Org mode mailing list (M-x org-submit-bug-report). The buffer is: %s\n Current command: %S\n Backtrace:\n%S" - (buffer-name (current-buffer)) - this-command - (when (and (fboundp 'backtrace-get-frames) - (fboundp 'backtrace-to-string)) - (backtrace-to-string (backtrace-get-frames 'backtrace)))) - (org-element-cache-reset)) - (let ((inhibit-quit t) request next) - (setq org-element--cache-interrupt-C-g-count 0) - (when org-element--cache-sync-timer - (cancel-timer org-element--cache-sync-timer)) - (let ((time-limit (time-add nil org-element-cache-sync-duration))) - (catch 'org-element--cache-interrupt - (when org-element--cache-sync-requests - (org-element--cache-log-message "Syncing down to %S-%S" (or future-change threshold) threshold)) - (while org-element--cache-sync-requests - (setq request (car org-element--cache-sync-requests) - next (nth 1 org-element--cache-sync-requests)) - (org-element--cache-process-request - request - (when next (org-element--request-key next)) - threshold - (unless threshold time-limit) - future-change - offset) - ;; Re-assign current and next requests. It could have - ;; been altered during phase 1. - (setq request (car org-element--cache-sync-requests) - next (nth 1 org-element--cache-sync-requests)) - ;; Request processed. Merge current and next offsets and - ;; transfer ending position. - (when next - ;; The following requests can only be either phase 1 - ;; or phase 2 requests. We need to let them know - ;; that additional shifting happened ahead of them. - (cl-incf (org-element--request-offset next) (org-element--request-offset request)) - (org-element--cache-log-message - "Updating next request offset to %S: %s" - (org-element--request-offset next) - (let ((print-length 10) (print-level 3)) (prin1-to-string next))) - ;; FIXME: END part of the request only matters for - ;; phase 0 requests. However, the only possible - ;; phase 0 request must be the first request in the - ;; list all the time. END position should be - ;; unused. - (setf (org-element--request-end next) (org-element--request-end request))) - (setq org-element--cache-sync-requests - (cdr org-element--cache-sync-requests))))) - ;; If more requests are awaiting, set idle timer accordingly. - ;; Otherwise, reset keys. - (if org-element--cache-sync-requests - (org-element--cache-set-timer buffer) - (setq org-element--cache-change-warning nil) - (setq org-element--cache-sync-keys-value (1+ org-element--cache-sync-keys-value)))))))) + (buffer-name (current-buffer)) + this-command + (when (and (fboundp 'backtrace-get-frames) + (fboundp 'backtrace-to-string)) + (backtrace-to-string (backtrace-get-frames 'backtrace)))) + (org-element-cache-reset)) + (let ((inhibit-quit t) request next) + (setq org-element--cache-interrupt-C-g-count 0) + (when org-element--cache-sync-timer + (cancel-timer org-element--cache-sync-timer)) + (let ((time-limit (time-add nil org-element-cache-sync-duration))) + (catch 'org-element--cache-interrupt + (when org-element--cache-sync-requests + (org-element--cache-log-message "Syncing down to %S-%S" (or future-change threshold) threshold)) + (while org-element--cache-sync-requests + (setq request (car org-element--cache-sync-requests) + next (nth 1 org-element--cache-sync-requests)) + (org-element--cache-process-request + request + (when next (org-element--request-key next)) + threshold + (unless threshold time-limit) + future-change + offset) + ;; Re-assign current and next requests. It could have + ;; been altered during phase 1. + (setq request (car org-element--cache-sync-requests) + next (nth 1 org-element--cache-sync-requests)) + ;; Request processed. Merge current and next offsets and + ;; transfer ending position. + (when next + ;; The following requests can only be either phase 1 + ;; or phase 2 requests. We need to let them know + ;; that additional shifting happened ahead of them. + (cl-incf (org-element--request-offset next) (org-element--request-offset request)) + (org-element--cache-log-message + "Updating next request offset to %S: %s" + (org-element--request-offset next) + (let ((print-length 10) (print-level 3)) (prin1-to-string next))) + ;; FIXME: END part of the request only matters for + ;; phase 0 requests. However, the only possible + ;; phase 0 request must be the first request in the + ;; list all the time. END position should be + ;; unused. + (setf (org-element--request-end next) (org-element--request-end request))) + (setq org-element--cache-sync-requests + (cdr org-element--cache-sync-requests))))) + ;; If more requests are awaiting, set idle timer accordingly. + ;; Otherwise, reset keys. + (if org-element--cache-sync-requests + (org-element--cache-set-timer buffer) + (setq org-element--cache-change-warning nil) + (setq org-element--cache-sync-keys-value (1+ org-element--cache-sync-keys-value))))))))) (defun org-element--cache-process-request (request next-request-key threshold time-limit future-change offset) -- 2.35.1 --=-=-=--