EFLS / zetteldeft

A Zettelkasten system! Or rather, some functions on top of the emacs deft package.
https://efls.github.io/zetteldeft
GNU General Public License v3.0
394 stars 42 forks source link

Feature request: Queue random note for spontaneous recall and related notes #53

Closed erictleung closed 4 years ago

erictleung commented 4 years ago

In using org-brain, I really liked its wander feature, which brings a note randomly. It essentially randomly samples the notes created and displays it. This can be helpful as an informal 'quiz' of your knowledge base or at least refresh your memory that the particular note exists. From there you can edit it with current knowledge or link it to other notes.

I'd like to propose a similar function in zetteldeft.

I've created a simple function to accomplish this.

(defun etl/zetteldeft-ergodic ()
  "Find a random file in the deft directory."
  (interactive)
  (deft-filter-clear)
  (kill-new
   (zetteldeft--lift-id
    (nth (random (length (directory-files deft-directory)))
         (directory-files deft-directory)))
    nil)
  (deft-filter-yank))

I'd run this after being in the deft buffer. So after running deft (C-c d d), I'd run the above etl/zetteldeft-ergodic which will randomly retrieve a random note ID and search for it.

Thanks for creating this package.

EFLS commented 4 years ago

Ooh that's nice. I'm working on a sort of Zetteldeft knowledge base (in Zetteldeft of course) and will make sure to include this piece of code.

I think it is nice to provide these as snippets that people can use as they see fit, rather than features included in the code itself, as I don't think it is core functionality. At least for now.

erictleung commented 4 years ago

A knowledge base sounds like a great idea. I look forward to reading it. And thanks for your consideration. Plug-and-play snippets sounds really nice actually.

EFLS commented 4 years ago

I've changed your code a bit, so that it

  1. picks a note from those deft knows about (since directory-files will also return . and .., and won't respect deft-recursive, deft-ignore-files-regex etc.)
  2. opens the deft buffer automatically (but will still work when you're already at it)
  3. sets the filter directly, rather than via yank

I've called it zetteldeft-wander. Really nice idea! Maybe I should consider including it in the main code after all...

(defun zetteldeft-wander ()
  "Wander through `zetteldeft' notes.
Search `deft' for a random `zetteldeft' id."
  (interactive)
  (switch-to-buffer deft-buffer)
  (let ((all-files (deft-find-all-files-no-prefix)))
    (deft-filter
      (zetteldeft--lift-id
        (nth (random (length all-files))
           all-files)))))
EFLS commented 4 years ago

This is now included in https://github.com/EFLS/zd-tutorial, which serves as both a knowledge base and a tutorial. More discussion in #64.

Feel free to leave a comment if you think this should be part of the core feature set.