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

Add file/note data to candidates #595

Merged
merged 2 commits into from
May 18, 2022
Merged

Add file/note data to candidates #595

merged 2 commits into from
May 18, 2022

Conversation

bdarcus
Copy link
Contributor

@bdarcus bdarcus commented May 17, 2022

This PR has two commits; both to facilitate programmatic filtering etc of candidates.

Add cons cells to candidate entries

First, when creating candidates, it adds cons cells for files or notes, I can drop this commit if we prefer the more general solution below, but I don't believe the operations here (pushing cons to a list) are expensive.

(("has-note" . t) ; this PR adds this and next line
 ("has-file" . t)
 ("doi" . "10.1111/j.1540-6040.2009.01269.x")
 ("journaltitle" . "City \\& Community")
 ("date" . "2009-03-01")
 ("author" . "Zukin, Sharon and Trujillo, Valerie and Frase, Peter and Jackson, Danielle and Recuber, Tim and Walker, Abraham")
 ("title" . "New Retail Capital and Neighborhood Change: Boutiques and Gentrification in {{New York City}}")
 ("=type=" . "article")
 ("=key=" . "zukin2009"))

To filter:

(seq-filter 
  (lambda (entry) 
    (assoc "has-note" entry)) 
  (citar--get-candidates))

Add filter arg to citar--get-candidates

Second, more generally, it adds an optional filter to citar--get-candidates:

(citar--get-candidates t (citar-has-note))

FWIW, this is actually slower than the first option (though that's not surprising; this is running dynamically, while the former is static cached data).

ELISP> (benchmark-run-compiled 10 (citar--get-candidates nil (citar-has-note)))
(0.036507296 0 0.0)

ELISP> (benchmark-run-compiled 10 (seq-filter 
    (lambda (e) 
      (assoc "has-note" e)) 
  (citar--get-candidates)))
(0.004006728 0 0.0)

See Vidianos-Giannitsis/zetteldesk.el#5

Close #594

When creating candidates, add cons cells for files or notes, to
facilitate programmatic access.

Close #594
@bdarcus bdarcus force-pushed the note-file-cands branch from f79eb1e to d19a9a3 Compare May 18, 2022 00:48
@bdarcus bdarcus merged commit 23f4ec7 into main May 18, 2022
@bdarcus bdarcus deleted the note-file-cands branch May 18, 2022 11:58
@bdarcus
Copy link
Contributor Author

bdarcus commented May 18, 2022

@localauthor - this may or may not be useful for zk.

@bdarcus bdarcus mentioned this pull request Jun 5, 2022
4 tasks
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

Successfully merging this pull request may close these issues.

How to get a list of keys for references that have notes?
1 participant