rde: Add feature-emacs-denote. v2 APPLIED

Benoit Joly: 1
 rde: Add feature-emacs-denote.

 1 files changed, 112 insertions(+), 0 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~abcdw/rde-devel/patches/39851/mbox | git am -3
Learn more about email & git

[PATCH v2] rde: Add feature-emacs-denote. Export this patch

The existance of this patch was shared on denote's mailing list: https://lists.sr.ht/~protesilaos/denote/%3C87y1nsk4a2.fsf%40benoitj.ca%3E

I also CCed Prot on the patch.


 src/rde/features/emacs-xyz.scm | 112 +++++++++++++++++++++++++++++++++
 1 file changed, 112 insertions(+)

diff --git a/src/rde/features/emacs-xyz.scm b/src/rde/features/emacs-xyz.scm
index c384914..3e14a66 100644
--- a/src/rde/features/emacs-xyz.scm
+++ b/src/rde/features/emacs-xyz.scm
@@ -5,6 +5,7 @@
;;; Copyright © 2022 Demis Balbach <db@minikn.xyz>
;;; Copyright © 2022, 2023 Nicolas Graves <ngraves@ngraves.fr>
;;; Copyright © 2022, 2023 conses <contact@conses.eu>
;;; Copyright © 2023 Benoit Joly <benoit@benoitj.ca>
;;; This file is part of rde.
@@ -106,6 +107,7 @@

            ;; Communication
@@ -3973,6 +3975,116 @@ SPELLING-DICTIONARIES inside buffers of modes defined in FLYSPELL-HOOKS
   (values `((,f-name . ,emacs-graphviz-dot-mode)))
   (home-services-getter get-home-services)))

(define* (feature-emacs-denote
          (emacs-denote emacs-denote)
          (prefix-key "C-c N")
          (denote-directory #f)
          (denote-prompts '(title keywords))
          (denote-file-type 'org)
          (denote-date-prompt-use-org? #t)
          (denote-dired-hook 'denote-dired-mode-in-directories))
  "Configure denote, Prot's great note taking package."
  (ensure-pred file-like? emacs-denote)
  (ensure-pred string? prefix-key)
  (define (not-boolean? x) (not (boolean? x)))
  (ensure-pred not-boolean? denote-directory)
  (ensure-pred list? denote-prompts)
  (ensure-pred symbol? denote-file-type)
  (ensure-pred boolean? denote-date-prompt-use-org?)
  (ensure-pred symbol? denote-dired-hook)

  (define emacs-f-name 'denote)
  (define f-name (symbol-append 'emacs- emacs-f-name))

  (define (get-home-services config)
    "Return home services related to denote."
    (define denote (@ (gnu packages emacs-xyz) emacs-denote))
         (require 'denote))

        (setq denote-directory (expand-file-name ,denote-directory))
        (setq denote-prompts ',denote-prompts)

        (setq denote-known-keywords '())
        (setq denote-infer-keywords t)
        (setq denote-sort-keywords t)
        (setq denote-file-type ',denote-file-type)

        (setq denote-excluded-keywords-regexp nil)
        (setq denote-excluded-directories-regexp nil)

        ,@(if denote-date-prompt-use-org?
              '((setq denote-date-prompt-use-org-read-date t))
              '((setq denote-date-prompt-use-org-read-date nil)))

        ,@(if (member denote-file-type '(text markdown-toml markdown-yaml))
              '((add-hook 'find-file-hook #'denote-link-buttonize-buffer))

        (setq denote-dired-directories (list denote-directory))

        (with-eval-after-load 'dired
          (add-hook 'dired-mode-hook ',denote-dired-hook))

        (defun rde-denote-project-find-file (&optional note-dir)
          "Denote find-file using project.el's find-file.
When NOTE-DIR is not set, uses denote-directory, otherwise uses the specified
NOTE-DIR as the notes project directory. The command assumes your notes are
stored in directory understood by project.el."
          (let* ((pr (project-current t (or note-dir denote-directory)))
                 (root (project-root pr))
                 (dirs (list root)))
            (project-find-file-in nil dirs pr nil)))

        (defun rde-find-denote ()
          "find-file on denote directory"
          (find-file denote-directory))

        (defvar denote-mode-map
          (let ((map (make-sparse-keymap)))
            (define-key map (kbd "n") 'denote)
            (define-key map (kbd "N t") 'denote-type)
            (define-key map (kbd "N d") 'denote-date)
            (define-key map (kbd "N s") 'denote-subdirectory)

            (define-key map (kbd "i") 'denote-link)
            (define-key map (kbd "I") 'denote-link-add-links)
            (define-key map (kbd "b") 'denote-link-backlinks)
            (define-key map (kbd "d") 'rde-find-denote)
            (define-key map (kbd "f") 'rde-denote-project-find-file)
            (define-key map (kbd "l f") 'denote-link-find-file)
            (define-key map (kbd "l b") 'denote-link-find-backlink)
            (define-key map (kbd "r") 'denote-rename-file)
            (define-key map (kbd "R") 'denote-rename-file-using-front-matter)
          "Keymap for binding denote functionality.")

        (define-key global-map (kbd ,prefix-key) denote-mode-map)

          (let ((map dired-mode-map))
            (define-key map (kbd "C-c C-d C-i")
            (define-key map (kbd "C-c C-d C-r")

      #:keywords '(convenience)
      #:elisp-packages (list emacs-denote))))

     (name f-name)
     (values `((,f-name . ,emacs-denote)))
     (home-services-getter get-home-services)))

;;; Communication.