Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mediapathic opened this issue Feb 17, 2021 · 4 comments
Open

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

mediapathic opened this issue Feb 17, 2021 · 4 comments
Labels
bug Something isn't working

Comments

@mediapathic
Copy link

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
Copy link
Owner

EFLS commented Feb 17, 2021

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 EFLS added the bug Something isn't working label Feb 17, 2021
@EFLS
Copy link
Owner

EFLS commented Feb 17, 2021

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
Copy link
Author

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:

  • Well formed UID filenames work find
  • the third item on the list has the filename "202009240000 Designing GTD PM System.org". The three dashes are the first line of the file (a YAML metadata delimiter). So this tells me it did not find a title because there's a space between the UID and the rest, rather than dashes
  • the one after those, that just lists tags, has the filename "100 --Area-- Newsletter.md". That's just a weird thing to regex against, I know, but everything here that just list first lines have approxmiately that format. Again the "tags" line is just the first line of the document.
  • "000 org-index" is getting that from an org #+title field, not the filename, which I suppose makes sense.

I hope this is useful and not just random noise!

@EFLS
Copy link
Owner

EFLS commented Feb 18, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants