emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [org-cite] request for coding help on a capf to insert citation key


From: Bruce D'Arcus
Subject: Re: [org-cite] request for coding help on a capf to insert citation key
Date: Sun, 6 Jun 2021 12:21:28 -0400

One other idea, Nicolas:

Is there room to include a org-cite somehow, so that one had a defcustom like:

(setq org-cite-complete-key-candidates my-candidates)
;; here override default with results from my package
(setq my-candidates (bibtex-actions--get-candidates))

... and default could be some simple thing in oc-basic?

If not, totally fine of course, but I thought I'd mention it as I'm
trying to figure this out.

Bruce

On Sat, Jun 5, 2021 at 5:14 PM Bruce D'Arcus <bdarcus@gmail.com> wrote:
>
> Round 2, which should address the "regex" todo.
>
> --8<---------------cut here---------------start------------->8---
> (defun bibtex-actions-complete-key-at-point-oc ()
>     "Complete org-cite citation key at point.
>
> When inserting '@' in a buffer the capf UI will present user with
> a list of entries, from which they can narrow against a string
> which includes title, author, etc., and then select one.  This
> function will then return the key 'key', resulting in '@key' at
> point."
>     ;; FIX exit-function is wrong; results in "no match"
>   (when (and (eq major-mode 'org-mode)
>              (eq (car (org-element-context)) 'citation))
>     (let* ((candidates (bibtex-actions--get-candidates))
>            (begin (save-excursion (backward-word) (point)))
>            (end (point)))
>       (list begin end candidates :exclusive 'no
>             :exit-function
>             (lambda (chosen status)
>               (when (eq status 'finished)
>                 (cdr (assoc chosen candidates))))))))
> --8<---------------cut here---------------end--------------->8---



reply via email to

[Prev in Thread] Current Thread [Next in Thread]