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

There should be "upsert" functionality #94

Open maw opened 3 years ago

maw commented 3 years ago

There should be a way to edit a note that already exists or to create a new one in one go.

I wrote a function that does this. I'll submit a PR in a few minutes.

EFLS commented 3 years ago

There should be a way to edit a note that already exists or to create a new one in one go.

Can you explain a bit more what the functionality is you aim for?

Is this similar to searching via Deft and -- when no notes are found -- creating a new note with return? (Or something similar, I don't use it.)

maw commented 3 years ago

Argh, I had no idea that that existed. AFAICT it's just like you said. But I think it's nicer to use.

I just implemented zetteldeft-upsert-and-link and zetteldeft-upsert-and-backlink. These might be more compelling; they're analogous to zetteldeft-new-file-and-link and zetteldeft-new-file-and-backlink, respectively.

EFLS commented 3 years ago

I'm still a bit in doubt whether this should be included as default Zetteldeft behaviour. Not that I don't think it is useful, but I think the use case is very specific. Can you perhaps explain a bit more how they fit in your workflow? For exapmle with -upsert-and-link. So you are typing a note, looking for one that you want to link to, notice it doesn't exist yet, and then immediately create one and link to it? Isn't this the same as -new-file-and-link? Or am I missing something?

maw commented 3 years ago

Hi, I'm sorry for taking so long to respond.

Contrary to what I posted earlier, I don't think you can do what my upsert functions do as conveniently from *Deft*. In the deft buffer, if you type a substring of a file that exists and then hit RET, it opens the first match; you need to hit C-c C-n (deft-new-file) to create a new file. This gets the job done, of course, but I think it's clunky.

I use my upsert functions most when I'm working on a note, I think of something tangentially related that I don't want to forget - but I also don't want to lose my train of thought in the current note. I find having fewer steps to create a stub note to be very helpful.

In fact, I don't even run my upsert function directly that often. Instead, I use this little wrapper function (that I definitely don't expect you to accept!):

(defun mw-zetteldeft-new-file-and-link (str)
  (interactive (list (read-string "Note title: ")))
  (progn (split-window)
         (zetteldeft-upsert-and-link str)
         (end-of-buffer)))

Anyway. If you don't want to give these functions bindings, that's fine. If, even once their problems are worked out, you don't want to include them at all, that's fine too—I have no problem maintaining them for my own use. But they've made my experience using zetteldeft much more pleasant and so I thought other people might feel the same way.

EFLS commented 3 years ago

Thanks for the additional info. I'll try to explore such a feature by using it, hopefully soon!