aboutsummaryrefslogtreecommitdiff
path: root/.emacs.d/rul-lisp/packages/rul-write.el
diff options
context:
space:
mode:
authorRaúl Benencia <id@rbenencia.name>2023-07-27 07:55:41 -0700
committerRaúl Benencia <id@rbenencia.name>2023-07-27 07:55:41 -0700
commit1dbdde9d5c392bf2042ee36abe37b9ec6cd86b2d (patch)
tree7967afc6f40c9b3583ad3609941141356f10fbde /.emacs.d/rul-lisp/packages/rul-write.el
parent4ee690114a3fc68c7f58897a9ba1b44ef902a3e5 (diff)
emacs: rul-write and rul-completion
Diffstat (limited to '.emacs.d/rul-lisp/packages/rul-write.el')
-rw-r--r--.emacs.d/rul-lisp/packages/rul-write.el38
1 files changed, 38 insertions, 0 deletions
diff --git a/.emacs.d/rul-lisp/packages/rul-write.el b/.emacs.d/rul-lisp/packages/rul-write.el
new file mode 100644
index 0000000..933473d
--- /dev/null
+++ b/.emacs.d/rul-lisp/packages/rul-write.el
@@ -0,0 +1,38 @@
+(use-package denote
+ :ensure t
+ :config
+ (setq denote-infer-keywords t)
+ (setq denote-sort-keywords t)
+ (setq denote-file-type 'text)
+ (setq denote-excluded-directories-regexp nil)
+ (setq denote-allow-multi-word-keywords nil)
+ (setq denote-link-fontify-backlinks t)
+
+ (add-hook 'find-file-hook #'denote-link-buttonize-buffer)
+ (add-hook 'dired-mode-hook #'denote-dired-mode-in-directories)
+
+ (let ((map global-map))
+ (define-key map (kbd "C-c n j") #'rul/denote-journal)
+ (define-key map (kbd "C-c n n") #'denote))
+)
+
+(defun rul/denote-journal ()
+ "Create an entry tagged 'journal' with the date as its title.
+If a journal for the current day exists, visit it. If multiple
+entries exist, prompt with completion for a choice between them.
+Else create a new file."
+ (interactive)
+ (let* ((today (format-time-string "%A %e %B %Y"))
+ (string (denote-sluggify today))
+ (files (denote-directory-files-matching-regexp string)))
+ (cond
+ ((> (length files) 1)
+ (find-file (completing-read "Select file: " files nil :require-match)))
+ (files
+ (find-file (car files)))
+ (t
+ (denote
+ today
+ '("journal"))))))
+
+(provide 'rul-write)
nihil fit ex nihilo