From e326597f9e83b8902a8b5cb81bb0db4e71627811 Mon Sep 17 00:00:00 2001 From: jao Date: Mon, 28 Jun 2021 03:16:30 +0100 Subject: jao-org-notes: caching tag list in disk --- lib/doc/jao-org-notes.el | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'lib/doc') diff --git a/lib/doc/jao-org-notes.el b/lib/doc/jao-org-notes.el index c690ae2..77cca9e 100644 --- a/lib/doc/jao-org-notes.el +++ b/lib/doc/jao-org-notes.el @@ -87,15 +87,27 @@ t))))) (defvar jao-org-notes--tags nil) +(defvar jao-org-notes-tags-cache-file "~/.emacs.d/cache/tags.eld") (defun jao-org-notes--update-tags () (message "Updating tags cache...") (setq jao-org-notes--tags (org-global-tags-completion-table - (directory-files-recursively jao-org-notes-dir ".*\\.org")))) + (directory-files-recursively jao-org-notes-dir ".*\\.org"))) + (with-current-buffer (find-file-noselect jao-org-notes-tags-cache-file) + (delete-region (point-min) (point-max)) + (print jao-org-notes--tags (current-buffer)) + (save-buffer))) + +(defun jao-org-notes-read-tags-cache (&optional refresh) + (interactive "P") + (when refresh (jao-org-notes--update-tags)) + (or jao-org-notes--tags + (setq jao-org-notes--tags + (read (find-file-noselect jao-org-notes-tags-cache-file))))) (defun jao-org-notes--read-tags () - (unless jao-org-notes--tags (jao-org-notes--update-tags)) + (unless jao-org-notes--tags (jao-org-notes-read-tags-cache)) (completing-read-multiple "Tags: " jao-org-notes--tags)) (defun jao-org-notes--insert-tags () -- cgit v1.2.3