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

zetteldeft-insert-list-links fails if no UID in filename #105

Open mediapathic opened 3 years ago

mediapathic commented 3 years ago

I've found a behavior in zetteldeft that is a bug for my use cases, but may not be given the way you designed things.

The function zetteldeft-insert-list-links works perfectly well with filenames that are formed as you intended, i.e. with a UID in the filename. However, with filenames that do not have a UID, the function aborts with an error.

I realize that my use case here is, again, not as you have this designed. But I would argue that there may be more people than me who would want to use this functionality. Between the work I've done and the suggestions you've made here, I believe I'm 90% to a way of operating with bare filenames. And I think we agree that a non-UID file naming scheme is not optimal, but it happens often enough that I'd like to be able to tell people that it's usable.

Basically I'm saying-- if this is an easy fix I think you should do it, and if it's not, don't bother.

I'll see if I can figure out some code for this, but I have little faith in my lisp abilities to do so. Is this worth you looking at?

EFLS commented 3 years ago

The Zetteldeft approach does indeed assume IDs for each note. That said, it shouldn't be too hard to prevent errors such as these. In fact, I remember running into this as well and thought it was fixed already. I'll look into it when I have some time.

EFLS commented 3 years ago

Eh, so I took a look already. The following code should work even when filenames don't contain an ID. It overwrites a helper function. Let me know if it works for you.

(defun zetteldeft--list-entry-file-link (zdFile)
  "Insert ZDFILE as list entry."
  (let ((id (zetteldeft--lift-id (file-name-base zdFile))))
    (insert zetteldeft-list-prefix)
    (when id
          (insert zetteldeft-link-indicator
                  id
                  zetteldeft-link-suffix
                  " "))
    (insert (zetteldeft--lift-file-title zdFile)
            "\n")))
mediapathic commented 3 years ago

It sort of works. It no longer errors on the creation of the list, but only some of the links are created. Here is a sample, with links made visible in org mode:

 - [[202102120951]] A Garde
 - [[202102150638]] Zetteldeft docs
 - [[202009240000]] ---
 - tags:  #newsletter #jobsheet #MOC #active
 - 000 org-index
 - tags: #active #gigs #MOC #writing

As far as I can tell:

I hope this is useful and not just random noise!

EFLS commented 3 years ago

I think the issue here is with how the titles are extracted from each of these notes. This is done via deft-parse-title, so if Deft misinterprets the title, it will be mangled in the lists as well.