Git Product home page Git Product logo

citar-capf's Introduction

NOTE: Citar-capf is being merged into citar per this commit. All further development will be a part of the citar repo.

citar-capf provides a completion-at-point function (via the minor-mode citar-capf-mode) for citations in latex, org, and markdown (pandoc) modes. This completion depends on citar and its parsing of bibtex keys. This backend activates for citation styles used by markdown-mode (pandoc, (@)), latex-mode (\cite{}), and org-mode (cite:@).

Please note that citar-capf reads from a bibliography file or files specified in citar-bibliography and presents completion info as set by citar-templates.

Initialization

Load the package and turn on the minor-mode via the following hooks:

(require 'citar-capf)
;; Define hook
(add-hook 'tex-mode-hook #'citar-capf-mode) ;; you may need to define this in more than one tex mode (e.g. latex, reftex, etc). 
(add-hook 'markdown-mode-hook #'citar-capf-mode)
(add-hook 'org-mode-hook #'citar-capf-mode)

If you use use-package, here’s how you might set things:

(use-package citar-capf
  :straight (:type git :host github :repo "mclear-tools/citar-capf")
  ;; NOTE: Set these hooks for whatever modes for which you want citar citation completion
  :hook ((org-mode markdown-mode tex-mode latex-mode reftex-mode) . citar-capf-mode) 
  :config
  ;; if you don't already have this set in citar
  (setq citar-bibliography "path/to/bib")
  (setq citar-templates
      `((main . " ${=key= id:15} ${title:48}")
        (suffix . "${author editor:30}  ${=type=:12}  ${=beref=:12} ${tags keywords:*}")
        (preview . "${author editor} (${year issued date}) ${title}, ${journal journaltitle publisher container-title collection-title}.\n"))))

To remove the hooks just deactivate the minor mode.

Acknowledgements

  • Thanks to Bruce D’Arcus for discussion of how to best flesh out the completion function.

citar-capf's People

Contributors

mclearc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

krisbalintona

citar-capf's Issues

Why not make this part of Citar itself?

The advantage of the Capf API is that it doesn't incur dependencies, so it could go directly into Citar. Is the provided functionality controversial such that @bdarcus prefers to have it in a separate package? If not, having this inside Citar will be advantageous:

  • User friendliness.
  • Less work for the MELPA/ELPA maintainers.
  • Easier to maintain for the Citar maintainers and you, since everything will be updated in sync.
  • Better coordination with other Citar features.

Generally I am all for a modularized package ecosystem where it makes sense. But sometimes packages are too fine grained as it seems to be the case here.

Minor docstring clarification

The parsing of the bibtex file is handled by citar."

I'm not sure how you want to clarify this, or I would submit a tiny PR, but note:

  1. As I use it in citar, parsebib parses bibtex, biblatex and csl json files.
  2. It can be multiple files.

config example not setting capf correctly

Picking up where we earlier left off, in the hopes I can get this working, or it might help with the README instructions.

I do plan to test it with emacs -Q; I just need more time (maybe tomorrow).

If I add your use-package example, suitably modified for doom ...

Org

Value of completion-at-point-functions:

Its value is (pcomplete-completions-at-point t)
Local in buffer test.org; global value is 
(tags-completion-at-point-function citar-capf)

I do get corfu to activate with the citar completion. But if I hit RET on a candidate, it does not insert the key, but instead adds a newline to the buffer.

Aside: with the private doom corfu module I'm using, for other capfs (for example, in lisp buffers), when I highlight a candidate, it presents a preview, and when I hit RET it behaves as expected (inserts the candidate).

LaTeX

Its value is (TeX--completion-at-point t)
Local in buffer test.tex; global value is 
(tags-completion-at-point-function citar-capf)

Here I get no matches.

Markdown

No matches.

Its value is (citar-capf t)
Local in buffer test.md; global value is 
(tags-completion-at-point-function citar-capf)

Any suggestions? Is that setup as you expect with the variable?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.