rde: Add feature-emacs-denote. v1 SUPERSEDED

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

 1 files changed, 104 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/39838/mbox | git am -3
Learn more about email & git

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

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

diff --git a/src/rde/features/emacs-xyz.scm b/src/rde/features/emacs-xyz.scm
index c384914..55c27b1 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,108 @@ 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 "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)
  (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))

        (let ((map mode-specific-map))
          (define-key map (kbd ,(string-append prefix-key " n")) 'denote)
          (define-key map (kbd ,(string-append prefix-key " N t")) 'denote-type)
          (define-key map (kbd ,(string-append prefix-key " N d")) 'denote-date)
          (define-key map (kbd ,(string-append prefix-key " N s")) 'denote-subdirectory)

          (define-key map (kbd ,(string-append prefix-key " i")) 'denote-link)
          (define-key map (kbd ,(string-append prefix-key " I")) 'denote-link-add-links)
          (define-key map (kbd ,(string-append prefix-key " b")) 'denote-link-backlinks)
          (define-key map (kbd ,(string-append prefix-key " d")) 'rde-find-denote)
          (define-key map (kbd ,(string-append prefix-key " f")) 'rde-denote-project-find-file)
          (define-key map (kbd ,(string-append prefix-key " l f")) 'denote-link-find-file)
          (define-key map (kbd ,(string-append prefix-key " l b")) 'denote-link-find-backlink)
          (define-key map (kbd ,(string-append prefix-key " r")) 'denote-rename-file)
          (define-key map (kbd ,(string-append prefix-key " R")) 'denote-rename-file-using-front-matter))

          (let ((map dired-mode-map))
            (define-key map (kbd "C-c C-d C-i") 'denote-link-dired-marked-notes)
            (define-key map (kbd "C-c C-d C-r") 'denote-dired-rename-marked-files))))

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

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

;;; Communication.