Keep a single configuration block for denote

This is a gotcha of elpaca, it only allows you to specify one
use-package block for a single recipe. The last one was taking
precedence in our case.
This commit is contained in:
Vedang Manerikar 2024-12-12 23:35:07 +05:30
parent 315bea5400
commit baa0fc9e2b
2 changed files with 117 additions and 126 deletions

View file

@ -5263,6 +5263,9 @@ Prot is the developer and maintainer of this package.
;; `org-mode-map', `markdown-mode-map', and/or `text-mode-map'. ;; `org-mode-map', `markdown-mode-map', and/or `text-mode-map'.
("C-c d j" . denote-journal-extras-new-entry) ("C-c d j" . denote-journal-extras-new-entry)
("C-c d s" . denote-sort-dired) ("C-c d s" . denote-sort-dired)
;; Bindings to personal functions (defined below)
("C-c d p m" . vedang/denote-publishing-extras-new-microblog-entry)
("C-c d p b" . vedang/denote-publishing-extras-new-blog-entry)
:map text-mode-map :map text-mode-map
("C-c d B" . denote-backlinks) ("C-c d B" . denote-backlinks)
("C-c d b" . denote-find-backlink) ("C-c d b" . denote-find-backlink)
@ -5333,10 +5336,10 @@ Prot is the developer and maintainer of this package.
,#+filetags: %3$s ,#+filetags: %3$s
,#+date: %2$s ,#+date: %2$s
,#+identifier: %4$s ,#+identifier: %4$s
\n")) \n")
(defun vedang/denote-publishing-extras-new-blog-entry (&optional date) (defun vedang/denote-publishing-extras-new-blog-entry (&optional date)
"Create a new blog entry. "Create a new blog entry.
With optional DATE as a prefix argument, prompt for a date. If With optional DATE as a prefix argument, prompt for a date. If
`denote-date-prompt-use-org-read-date' is non-nil, use the Org `denote-date-prompt-use-org-read-date' is non-nil, use the Org
@ -5345,18 +5348,18 @@ Prot is the developer and maintainer of this package.
When called from Lisp DATE is a string and has the same format as When called from Lisp DATE is a string and has the same format as
that covered in the documentation of the `denote' function. It that covered in the documentation of the `denote' function. It
is internally processed by `denote-parse-date'." is internally processed by `denote-parse-date'."
(interactive (list (when current-prefix-arg (denote-date-prompt)))) (interactive (list (when current-prefix-arg (denote-date-prompt))))
(let ((internal-date (denote-parse-date date)) (let ((internal-date (denote-parse-date date))
(denote-directory (file-name-as-directory (expand-file-name "published" denote-directory)))) (denote-directory (file-name-as-directory (expand-file-name "published" denote-directory))))
(denote (denote
(denote-title-prompt) (denote-title-prompt)
'("draft") '("draft")
nil nil date nil nil date
;; See YASnippet ;; See YASnippet
"fullblog"))) "fullblog")))
(defun vedang/denote-publishing-extras-new-microblog-entry (&optional date) (defun vedang/denote-publishing-extras-new-microblog-entry (&optional date)
"Create a new microblog entry. "Create a new microblog entry.
Set the title of the new entry according to the value of the user option Set the title of the new entry according to the value of the user option
`denote-journal-extras-title-format'. `denote-journal-extras-title-format'.
@ -5367,18 +5370,18 @@ Prot is the developer and maintainer of this package.
When called from Lisp DATE is a string and has the same format as When called from Lisp DATE is a string and has the same format as
that covered in the documentation of the `denote' function. It that covered in the documentation of the `denote' function. It
is internally processed by `denote-parse-date'." is internally processed by `denote-parse-date'."
(interactive (list (when current-prefix-arg (denote-date-prompt)))) (interactive (list (when current-prefix-arg (denote-date-prompt))))
(let ((internal-date (denote-parse-date date)) (let ((internal-date (denote-parse-date date))
(denote-directory (file-name-as-directory (expand-file-name "published" denote-directory)))) (denote-directory (file-name-as-directory (expand-file-name "published" denote-directory))))
(denote (denote
(denote-journal-extras-daily--title-format internal-date) (denote-journal-extras-daily--title-format internal-date)
'("draft" "microblog") '("draft" "microblog")
nil nil date nil nil date
;; See YASnippet ;; See YASnippet
"microblog"))) "microblog")))
(defun vedang/denote-link-ol-get-id () (defun vedang/denote-link-ol-get-id ()
"Get the CUSTOM_ID of the current entry. "Get the CUSTOM_ID of the current entry.
If the entry already has a CUSTOM_ID, return it as-is, else create a new If the entry already has a CUSTOM_ID, return it as-is, else create a new
one. one.
@ -5388,51 +5391,44 @@ Prot is the developer and maintainer of this package.
This function is based on `denote-link-ol-get-id', with minor This function is based on `denote-link-ol-get-id', with minor
modifications." modifications."
(interactive) (interactive)
(let* ((pos (point)) (let* ((pos (point))
(id (org-entry-get pos "CUSTOM_ID")) (id (org-entry-get pos "CUSTOM_ID"))
(created (org-entry-get pos "CREATED"))) (created (org-entry-get pos "CREATED")))
(if (and (stringp id) (string-match-p "\\S-" id)) (if (and (stringp id) (string-match-p "\\S-" id))
id id
(setq id (org-id-new "h")) (setq id (org-id-new "h"))
(org-entry-put pos "CUSTOM_ID" id)) (org-entry-put pos "CUSTOM_ID" id))
(when (not created) (when (not created)
(setq created (format-time-string (org-time-stamp-format t t) (current-time))) (setq created (format-time-string (org-time-stamp-format t t) (current-time)))
(org-entry-put pos "CREATED" created)) (org-entry-put pos "CREATED" created))
id)) id))
(defun vedang/denote--split-luhman-sig (signature) (defun vedang/denote--split-luhman-sig (signature)
"Split numbers and letters in Luhmann-style SIGNATURE string." "Split numbers and letters in Luhmann-style SIGNATURE string."
(replace-regexp-in-string (replace-regexp-in-string
"\\([a-zA-Z]+?\\)\\([0-9]\\)" "\\1=\\2" "\\([a-zA-Z]+?\\)\\([0-9]\\)" "\\1=\\2"
(replace-regexp-in-string (replace-regexp-in-string
"\\([0-9]+?\\)\\([a-zA-Z]\\)" "\\1=\\2" "\\([0-9]+?\\)\\([a-zA-Z]\\)" "\\1=\\2"
signature))) signature)))
(defun vedang/denote--pad-sig (signature) (defun vedang/denote--pad-sig (signature)
"Create a new signature with padded spaces for all components" "Create a new signature with padded spaces for all components"
(combine-and-quote-strings (combine-and-quote-strings
(mapcar (mapcar
(lambda (x) (lambda (x)
(string-pad x 5 32 t)) (string-pad x 5 32 t))
(split-string (vedang/denote--split-luhman-sig signature) "=" t)) (split-string (vedang/denote--split-luhman-sig signature) "=" t))
"=")) "="))
(defun vedang/denote-sort-for-signatures (sig1 sig2) (defun vedang/denote-sort-for-signatures (sig1 sig2)
"Return non-nil if SIG1 is smaller that SIG2. "Return non-nil if SIG1 is smaller that SIG2.
Perform the comparison with `string<'." Perform the comparison with `string<'."
(string< (vedang/denote--pad-sig sig1) (vedang/denote--pad-sig sig2))) (string< (vedang/denote--pad-sig sig1) (vedang/denote--pad-sig sig2)))
(use-package denote
:ensure t
:bind
( :map global-map
;; Bindings to personal functions (defined above)
("C-c d p m" . vedang/denote-publishing-extras-new-microblog-entry)
("C-c d p b" . vedang/denote-publishing-extras-new-blog-entry))
:config
(setq denote-sort-signature-comparison-function #'vedang/denote-sort-for-signatures)) (setq denote-sort-signature-comparison-function #'vedang/denote-sort-for-signatures))
#+end_src #+end_src
*** The =unravel-study.el= integration between Consult and Denote (~consult-denote~) *** The =unravel-study.el= integration between Consult and Denote (~consult-denote~)

View file

@ -42,6 +42,9 @@
;; `org-mode-map', `markdown-mode-map', and/or `text-mode-map'. ;; `org-mode-map', `markdown-mode-map', and/or `text-mode-map'.
("C-c d j" . denote-journal-extras-new-entry) ("C-c d j" . denote-journal-extras-new-entry)
("C-c d s" . denote-sort-dired) ("C-c d s" . denote-sort-dired)
;; Bindings to personal functions (defined below)
("C-c d p m" . vedang/denote-publishing-extras-new-microblog-entry)
("C-c d p b" . vedang/denote-publishing-extras-new-blog-entry)
:map text-mode-map :map text-mode-map
("C-c d B" . denote-backlinks) ("C-c d B" . denote-backlinks)
("C-c d b" . denote-find-backlink) ("C-c d b" . denote-find-backlink)
@ -112,10 +115,10 @@
#+filetags: %3$s #+filetags: %3$s
#+date: %2$s #+date: %2$s
#+identifier: %4$s #+identifier: %4$s
\n")) \n")
(defun vedang/denote-publishing-extras-new-blog-entry (&optional date) (defun vedang/denote-publishing-extras-new-blog-entry (&optional date)
"Create a new blog entry. "Create a new blog entry.
With optional DATE as a prefix argument, prompt for a date. If With optional DATE as a prefix argument, prompt for a date. If
`denote-date-prompt-use-org-read-date' is non-nil, use the Org `denote-date-prompt-use-org-read-date' is non-nil, use the Org
@ -124,18 +127,18 @@
When called from Lisp DATE is a string and has the same format as When called from Lisp DATE is a string and has the same format as
that covered in the documentation of the `denote' function. It that covered in the documentation of the `denote' function. It
is internally processed by `denote-parse-date'." is internally processed by `denote-parse-date'."
(interactive (list (when current-prefix-arg (denote-date-prompt)))) (interactive (list (when current-prefix-arg (denote-date-prompt))))
(let ((internal-date (denote-parse-date date)) (let ((internal-date (denote-parse-date date))
(denote-directory (file-name-as-directory (expand-file-name "published" denote-directory)))) (denote-directory (file-name-as-directory (expand-file-name "published" denote-directory))))
(denote (denote
(denote-title-prompt) (denote-title-prompt)
'("draft") '("draft")
nil nil date nil nil date
;; See YASnippet ;; See YASnippet
"fullblog"))) "fullblog")))
(defun vedang/denote-publishing-extras-new-microblog-entry (&optional date) (defun vedang/denote-publishing-extras-new-microblog-entry (&optional date)
"Create a new microblog entry. "Create a new microblog entry.
Set the title of the new entry according to the value of the user option Set the title of the new entry according to the value of the user option
`denote-journal-extras-title-format'. `denote-journal-extras-title-format'.
@ -146,18 +149,18 @@
When called from Lisp DATE is a string and has the same format as When called from Lisp DATE is a string and has the same format as
that covered in the documentation of the `denote' function. It that covered in the documentation of the `denote' function. It
is internally processed by `denote-parse-date'." is internally processed by `denote-parse-date'."
(interactive (list (when current-prefix-arg (denote-date-prompt)))) (interactive (list (when current-prefix-arg (denote-date-prompt))))
(let ((internal-date (denote-parse-date date)) (let ((internal-date (denote-parse-date date))
(denote-directory (file-name-as-directory (expand-file-name "published" denote-directory)))) (denote-directory (file-name-as-directory (expand-file-name "published" denote-directory))))
(denote (denote
(denote-journal-extras-daily--title-format internal-date) (denote-journal-extras-daily--title-format internal-date)
'("draft" "microblog") '("draft" "microblog")
nil nil date nil nil date
;; See YASnippet ;; See YASnippet
"microblog"))) "microblog")))
(defun vedang/denote-link-ol-get-id () (defun vedang/denote-link-ol-get-id ()
"Get the CUSTOM_ID of the current entry. "Get the CUSTOM_ID of the current entry.
If the entry already has a CUSTOM_ID, return it as-is, else create a new If the entry already has a CUSTOM_ID, return it as-is, else create a new
one. one.
@ -167,50 +170,42 @@ timestamp as well.
This function is based on `denote-link-ol-get-id', with minor This function is based on `denote-link-ol-get-id', with minor
modifications." modifications."
(interactive) (interactive)
(let* ((pos (point)) (let* ((pos (point))
(id (org-entry-get pos "CUSTOM_ID")) (id (org-entry-get pos "CUSTOM_ID"))
(created (org-entry-get pos "CREATED"))) (created (org-entry-get pos "CREATED")))
(if (and (stringp id) (string-match-p "\\S-" id)) (if (and (stringp id) (string-match-p "\\S-" id))
id id
(setq id (org-id-new "h")) (setq id (org-id-new "h"))
(org-entry-put pos "CUSTOM_ID" id)) (org-entry-put pos "CUSTOM_ID" id))
(when (not created) (when (not created)
(setq created (format-time-string (org-time-stamp-format t t) (current-time))) (setq created (format-time-string (org-time-stamp-format t t) (current-time)))
(org-entry-put pos "CREATED" created)) (org-entry-put pos "CREATED" created))
id)) id))
(defun vedang/denote--split-luhman-sig (signature) (defun vedang/denote--split-luhman-sig (signature)
"Split numbers and letters in Luhmann-style SIGNATURE string." "Split numbers and letters in Luhmann-style SIGNATURE string."
(replace-regexp-in-string (replace-regexp-in-string
"\\([a-zA-Z]+?\\)\\([0-9]\\)" "\\1=\\2" "\\([a-zA-Z]+?\\)\\([0-9]\\)" "\\1=\\2"
(replace-regexp-in-string (replace-regexp-in-string
"\\([0-9]+?\\)\\([a-zA-Z]\\)" "\\1=\\2" "\\([0-9]+?\\)\\([a-zA-Z]\\)" "\\1=\\2"
signature))) signature)))
(defun vedang/denote--pad-sig (signature) (defun vedang/denote--pad-sig (signature)
"Create a new signature with padded spaces for all components" "Create a new signature with padded spaces for all components"
(combine-and-quote-strings (combine-and-quote-strings
(mapcar (mapcar
(lambda (x) (lambda (x)
(string-pad x 5 32 t)) (string-pad x 5 32 t))
(split-string (vedang/denote--split-luhman-sig signature) "=" t)) (split-string (vedang/denote--split-luhman-sig signature) "=" t))
"=")) "="))
(defun vedang/denote-sort-for-signatures (sig1 sig2) (defun vedang/denote-sort-for-signatures (sig1 sig2)
"Return non-nil if SIG1 is smaller that SIG2. "Return non-nil if SIG1 is smaller that SIG2.
Perform the comparison with `string<'." Perform the comparison with `string<'."
(string< (vedang/denote--pad-sig sig1) (vedang/denote--pad-sig sig2))) (string< (vedang/denote--pad-sig sig1) (vedang/denote--pad-sig sig2)))
(use-package denote
:ensure t
:bind
( :map global-map
;; Bindings to personal functions (defined above)
("C-c d p m" . vedang/denote-publishing-extras-new-microblog-entry)
("C-c d p b" . vedang/denote-publishing-extras-new-blog-entry))
:config
(setq denote-sort-signature-comparison-function #'vedang/denote-sort-for-signatures)) (setq denote-sort-signature-comparison-function #'vedang/denote-sort-for-signatures))
(use-package consult-denote (use-package consult-denote