summaryrefslogtreecommitdiff
path: root/lisp/ss-denote.el
blob: 65b9b534f0b7cef5d69342040e06d320b58cd782 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
;;; ss-denote.el --- Denote configuration -*- lexical-binding: t; -*-

;;; Commentary:

;; Durable note creation and Denote integration.

;;; Code:

(require 'ss-core)

(declare-function denote-keywords-prompt "denote")
(declare-function denote-org-capture "denote")
(declare-function denote-org-capture-with-prompts "denote")

(defun ss-denote-capture-in-directory (directory &optional keywords &rest prompts)
  "Start a Denote Org capture in DIRECTORY with KEYWORDS and PROMPTS.
If PROMPTS is empty, rely on `denote-prompts'."
  (let* ((prompt-for-keywords (memq :keywords prompts))
         (directory (ss-require-existing-directory directory))
         (denote-directory directory)
         (denote-use-directory (unless (memq :subdirectory prompts) directory))
         (denote-use-keywords
          (if prompt-for-keywords
              (delete-dups (append keywords (denote-keywords-prompt)))
            keywords)))
    (if prompts
        (denote-org-capture-with-prompts
         (memq :title prompts)
         nil
         (memq :subdirectory prompts)
         (memq :date prompts)
         (memq :template prompts))
      (denote-org-capture))))

(defun ss-denote-setup ()
  "Initialize Denote."
  (use-package denote
    :ensure t
    :after org
    :config
    (setq denote-directory ss-org-directory
          denote-known-keywords '("project")
          denote-prompts '(title keywords)
          denote-org-capture-specifiers "%?")
    (denote-rename-buffer-mode 1)))

(provide 'ss-denote)

;;; ss-denote.el ends here