From 207d9f8c392111e2aed500f5439481eebc14af27 Mon Sep 17 00:00:00 2001 From: Daniel Borchmann Date: Tue, 30 Apr 2024 08:30:07 +0200 Subject: [PATCH] Remove statistics cookies from Org links MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Those cookies are correct when the link is inserted, but subsequently gets updated (usually to `[0/0]`) when the statistics cookie is updated in the Org item where the link is placed — removing any meaning from this cookie. It's thus better to not have it at all, I think. --- init.el | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/init.el b/init.el index 9c6405c..0a7330e 100644 --- a/init.el +++ b/init.el @@ -865,7 +865,23 @@ (member x org-stored-links--new)) org-stored-links--original)))) - org-store-link--return-value)))) + org-store-link--return-value)) + + (define-advice org-link-make-string (:around + (orig-func link &optional description) + db/org--remove-statistics-cookie-from-link-descriptions) + "Remove statistics cookies from link descriptions. + +Such cookies get updated with other statistics cookies and +quickly loose their meaning." + (funcall orig-func + link + (when description + ;; Taken from `org--get-outline-path-1': + (org-trim + (replace-regexp-in-string + "\\[[0-9]+%\\]\\|\\[[0-9]+/[0-9]+\\]" "" + description))))))) (use-package ol-bbdb :config (add-to-list 'org-bbdb-anniversary-format-alist