From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ihor Radchenko Newsgroups: gmane.emacs.devel Subject: Re: [elpa] externals/org 46da64c 4/6: org-persist.el: Fix `add-hook' priority argument Date: Tue, 19 Oct 2021 21:50:26 +0800 Message-ID: <875yttgm3h.fsf@localhost> References: <20211019125722.17993.60001@vcs0.savannah.gnu.org> <20211019125725.EA9CF209AA@vcs0.savannah.gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12389"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Oct 19 15:49:47 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mcpUw-00035B-O1 for ged-emacs-devel@m.gmane-mx.org; Tue, 19 Oct 2021 15:49:46 +0200 Original-Received: from localhost ([::1]:46734 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mcpUv-000104-O9 for ged-emacs-devel@m.gmane-mx.org; Tue, 19 Oct 2021 09:49:45 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57776) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mcpUJ-0000JM-QV for emacs-devel@gnu.org; Tue, 19 Oct 2021 09:49:10 -0400 Original-Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]:37650) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mcpUI-0008DH-4W for emacs-devel@gnu.org; Tue, 19 Oct 2021 09:49:07 -0400 Original-Received: by mail-pj1-x102a.google.com with SMTP id lk8-20020a17090b33c800b001a0a284fcc2so2154379pjb.2 for ; Tue, 19 Oct 2021 06:49:05 -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=OxAcVucS8gtQ03Dpc7rhVrL1D9jVxl0cQUJWljN1+i8=; b=hxd8RhBCp/gJ70Jtl9BkfNh2curx+4f+/fjtoIemj/SzKSLXOZD5IVu5RrEuoHDiAI 1ngBBHG/9uw4THE+G9agwbKBNxNP1twn2Z5mR3OpXqkn4fmJsxH/zG8gop1uzoqx6HVh axmJ1L547LyU8u/j2j0NVYvFTi614foDKcPfxC6CCUeyA9mTHyDSRv8gGOeuzq0WIgX8 1c4pQq+q3vibdxBGD90dmuXM/0nkLgK9HjRq3y9y6sS5Tkw/Qn4YJloF59gfbAhI15DS 0zWfETZMO51UZwRaiqFKvUHtvE7nq/99Yv/KtrbNcktse8qGwPXb07Air+FL2x1F3NQi 7Jww== 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=OxAcVucS8gtQ03Dpc7rhVrL1D9jVxl0cQUJWljN1+i8=; b=LZjJT1l49rRPE7HXvBCI4venGgCV6oX/9d6UPiilPKNzFGzh1w5grDKPI6KxprcUgU DZf1I1hLF3REzFjLtvqRTk0cpr+mXvGrM3KeUmdcjtwk6me0c5Xc3c+cs2wMIEGDh/hj wgeCbebhAxPnBw43LpadHsLS0Be0/GA6Kqofmd8HFMjS11n82e0q7WrfTChW5B0WZzAp 5P5xCznkERnyHE0Jrz/d/+kZYkodVo31aVR4PRECIWkuAmjfLvlbHK6jEyUGXx7vlw0f hGOQMzsuNZDUIKKrZCubxQe4K5689VyRDMmMIN2rzGk2CQ5qbjcGOr1GPcAIf7elCUEG OTkA== X-Gm-Message-State: AOAM531JMA8CU9tUJ1M4KYU17D1EKD6t7rwddwIQqDajw0+t8Md866Jv y2ptVL8gb4YYx0TdeKKl1JeftjWLsf0= X-Google-Smtp-Source: ABdhPJyE5ymzd27E41g3xbjtQj6VGRC1vNuxtdrgNd0ktJjsE+dXKGJ/HhyfsHvCL+QWvEpUVNCoUg== X-Received: by 2002:a17:90a:1a12:: with SMTP id 18mr7074597pjk.113.1634651344627; Tue, 19 Oct 2021 06:49:04 -0700 (PDT) Original-Received: from localhost ([103.125.234.210]) by smtp.gmail.com with ESMTPSA id kk18sm3288255pjb.8.2021.10.19.06.49.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Oct 2021 06:49:04 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::102a; envelope-from=yantar92@gmail.com; helo=mail-pj1-x102a.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:277360 Archived-At: Hi Stefan, Thanks for providing comments on this new feature! Stefan Monnier writes: >> (add-hook 'kill-emacs-hook #'org-persist-gc) >> -(add-hook 'kill-emacs-hook #'org-persist-write-all 1000) >> +(add-hook 'kill-emacs-hook #'org-persist-write-all 100) > > The docstring also says: > > Since nothing is \"always\" true, don't use 100 nor -100. > > 100 means that nothing will *ever* want to come later. I.e. you claim > to be the one and only function that will ever deserve to always be the > last one on this hook, which is rather presumptuous, I think. > AFAICT the only thing that actually matters is that it should come after > `org-persist-gc`, so even just 0.01 would be good enough. No need to > get anywhere near 100 (tho it would make sense to leave room for other > hooks that might need to come between `org-persist-gc` and > `org-persist-write-all`). Also, I'd recommend you add a comment > explaining the constraints that were considered when choosing this depth > (e.g "Make sure it comes after `org-persist-gc`"). The idea behind 100 is related to Org usage. We save buffer-local `org-element--cache' to files. It needs to be done _after_ all the possible changes in Org buffers are made. If any hook changes an Org buffer after `org-persist-write-all', the saved value will become invalid. I am not sure what can be a reasonable DEPTH value in such case. Can it be something like 1? Looking through Emacs code base, I can mostly see non-nil values as DEPTH argument. So, maybe 90? 91? Best, Ihor