-
Notifications
You must be signed in to change notification settings - Fork 54
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
feat: add new format-entry function, note template #274
Conversation
This function is formatting entries for non-column display.
221173f
to
d713c8d
Compare
1fcde13
to
2bd5965
Compare
4170af2
to
05c7d9e
Compare
05c7d9e
to
783cef4
Compare
Is it adding the (defun my-ba-get-entry (key)
"Return the cached entry for KEY."
(if (or (eq 'uninitialized bibtex-actions--candidates-cache)
(eq 'uninitialized bibtex-actions--local-candidates-cache))
(message "Something is wrong; your library is not initialized.")
(cddr (seq-find
(lambda (entry)
(string-equal key (cadr entry)))
(bibtex-actions--get-candidates))))) and the calling it with a key and it seems to return the entry as expected. I am setting up at a new place so won't do much anytime soon but I will try to track down infinite recursion bug if I can reproduce it. |
No; the reverse. Adding that statement, along with changing the load order of some functions, originally "fixed" it. I don't see why it should make any difference, and in retrospect, the check didn't make sense there (and the "or" should be "and").
OK. |
I added this check back (which again "fixed" it), but also added a "FIX" comment, because I don't think this check should be necessary if everything else is correctly coded. |
@bdarcus, does changing (defun bibtex-actions--get-candidates (&optional force-rebuild-cache)
"Get the cached candidates.
If the cache is unintialized, this will load the cache.
If FORCE-REBUILD-CACHE is t, force reload the cache."
(when force-rebuild-cache
(bibtex-actions-refresh force-rebuild-cache))
(when (eq 'uninitialized bibtex-actions--candidates-cache)
(bibtex-actions-refresh nil 'global))
(when (eq 'uninitialized bibtex-actions--local-candidates-cache)
(bibtex-actions-refresh nil 'local))
(seq-concatenate 'list
bibtex-actions--local-candidates-cache
bibtex-actions--candidates-cache)) helps with the recursion blowing up? There is certainly a bug as currently the I don't see why it would cause infinite recursion instead of a type error though, unless it is something that happens during I would test and do a pr but I need to setup my laptop since the last one went with my last job. |
Alas, no. |
@bdarcus I figured out the problem, but I don't have a good solution yet. It is the use of This has me thinking that |
Maybe get-entry (or just however to get the necessary data) needs to grab from the candidate cddr then?
If that's possible; not sure it is.
|
Something like this would be my preferred solution. Where |
Looks like the only field files-for-key is currently accessing (indirectly) is |
Yes, but I think generally the set of functions that depend on the caches being populated should be fairly limited, I guess ideally only to interactive functions. |
One issue, the details of which I'm forgetting such that I'm unsure if it applies here, is that completing-read throws out non-candidate data at a certain point. |
Occurs to me also that it might be wise at some to add some tests, that we can also hook up to the CI. |
I think we already take care of it to find the key corresponding to the formatted string. I was thinking of changing this (cl-loop for choice in chosen
;; Collect citation keys of selected candidate(s).
collect (or (cadr (assoc choice candidates))
;; Key is literal coming from embark, just pass it on
choice)) to something like this (seq-map (lambda (choice) (seq-find
(lambda (cand) (cdr (or (equal choice (car cand))
;; For embark, find the cand with correct key
(equal choice (cadr cand)))))
candidates))
chosen) Basically change |
I briefly looked at #274 and it looks good. This is almost unrelated and the purpose is not to go through candidate list too many times. I think it cleaner if we have a separation of the part of the library that does caching and the rest of the library interacts with cached candidates only through |
Yes, ideally they really should be cleanly-separated. |
Per #269, this adds a template for formatting new note titles, and a function to handle it.
It has occurred to me maybe this function should be called
format-entry
, and the original one renamedformat-entry-columns
?