From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id gMWMGVqIBmZb5gAA62LTzQ:P1 (envelope-from ) for ; Fri, 29 Mar 2024 10:22:34 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id gMWMGVqIBmZb5gAA62LTzQ (envelope-from ) for ; Fri, 29 Mar 2024 10:22:34 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=hKmpbycW; dmarc=pass (policy=none) header.from=posteo.net; 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-Seal: i=1; s=key1; d=yhetil.org; t=1711704153; a=rsa-sha256; cv=none; b=sOs87bsAYwsbprVqHxHz6fWY0loKJVRv7bYCv6xYcSp2F6BJaSiHTnZPgeRtsxvuohDASq hu5lgbBgkwFWZEqSXIidme4Vk3ZZTAYq37a93FWMhObV71xorb/6ZB7PzaxdGnNHwkaWrb Ye/jj3gcfWuDydB/xTP1ThTR9fmjmO5Ct3x02qI1q2eTzD4yRmgpMTdReZWeoL/Tk8HQYM VXHY08MGeeciuIbySMH44zb8ZZzenjPn8rqPFcIfNWtDQM1q3LCMDa8c6HhE8gQLYboEgt dnvT/goZF3iAxkvRpkzvuRBWeqpalsY6UT/H4yyDWlFfoOpVf1NuQcrd2uuwmQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=hKmpbycW; dmarc=pass (policy=none) header.from=posteo.net; 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=1711704153; 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:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=wyi/9liXQJVCgwGiCx+nI54y3x937aXe25Rfxa1F24w=; b=QhLdOe40Q84RVXl8W5FAtNcXcUcUUftVy5QzgjD7qhowD/68OoMWLOqxHMy5RpHWGbGsrm l9e4ktl1FBc6XIVL6Zx+qZ7gXtR8fE2YyRWIkn2GxwiZouFQotI8qZtL5BjG5m+Yhgip6A FWR+kacbl5BbY0586hySGsViMvuZCdUazH2557zLDJvnJnTNVIQqUCKjHD5+AKcZJqd+Nm kTmMvmWcqFKH+eq85xDGqyWBeamhMoBAvwAqpDgUSbTqlOR78Ghp804HV54W0Rqanrtoij DXg8kdr+xwgHnWdry6LJ4LDNNqXoI8vlmj/cNBhTpyrkdYrmMtXzE6T397zT1w== 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 43F1A1F289 for ; Fri, 29 Mar 2024 10:22:32 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rq8QU-00073J-6C; Fri, 29 Mar 2024 05:21:30 -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 1rq8QR-00070u-QV for emacs-orgmode@gnu.org; Fri, 29 Mar 2024 05:21:27 -0400 Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rq8QO-00071O-VO for emacs-orgmode@gnu.org; Fri, 29 Mar 2024 05:21:27 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id ED30F240103 for ; Fri, 29 Mar 2024 10:21:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1711704081; bh=BeKiN2BJ5eOSkhOX/M6QxIwOyprByLbn+7BY+d/bIjA=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=hKmpbycWt8Le1XGFRs37vFm+yWtEtujexGfsNJ0GSisf/4QeAORDy9YVim0oQY02R sOg7tpD3b570HWxY3kFvFnjIGmrtaBPSzzgZQ5YV9pb4FBTK/+rXoLIyvIdnTJDwK4 IhYXdtCvVycb3Q/NC9kVMOfvebub2I3/dYxuR+IPMjGcIbitXwm6GyU1/3M9VFvGYY brSSacQPj+F8yWhoGfncdJuq8uuDkUf6To8HaA+rdaV9wFRwSvVgO+3RYNtmEOkypy qgsExGYr/TOZJCq6EvpzGGrbhhB6koZS3con8yEnOyz+EbMb1Bppo7M0sq2y7dmU0m 4Vm1ipKfM5xLA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4V5Zf80XS1z6tm4 for ; Fri, 29 Mar 2024 10:21:19 +0100 (CET) From: Ihor Radchenko To: emacs-orgmode@gnu.org Subject: [PATCH] ox-publish: Do not store :title, :date, and :index in project cache Date: Fri, 29 Mar 2024 09:21:23 +0000 Message-ID: <878r21fl64.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.66; envelope-from=yantar92@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Spam-Score: -8.05 X-Migadu-Queue-Id: 43F1A1F289 X-Migadu-Scanner: mx12.migadu.com X-Migadu-Spam-Score: -8.05 X-TUID: xWAbRnFbW24N --=-=-= Content-Type: text/plain This patch fixes situation when :title/:date/:index properties are stored in the project cache and then not updated even when the corresponding project file does get updated. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-ox-publish-Do-not-store-title-date-and-index-in-proj.patch >From 06bd6a52686ec868a336d89a0ceef4359a71fb14 Mon Sep 17 00:00:00 2001 Message-ID: <06bd6a52686ec868a336d89a0ceef4359a71fb14.1711703988.git.yantar92@posteo.net> From: Ihor Radchenko Date: Fri, 29 Mar 2024 12:17:09 +0300 Subject: [PATCH] ox-publish: Do not store :title, :date, and :index in project cache * lisp/ox-publish.el (org-publish-transient-cache): New transient cache, used just during current publish process. (org-publish-initialize-cache): (org-publish-reset-cache): Initialize the transient cache. (org-publish-cache-set-file-property): Add new optional argument to store property in transient cache rather than persistent cache. (org-publish-cache-get-file-property): Query transient cache first. (org-publish-collect-index): (org-publish-find-title): (org-publish-find-date): Use transient cache. This commit fixes situation when :title/:date/:index properties are not updated even when the corresponding project file does get updated. --- lisp/ox-publish.el | 49 +++++++++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/lisp/ox-publish.el b/lisp/ox-publish.el index 9bfd333a4..3e526b813 100644 --- a/lisp/ox-publish.el +++ b/lisp/ox-publish.el @@ -56,6 +56,9 @@ (defvar org-publish-cache nil "This will cache timestamps and titles for files in publishing projects. Blocks could hash sha1 values here.") +(defvar org-publish-transient-cache nil + "This will cache information during publishing process.") + (defvar org-publish-after-publishing-hook nil "Hook run each time a file is published. Every function in this hook will be called with two arguments: @@ -867,7 +870,7 @@ (defun org-publish-find-title (file project) (org-no-properties (org-element-interpret-data parsed-title)) (file-name-nondirectory (file-name-sans-extension file))))) - (org-publish-cache-set-file-property file :title title))))) + (org-publish-cache-set-file-property file :title title nil 'transient))))) (defun org-publish-find-date (file project) "Find the date of FILE in PROJECT. @@ -892,7 +895,8 @@ (defun org-publish-find-date (file project) (org-time-string-to-time value)))))) ((file-exists-p file) (file-attribute-modification-time (file-attributes file))) - (t (error "No such file: \"%s\"" file))))))))) + (t (error "No such file: \"%s\"" file))))) + nil 'transient)))) (defun org-publish-sitemap-default-entry (entry style project) "Default format for site map ENTRY, as a string. @@ -1048,7 +1052,8 @@ (defun org-publish-collect-index (output _backend info) (replace-regexp-in-string "\\[[0-9]+%\\]\\|\\[[0-9]+/[0-9]+\\]" "" (org-element-property :raw-value parent))))))))) - info)))) + info)) + nil 'transient)) ;; Return output unchanged. output) @@ -1251,6 +1256,9 @@ (defun org-publish-initialize-cache (project-name) (error "Org publish timestamp: %s is not a directory" org-publish-timestamp-directory)) + (unless org-publish-transient-cache + (setq org-publish-transient-cache (make-hash-table :test #'equal))) + (unless (and org-publish-cache (string= (org-publish-cache-get ":project:") project-name)) (let* ((cache-file @@ -1274,6 +1282,8 @@ (defun org-publish-reset-cache () (message "%s" "Resetting org-publish-cache") (when (hash-table-p org-publish-cache) (clrhash org-publish-cache)) + (when (hash-table-p org-publish-transient-cache) + (clrhash org-publish-transient-cache)) (setq org-publish-cache nil)) (defun org-publish-cache-file-needs-publishing @@ -1319,16 +1329,22 @@ (defun org-publish-cache-file-needs-publishing included-files-mtime)))))) (defun org-publish-cache-set-file-property - (filename property value &optional project-name) + (filename property value &optional project-name transient) "Set the VALUE for a PROPERTY of file FILENAME in publishing cache to VALUE. Use cache file of PROJECT-NAME. If the entry does not exist, it -will be created. Return VALUE." +will be created. Return VALUE. + +When TRANSIENT is non-nil, store value in transient cache that is only +maintained during the current publish process." ;; Evtl. load the requested cache file: (when project-name (org-publish-initialize-cache project-name)) - (let ((pl (org-publish-cache-get filename))) - (if pl (progn (plist-put pl property value) value) - (org-publish-cache-get-file-property - filename property value nil project-name)))) + (if transient + (puthash (cons filename property) value + org-publish-transient-cache) + (let ((pl (org-publish-cache-get filename))) + (if pl (progn (plist-put pl property value) value) + (org-publish-cache-get-file-property + filename property value nil project-name))))) (defun org-publish-cache-get-file-property (filename property &optional default no-create project-name) @@ -1337,13 +1353,14 @@ (defun org-publish-cache-get-file-property or DEFAULT, if the value does not yet exist. Create the entry, if necessary, unless NO-CREATE is non-nil." (when project-name (org-publish-initialize-cache project-name)) - (let ((properties (org-publish-cache-get filename))) - (cond ((null properties) - (unless no-create - (org-publish-cache-set filename (list property default))) - default) - ((plist-member properties property) (plist-get properties property)) - (t default)))) + (or (gethash (cons filename property) org-publish-transient-cache) + (let ((properties (org-publish-cache-get filename))) + (cond ((null properties) + (unless no-create + (org-publish-cache-set filename (list property default))) + default) + ((plist-member properties property) (plist-get properties property)) + (t default))))) (defun org-publish-cache-get (key) "Return the value stored in `org-publish-cache' for key KEY. -- 2.44.0 --=-=-= Content-Type: text/plain -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at --=-=-=--