joostkremers / ebib

A BibTeX database manager for Emacs.
https://joostkremers.github.io/ebib/
BSD 3-Clause "New" or "Revised" License
272 stars 37 forks source link

Filters do not respect inheritance #255

Closed Hugo-Heagren closed 2 years ago

Hugo-Heagren commented 2 years ago

I have two entries:

@Book{clark00:_theor_sentien,
    keywords = {perception},
    date = {2000-03},
    timestamp = {2022-03-29 15:27:43 (BST)},
    author = {Clark, Austen},
    title = {A Theory of Sentience},
    doi = {10.1093/acprof:oso/9780198238515.001.0001},
    url = {http://dx.doi.org/10.1093/acprof:oso/9780198238515.001.0001},
    ISBN = 9780198238515,
    publisher = oup
}

@InBook{clark00:_featur_placin_hypot,
    file = {clark00:_featur_placin_hypot.pdf},
    chapter = {5},
    crossref = {clark00:_theor_sentien},
    timestamp = {2022-03-29 15:28:27 (BST)},
    title = {The Feature-Placing Hypothesis},
    pages = {164–205},
    doi = {10.1093/acprof:oso/9780198238515.003.0005},
    url = {http://dx.doi.org/10.1093/acprof:oso/9780198238515.003.0005}
}

The second inherits its author from the first, and this shows up correctly in the entry buffer if I view it. However, if I filter the database by author for "clark", only the first entry shows up. I think this is because the author isn't explicitly included in the second entry. This seems like a bug to me: the filter should respect inheritance.

joostkremers commented 2 years ago

Yeah, I agree that would make sense, at least as an option.

A filter takes the alist of each entry and uses that to check if the search-for value is contained in the entry. That avoids the overhead of having to go through ebib-db-get-field-value for each field in an entry.

Currently, ebib--filters-run-filter uses ebib-db-get-entry to get the entry. One could use ebib-get-entry instead and see if the extra overhead is noticeable or not. If it is, it could be an option that is off by default, if it isn't, it could be on by default (or not be an option at all).

joostkremers commented 2 years ago

Well, on my definitely low-end laptop and a modestly-sized .bib file (1248 entries), it doesn't seem to make filtering much slower.

I do think it should be an option, though, and I'm not entirely convinced it should be on by default. Consider the case where you are filtering on some search term in any field. If a Collection has the search term in its title, all papers in that Collection are going to turn up in the filter.

So perhaps this should be an option, and perhaps it should be possible to toggle its setting when a filter is active. (Though of course it should have a user-customisable default setting as well.)

Hugo-Heagren commented 2 years ago

So perhaps this should be an option, and perhaps it should be possible to toggle its setting when a filter is active. (Though of course it should have a user-customisable default setting as well.)

Good thinking -- this sounds like the way forward.

joostkremers commented 2 years ago

Does this do what you imagine:

https://github.com/joostkremers/ebib/tree/wip/filters-xref

Hugo-Heagren commented 2 years ago

Does this do what you imagine:

https://github.com/joostkremers/ebib/tree/wip/filters-xref

Perfect! And I especially like the interactive command to toggle the behaviour -- nice touch.

joostkremers commented 2 years ago

Merged.