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

denote-file-types: lack of :date-key-regexp and :identifier-key-regexp #467

Closed
sarcom-sar opened this issue Oct 23, 2024 · 3 comments
Closed

Comments

@sarcom-sar
Copy link

Hey, I've began hacking a bit on denote and started wondering why there are no keywords for :date-key-regexp and :identifier-key-regexp in denote-file-types, but there are for :title-key-regexp and :keywords-key-regexp.

Is it a "political" decision, because ID can be easily found in filename, while the date would be a huge pain?

As for proposed implementation :identifier-key-reverse-function the defun for :title-key-reverse-function could be easily reused, while the date would need something akin to:

;; example for org
(defun denote-extract-org-date-from-front-matter (string)
  (org-read-date nil t string nil))

Sadly, this implies at least three separate functions, which might be smelly, but since we have denote-date-foo, where foo is rfc3339, iso-8601 or org-timestamp, it would still be symetrical.

@jeanphilippegg
Copy link
Contributor

jeanphilippegg commented Oct 24, 2024

The reason they were not added was that we had no use for them yet.

However, I agree that we should probably include them all. This will make
denote-file-types bigger, but this is not really an issue.

We want to include the signature in the front matter (see #366). We will need
to add the relevant functions for signature at some point. The other functions
would also be necessary if we allow changing the identifier/date under some
conditions.

I am curious: What is your use-case for them?

@sarcom-sar
Copy link
Author

sarcom-sar commented Oct 24, 2024

What is your use-case for them?

Retrieval of :date-key-regexp et al. and :identifier-key-regexp et al. would be useful when working with individual notes downstream. To be precise, it would allow to elegantly pattern match elements according to needs, like:

(let ((foo (pcase some-keyword
	     ('title :title-key-regexp)
	     ;; you know the rest
	     ('identifier :identifier-key-regexp)
	     (_ nil)))
      (file-type (denote-filetype-heuristics file)))
  (unless foo
    (re-search-forward (plist-get foo file-type) nil t)))

The other functions would also be necessary if we allow changing the identifier/date under some conditions.

To be honest, I now understand the approach to denote-file-types better. The mutable parts are retrievable from front-matter, while non-mutable parts are not. Under my understanding the :date-function made more sense as part of :date-key-regexp et al. but now I understand the code's approach.

Edit: sorry for closing and reopening, this was a missed mouse input.

@protesilaos
Copy link
Owner

I just merged the PR of @jeanphilippegg. Thank you @sarcom-sar for the discussion! Closing now.

protesilaos added a commit that referenced this issue Oct 26, 2024
This was done in issue 467: <#467>.

The commit is by Jean-Philippe Gagné Guay, which was done in pull
request 468: <#468>.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants