-
Notifications
You must be signed in to change notification settings - Fork 55
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
Local value predicates for bib data variables #831
Conversation
Set the `safe-local-variable' property to a predicate which returns non-nil only for a list only of strings (or an empty list) for `citar-bibliography', `citar-library-paths' and `citar-notes-paths'.
Thanks @Hugo-Heagren. This seems straightforward enough, but I'm unsure if there are possible unintended consequences, so asked @roshanshariff for a review. |
This looks like the same feature as #800, right? Is there a reason the existing local bibliography detection doesn't work using the |
This comment was marked as off-topic.
This comment was marked as off-topic.
Maybe we should add something on this to the wiki and/or README instead?
|
Yes! Sorry, I hadn't seen that.
I didn't know about this, thanks for drawing my attention to it. It's very clever, but there are two problems with this approach (which, to be fair, both lie outside of the standard applications of packages like citar):
I think a local variable is an easy way around this. |
@Hugo-Heagren, thanks for clarifying your use cases. That makes sense! I propose a slightly different approach that is hopefully more explicit and less magical:
My thought is that having a separate variable makes things easier to understand and document, and the mode can be enabled or disabled explicitly with a command. What do you think? |
@roshanshariff ok thanks. So to be clear your proposed solution involves adding a new mode, and a new custom variable, and the new custom variable functions in the same way as the standard I find this much more confusing than just setting one existing variable locally. Moreover I'm confused about what it adds: the two variables seem to function in exactly the same way, except that one is local-only and the other is global-only?Emacs has a robust (and very flexible) system for this sort of thing which (it seems to me) is designed specifcally to avoid such duplication. Why should we reinvent it within citar? (to be fair, we may just be disagreeing about about how people 'should' use Emacs -- I'm of the opinion that generally anything should be locally safe unless there is a good reason for it not to be. If you really don't like my proposal, I'm happy to just set it up manually myself in my init file and leave this PR?) |
@Hugo-Heagren, I should've been more explicit about my reasons: Citar internally treats local bibliographies differently from global ones. It tracks which buffers own each local bibliography, and evicts them from the cache when no buffers need them. Currently global bibliographies always remain in the cache, though that might change at some point. So if you make That's why I suggested having a separate variable which augments the local bibliography auto-detection mechanism. Apart from this, there are a few other considerations:
I hope that explains my suggestions, which I think handle a broader set of use cases. I also don't think the complexity is excessive, since (apart from docstrings) we only really need (defcustom citar-local-bibliography :type '(repeat file) :safe t :local t)
(define-minor-mode citar-local-only-mode) along with some changes to |
@roshanshariff aha, I understand now -- than you for explaining. I agree -- you approach makes more sense, and I'll close this PR. Thank you again! |
I've started using a .bib file to hold data for my CV. When I'm working on the TeX in the CV folder, I the only bib data I want is that in my cv.bib. I never really want to acces it otherwise. So it's useful if these variables can be set locally (using .dir-locals). To avoid having to confirm that they're safe every time, I've added a sensible test for safety.