summaryrefslogtreecommitdiffhomepage
path: root/lib/doc
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2021-06-28 03:16:30 +0100
committerjao <jao@gnu.org>2021-06-28 03:16:30 +0100
commite326597f9e83b8902a8b5cb81bb0db4e71627811 (patch)
treea1da8f70aca69976ebc13d3d5b153f4c25c04308 /lib/doc
parent6924072ad48a82431c92e830eae4c5f187cb7b62 (diff)
downloadelibs-e326597f9e83b8902a8b5cb81bb0db4e71627811.tar.gz
elibs-e326597f9e83b8902a8b5cb81bb0db4e71627811.tar.bz2
jao-org-notes: caching tag list in disk
Diffstat (limited to 'lib/doc')
-rw-r--r--lib/doc/jao-org-notes.el16
1 files changed, 14 insertions, 2 deletions
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 ()