Skip to content

Dynamic bibtex-completion-library-path #420

@mpedramfar

Description

@mpedramfar

Hello again! :)
Currently bibtex-completion-library-path gets a list of directories. Users can write a function that generates this list based on their need. However, (I think) in many cases, the result of this function can change based on what happens outside Emacs. For example, a user might want to include all pdf files within a directory and all of its subdirectories, except inside hidden folders and git repositories.

Currently, if a directory in bibtex-completion-library-path is deleted and no longer exists, we get an error. If a directory is added, then clearly the library will have no way of knowing this change (except by running the function again to set the value of bibtex-completion-library-path).

A solution for that is to allow bibtex-completion-library-path to get a list of directories and functions and then have a function like this:

(defun bibtex-completion-library-path ()
  "Evaluate the functions in the variable `bibtex-completion-library-path',
if there are any, and return a list of directories."
  (-flatten
   (mapcar
    (lambda (item)
      (if (stringp item)
          item
        (funcall item)))
    (-flatten bibtex-completion-library-path))))

Note that this change is completely backward compatible and doesn't break any existing setup.
I've implemented this in my setup and I'll be happy to make a pull request if this is something you'd like to implement.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions