Emulating Howm Notes with Denote and Consult

News

Emulating Howm with Denote and Consult

What will we be trying to replicate?

  • Searching for notes in most-recent-edit order
  • Searching for notes from today, yesterday, specific date
  • Following search query links
(consult-denote-mode 1)

(let ((tab (make-hash-table :test 'equal)))
  (puthash "Foo" "foo.org" tab)
  (gethash (completing-read "Yes: "  tab) tab))

(defun denote-howmish-find-file ()
  (declare (interactive-only t))
  (interactive)
  (let* ((sorted-files (sort (mapcar (lambda (file)
                                       (cons (file-attribute-modification-time
                                              (file-attributes file))
                                             file))
                                     (denote-directory-files))
                             (lambda (left right)
                               (not
                                (time-less-p (car left)
                                             (car right))))))
         (table (make-hash-table :test 'equal))
         (options
          (mapcar (lambda (file)
                    (puthash (denote-retrieve-title-or-filename (cdr file) 'org)
                             (cdr file)
                             table))
                  sorted-files))
         (result
          (consult--read table
                         :prompt "Note: "
                         :sort nil
                         :require-match t
                         :add-history (thing-at-point 'filename)
                         :state (consult--file-preview)
                         :category 'file
                         :history '(:input consult--find-history))))
    (when result
      (find-file (gethash result table)))))

Enjoyed this stream? Explore our hands-on courses for deeper, structured learning on Guile Scheme and more.

Get the System Crafters Newsletter
Updates on open source tools, tutorials, and community projects. We'll also occasionally let you know about new courses and resources.
Name (optional)
Email Address