commit 1471bae362e3a973d2367b3c0c6bc910feb1cba4
parent 630d727efd2e7c582dada0f34784effafab29e03
Author: andsy10 <andsy1016@gmail.com>
Date: Tue, 1 Sep 2026 05:23:08 +0800
Update my denote functions
Diffstat:
3 files changed, 43 insertions(+), 35 deletions(-)
diff --git a/lisp/init-kbd-func.el b/lisp/init-kbd-func.el
@@ -72,9 +72,8 @@ With a prefix ARG create a new *scratch* buffer."
"Find blog file use denote-file-prompt."
(interactive)
(let* ((denote-directory my-blog-directory)
- (denote-excluded-files-regexp "_about")
- (file (denote-file-prompt)))
- (find-file file)))
+ (denote-prompts '(title keywords)))
+ (call-interactively #'denote-open-or-create)))
(defun my-blog-grep ()
"Run `consult-grep' in `my-blog-directory'."
diff --git a/lisp/init-kbd.el b/lisp/init-kbd.el
@@ -137,7 +137,8 @@
(general-def
:prefix "C-c j"
"o" #'my-denote-journal-open-entry
- "n" #'denote-journal-new-or-existing-entry)
+ "n" #'denote-journal-new-or-existing-entry
+ "f" #'my-denote-journal-find-file)
;; m for media
(general-def
diff --git a/lisp/init-org.el b/lisp/init-org.el
@@ -64,7 +64,7 @@
;; show inline images
(setq org-startup-with-inline-images 'inlineimages)
- ;; hide drawer contents
+ ;; don't fold headings
(setq org-startup-folded 'showall)
;; log in drawer
@@ -101,20 +101,12 @@
:hook
(after-init . denote-rename-buffer-mode)
(dired-mode . denote-dired-mode)
- :init
+ :config
(defun my-denote-find-file (&optional arg)
- "Find file use denote-file-prompt."
+ "Find file use denote-open-or-create."
(interactive "P")
- (if arg
- (find-file (denote-file-prompt))
- (let ((denote-excluded-files-regexp "=journal\\|=archive"))
- (find-file (denote-file-prompt)))))
-
- (defun my-denote-open-metanote ()
- "Open denote metanote in org directory"
- (interactive)
- (find-file
- (concat org-directory "/20260508T220745==metanote--all-my-metanotes__org.org")))
+ (let ((denote-excluded-files-regexp (if arg nil "=journal\\|=archive")))
+ (call-interactively #'denote-open-or-create)))
(defun my-denote-find-backlink-with-location ()
"Like `denote-find-backlink-with-location' but with consult preview."
@@ -126,30 +118,30 @@
(fetcher (lambda () (xref-matches-in-files id files))))
(consult-xref fetcher nil)))
- (defun my-denote-org-find-backlink-for-heading-with-location ()
- "Like `denote-org-backlinks-for-heading' but with consult preview."
- (interactive)
- (unless (featurep 'denote-org)
- (require 'denote-org))
- (when-let* ((heading-id (or (denote-org--get-file-id-and-heading-id-or-context)
- (user-error "The current file does not have a denote identifier")))
- (files (denote-directory-files nil :omit-current :text-only))
- (fetcher (lambda () (xref-matches-in-files heading-id files))))
- (consult-xref fetcher nil)))
-
- (setq denote-directory org-directory)
- (setq denote-org-store-link-to-heading 'context
+ (setq denote-directory org-directory
+ denote-org-store-link-to-heading 'context
denote-prompts '(title signature keywords))
(setq denote-title-history nil
denote-signature-history
- '("note" "project" "fun" "wisdom" "article" "data" "metanote" "agenda" "journal" "archive")
+ '("note" "project" "fun" "wisdom" "article" "data" "agenda" "journal" "archive")
denote-known-keywords
- '("emacs"))
+ '("emacs")
+ denote-excluded-files-regexp "==archive")
(with-eval-after-load 'savehist
(add-to-list 'savehist-ignored-variables 'denote-title-history)))
;; denote-org
-(use-package denote-org)
+(use-package denote-org
+ :autoload my-denote-org-find-backlink-for-heading-with-location
+ :config
+ (defun my-denote-org-find-backlink-for-heading-with-location ()
+ "Like `denote-org-backlinks-for-heading' but with consult preview."
+ (interactive)
+ (when-let* ((heading-id (or (denote-org--get-file-id-and-heading-id-or-context)
+ (user-error "The current file does not have a denote identifier")))
+ (files (denote-directory-files nil :omit-current :text-only))
+ (fetcher (lambda () (xref-matches-in-files heading-id files))))
+ (consult-xref fetcher nil))))
;; denote-lint
(use-package denote-lint
@@ -163,10 +155,12 @@
(use-package denote-journal
:hook
(calendar-mode . denote-journal-calendar-mode)
- :init
+ :autoload (my-denote-journal-path-to-existing-entry
+ my-denote-journal-open-entry
+ my-denote-journal-find-file)
+ :config
(defun my-denote-journal-path-to-existing-entry (&optional date interval)
"Return the path of current denote journal if it exists, otherwise return nil."
- (require 'denote-journal)
(let* ((internal-date
(denote-journal--date-in-interval-p (or date (current-time)) interval))
(files (denote-journal--get-entry internal-date interval)))
@@ -180,6 +174,20 @@
(find-file (my-denote-journal-path-to-existing-entry))
(message "No journal for today yet")))
+ (defun my-denote-journal-find-file ()
+ "Find denote journal files."
+ (interactive)
+ (let* ((denote-file-prompt-extra-metadata
+ (list (cons 'category 'denote-file)
+ (cons 'group-function #'denote-file-prompt-group)
+ (cons 'affixation-function #'denote-file-prompt-affixate)
+ (cons 'display-sort-function
+ (lambda (files) (sort files #'string-greaterp)))))
+ (entry (denote-file-prompt "==journal" "Select file" :no-require-match)))
+ (if (file-directory-p entry)
+ (denote-journal-new-or-existing-entry)
+ (find-file entry))))
+
(setq denote-journal-directory (expand-file-name "journal" denote-directory))
(setq denote-journal-keyword nil)
(setq denote-journal-signature "journal")