aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Herklotz <git@yannherklotz.com>2020-08-28 20:06:16 +0100
committerYann Herklotz <git@yannherklotz.com>2020-08-28 20:06:16 +0100
commit00753d8f1321c43fae3c0bc925b1e169c99ca001 (patch)
treec74ffbefe3591b418400233c418958c09512f492
parentd11f2ab3579ab48517ffa1be7884a639783cdbe4 (diff)
downloademacs-zettelkasten-00753d8f1321c43fae3c0bc925b1e169c99ca001.tar.gz
emacs-zettelkasten-00753d8f1321c43fae3c0bc925b1e169c99ca001.zip
Add tag files
-rw-r--r--zettelkasten.el46
1 files changed, 33 insertions, 13 deletions
diff --git a/zettelkasten.el b/zettelkasten.el
index 48576d8..aa48035 100644
--- a/zettelkasten.el
+++ b/zettelkasten.el
@@ -325,7 +325,17 @@ If PARENT is nil, it will not add a link from a PARENT."
#'(lambda (note)
(concat "- " (zettelkasten--format-link note) "\n"))
currlist))
- "\n")))
+ "\n")
+ (with-temp-buffer
+ (set-visited-file-name (concat tag ".org"))
+ (insert (concat "#+TITLE: " tag "\n\n"
+ (apply
+ 'concat
+ (mapcar
+ #'(lambda (note)
+ (concat "- " (zettelkasten--format-link note) "\n"))
+ currlist))))
+ (save-buffer))))
tags)))))
(defun zettelkasten-org-export-preprocessor (backend)
@@ -333,19 +343,29 @@ If PARENT is nil, it will not add a link from a PARENT."
Adds information such as backlinks to the `org-mode' files before
publishing."
- (let ((notes (zettelkasten--find-parents
- (zettelkasten--filename-to-id (buffer-file-name)))))
- (when notes
+ (unless (string= (zettelkasten--filename-to-id (buffer-file-name)) "")
+ (let ((notes (zettelkasten--find-parents
+ (zettelkasten--filename-to-id (buffer-file-name))))
+ (tags (zettelkasten--get-tags
+ (zettelkasten--filename-to-id (buffer-file-name)))))
(save-excursion
- (goto-char (point-max))
- (insert
- (mapconcat 'identity (append
- '("\n* Backlinks\n")
- (mapcar
- #'(lambda
- (el)
- (concat "- " (zettelkasten--format-link el) "\n"))
- notes)) ""))))))
+ (when tags
+ (goto-char (point-min))
+ (insert
+ (concat "#+begin_export html\n<div class=\"tags\"><ul>\n"
+ (mapconcat #'(lambda (el) (concat "<li><a href=\"" el
+ ".html\">" el "</a></li>\n")) tags "")
+ "</ul></div>\n#+end_export\n")))
+ (when notes
+ (goto-char (point-max))
+ (insert
+ (mapconcat 'identity (append
+ '("\n* Backlinks\n")
+ (mapcar
+ #'(lambda
+ (el)
+ (concat "- " (zettelkasten--format-link el) "\n"))
+ notes)) "")))))))
;;; ---------------------
;;; INTERACTIVE FUNCTIONS