-
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
Add database/file annotation to completions #695
Comments
It's an interesting problem.
Keep in mind, however, one can in theory have multiple global and/or local bibliographies associated with a buffer. In that situation, I would think the first option likely wouldn't be very useful, and the second could get unwieldy. But this is also tied to broader issues, like how citar merges multiple bibliographies. In theory, there should not really be duplicate entries with different keys, but we currently don't check for that. I could imagine a feature where we did, and we have some customization option on what to do with duplicates (and a related feature we may have previously discussed where one could import local entries into a global file). Also related, potentially: #645. |
While I appreciate the long-term goal / vision of having some complete method of handling duplicates. I think a very simple solution would be to simply check whether the database is included in the variable |
Right, but we have to think about the bigger picture before considering hard coding something like this. I don't use local files, for example, so I don't really want such an indicator taking up real estate. Which is why #645 may well be a better, more flexible and general, solution? WDYT? |
Sounds good. Sorry don't take my last email as being pushy. Just a statement of potential low hanging fruit. I very much appreciate all your hard work and effort on this project. It is wonderful!
Justin
|
In case it is of use to others, I wrote some helper functions which help to determine if a given citar function should prioritize global versus local bibliographies. I am sure these could be improved but they seem to work for me at the moment. ;;;###autoload
(defun jds~citar-prioritize-local-bib (fun)
"Run command FUN interactively setting citar-bibliography to local-bibliography if present."
(let ((local-latex (citar-latex-local-bib-files))
(local-org (citar-org-local-bib-files)))
(if (or local-latex local-org)
(let ((citar-bibliography (if local-latex
local-latex
local-org)))
(call-interactively fun))
(call-interactively fun))))
;;;###autoload
(defun jds~citar-prioritize-global-bib (fun)
"Run command FUN interactively setting citardybibliography to local-bibliography if present. C-u passed to fun."
;; use temp-buffer to ensure citar-bibliography does not include local bibs.
(let ((global-bib (with-temp-buffer citar-bibliography)))
(if global-bib
(let ((citar-bibliography global-bib))
(call-interactively fun))
(call-interactively fun))))
;;;###autoload
(defun jds/citar-insert-cite-prioritize-local-bib ()
"Run citar-insert-cite but pioritize local bibliographies if present, otherwise use global."
(interactive)
(jds~citar-prioritize-local-bib #'citar-insert-citation))
;;;###autoload
(defun jds/citar-open-prioritize-global-bib ()
"Run citar-open but prioritize global bibliographies if present, otherwise use local."
(interactive)
(jds~citar-prioritize-global-bib #'citar-open))
|
I pulled out a separate issue since there's really two issues here:
|
Is your feature request related to a problem? Please describe.
Yes. I have my own bibtex database which is my main / global / default database. I also frequently work with others on local databases that are in a given folder with a document we are working on. Others may add citations to the local bibtex file that are duplicates of something in my database but has a different key. This can cause problems when I am trying to figure out which of two seemingly identical (save different keys) completion candidates to use. In those cases I would prefer to just use the one that is in the local bibtex file.
Describe the solution you'd like
I think its too hard to automate the choice between two candidates but a simple option / annotation in the completions buffer would be enough. Would it be possible to show whether something is from a global file or the local file? This could simply be a ("global"/"local") indicator or simply just given the filename for where the candidate is comming from.
Describe alternatives you've considered
none. automating seems like more of a pain, indicating which file seems easiest.
The text was updated successfully, but these errors were encountered: