summaryrefslogtreecommitdiffhomepage
path: root/lib/doc
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2021-07-24 15:15:22 +0100
committerjao <jao@gnu.org>2021-07-24 15:15:22 +0100
commita14b7b5292d98c9a0b0636e113a4e52180e2b10e (patch)
tree8785c5494e48d9407f3bc043bd0d95ded2c546ae /lib/doc
parent9797060e0b1e57c619930082c112e1fec8243fcd (diff)
downloadelibs-a14b7b5292d98c9a0b0636e113a4e52180e2b10e.tar.gz
elibs-a14b7b5292d98c9a0b0636e113a4e52180e2b10e.tar.bz2
jao-org-notes: slimmer tags persistence
Diffstat (limited to 'lib/doc')
-rw-r--r--lib/doc/jao-org-notes.el34
1 files changed, 17 insertions, 17 deletions
diff --git a/lib/doc/jao-org-notes.el b/lib/doc/jao-org-notes.el
index 24698b9..9fdca8a 100644
--- a/lib/doc/jao-org-notes.el
+++ b/lib/doc/jao-org-notes.el
@@ -89,27 +89,28 @@
(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")))
+(defun jao-org-notes--save-tags ()
(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)))
+ (let ((message-log-max nil)
+ (inhibit-message t))
+ (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
- (let ((b (find-file-noselect jao-org-notes-tags-cache-file)))
- (with-current-buffer b (goto-char (point-min)))
- (setq jao-org-notes--tags (read b)))))
+(defun jao-org-notes--read-tags-cache ()
+ (let ((b (find-file-noselect jao-org-notes-tags-cache-file)))
+ (with-current-buffer b (goto-char (point-min)))
+ (setq jao-org-notes--tags (read b))))
(defun jao-org-notes--read-tags ()
- (unless jao-org-notes--tags (jao-org-notes-read-tags-cache))
- (completing-read-multiple "Tags: " jao-org-notes--tags))
+ (unless jao-org-notes--tags (jao-org-notes--read-tags-cache))
+ (let* ((tags (completing-read-multiple "Tags: " jao-org-notes--tags))
+ (new-tags (seq-difference tags jao-org-notes--tags)))
+ (when new-tags
+ (setq jao-org--notes-tags
+ (sort (append new-tags jao-org-notes--tags) #'string<))
+ (jao-org-notes--save-tags))
+ tags))
(defun jao-org-notes--insert-tags ()
(insert "#+filetags: " (mapconcat #'identity (jao-org-notes--read-tags) " ") "\n"))
@@ -137,8 +138,7 @@
(interactive)
(when (jao-org-notes--insert-title)
(jao-org-notes--insert-date)
- (jao-org-notes--insert-tags)
- (jao-org-notes--update-tags))
+ (jao-org-notes--insert-tags))
(save-buffer)
(buffer-file-name))