Skip to content
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

Display local and global bibliographies simultaneously #272

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Nov 15, 2018

  1. Display local and global bibliographies simultaneously

    This makes the helm-bibtex and ivy-bibtex commands show both local and
    global bibliography entries simultaneously. Commands
    helm-bibtex-with-global-bibliography,
    helm-bibtex-with-local-bibliography, and similarly for ivy-bibtex,
    show only the global or local entries, respectively. If a file is both
    in the local and global bibliographies, it is considered a global
    bibliography file only.
    
    In helm-bibtex, the local and global entries are shown in separate
    sources. In ivy-bibtex, a different face is used for local
    entries (since ivy does not display sources separately). This face is
    customizable through the variable ivy-bibtex-local-bibliography-face.
    
    Also, a new variable bibtex-completion-reverse-order allows to
    customize whether the order of files and/or entries are reversed in
    the list of candidates (the default behavior is unchanged: entries are
    reversed but not files). Finally, ivy-bibtex accepts an additional
    argument input as is already the case for helm-bibtex.
    
    The simultaneous display of local and global entries is implemented as
    follows. The optional argument local-bib of helm-bibtex and ivy-bibtex
    is now more generallly named scope and be either 'global or 'local to
    show only the global or local entries, respectively, or nil to show
    both.
    
    This scope argument is first passed to the function
    bibtex-completion-init, which initializes the newly introduced variable
    bibtex-completion-bibliography-internal accordingly: it is a cons
    whose car and cdr are the the global and local bibliiography
    bibliographies currently in use. If scope is nil, the car of this cons
    is the value of bibtex-completion-bibliography and its cdr is the list
    returned by bibtex-completion-find-local-bibliography from which the
    files in bibtex-completion-bibliography are removed. If scope is
    'global or 'local then the cdr or car of this cons is nil,
    respectively.
    
    Then bibtex-completion-candidates parses the
    bibliography as needed and now returns a cons of two lists of entries,
    one corresponding to the car and one to the cdr of
    bibtex-completion-bibliography-internal. These two lists are used as
    candidates list in the global and local sources that helm-bibtex now
    has. Then when the selected candidates or the set of marked candidates
    is passed to an action function by helm-bibtex, a property scope is
    added to the key strings, with value 'global or 'global depending on
    the source. This is done by modifying the macro
    helm-bibtex-helmify-action.
    
    For ivy-bibtex we need to append the two lists of candidates, but the
    number of local candidates is first recorded. This allows to determine
    if a given candidate is local or global. The function
    ivy-bibtex-display-transformer uses this to fontify the local
    candidates, and the macro ivy-bibtex-ivify-action is also modified to
    propertize the key string passed to the action functions with the
    scope property (ivy does not support marking several candidates).
    
    Finally, the function bibtex-completion-get-entry1 is modified to read
    the scope property of the key string and get the entry from the
    corresponding bibliography. This is sufficient to make most action
    functions able to distinguish between local and global bibliography
    entries. The only exception is the function
    bibtex-completion-show-entry, which is modified directly. Other
    actions, such as bibtex-completion-insert-citation, simply ignore
    the scope property since they don't need to make
    this distinction.
    ericdanan committed Nov 15, 2018
    Configuration menu
    Copy the full SHA
    9edef8c View commit details
    Browse the repository at this point in the history