Re: Org-cite follow function for ebib

2021-08-09 Thread Thomas S. Dye
Aloha John,

Thanks!

All the best,
Tom

John Kitchin  writes:

> If every thing is working right, you can get the file that a key is in like
> this:
>
> #+BEGIN_SRC emacs-lisp
> (cl-loop for (file . entries) in (org-cite-basic--parse-bibliography)
> when (gethash  "some-key" entries)
>  return file)
> #+END_SRC
>
> This returns the first file that matches.
>
> John
>
> ---
> Professor John Kitchin (he/him/his)
> Doherty Hall A207F
> Department of Chemical Engineering
> Carnegie Mellon University
> Pittsburgh, PA 15213
> 412-268-7803
> @johnkitchin
> http://kitchingroup.cheme.cmu.edu
>
>
>
> On Mon, Aug 9, 2021 at 6:45 AM Joost Kremers 
> wrote:
>
>> Hi Thomas & others,
>>
>> On Sat, Aug 07 2021, Thomas S. Dye wrote:
>> > Aloha Joost,
>> >
>> > Following some pointers from Eric and Bruce I have this in my
>> > configuration and it seems to work fine, though I haven't had a chance
>> > to use it very much.
>>
>> Thanks for figuring that out. :-) Once I get to implementing support, I'll
>> use
>> it as a starting point. There should also be a way to open the correct file
>> automatically, without the user having to select it.
>>
>>
>>
>> --
>> Joost Kremers
>> Life has its moments
>>
>>


--
Thomas S. Dye
https://tsdye.online/tsdye



Re: Org-cite follow function for ebib

2021-08-09 Thread John Kitchin
If every thing is working right, you can get the file that a key is in like
this:

#+BEGIN_SRC emacs-lisp
(cl-loop for (file . entries) in (org-cite-basic--parse-bibliography)
when (gethash  "some-key" entries)
 return file)
#+END_SRC

This returns the first file that matches.

John

---
Professor John Kitchin (he/him/his)
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu



On Mon, Aug 9, 2021 at 6:45 AM Joost Kremers 
wrote:

> Hi Thomas & others,
>
> On Sat, Aug 07 2021, Thomas S. Dye wrote:
> > Aloha Joost,
> >
> > Following some pointers from Eric and Bruce I have this in my
> > configuration and it seems to work fine, though I haven't had a chance
> > to use it very much.
>
> Thanks for figuring that out. :-) Once I get to implementing support, I'll
> use
> it as a starting point. There should also be a way to open the correct file
> automatically, without the user having to select it.
>
>
>
> --
> Joost Kremers
> Life has its moments
>
>


Re: Org-cite follow function for ebib

2021-08-09 Thread Bruce D'Arcus
I don't have a super specific suggestion ATM, but will just make the
following observation:

John Kitchin and I have been working on respective processors, and
they are modular enough that:

1) one can mix-and-match across projects

2) one can customize within each follow processor; for org-ref-cite,
you can extend its hydra-based follow UI using hydra+, and for
bibtex-actions you can write and use your own keymap to tell embark
which commands to use for it's menu.

Upshot: a function that takes a key (or list of keys, as with
bibtex-completion, which is what I use behind-the-scenes) is the
starting point for a basic single action follow processor. But it
should be easily incorporated into more feature-full UIs.



On Mon, Aug 9, 2021 at 6:45 AM Joost Kremers  wrote:
>
> Hi Thomas & others,
>
> On Sat, Aug 07 2021, Thomas S. Dye wrote:
> > Aloha Joost,
> >
> > Following some pointers from Eric and Bruce I have this in my
> > configuration and it seems to work fine, though I haven't had a chance
> > to use it very much.
>
> Thanks for figuring that out. :-) Once I get to implementing support, I'll use
> it as a starting point. There should also be a way to open the correct file
> automatically, without the user having to select it.
>
>
>
> --
> Joost Kremers
> Life has its moments



Re: Org-cite follow function for ebib

2021-08-09 Thread Joost Kremers
Hi Thomas & others,

On Sat, Aug 07 2021, Thomas S. Dye wrote:
> Aloha Joost,
>
> Following some pointers from Eric and Bruce I have this in my
> configuration and it seems to work fine, though I haven't had a chance
> to use it very much.

Thanks for figuring that out. :-) Once I get to implementing support, I'll use
it as a starting point. There should also be a way to open the correct file
automatically, without the user having to select it.



-- 
Joost Kremers
Life has its moments



Re: Org-cite follow function for ebib

2021-08-07 Thread Thomas S. Dye
Aloha Joost,

Following some pointers from Eric and Bruce I have this in my
configuration and it seems to work fine, though I haven't had a chance
to use it very much.

  ;; Citations
  (defun tsd/choose-file (candidates)
(interactive)
(org-completing-read "Choose file: " candidates))

  (defun tsd/ebib-follow (datum _)
"Follow citation or citation reference DATUM. When DATUM is a
citation reference, open ebib to the entry referencing the
citation key."
(let* ((key
(if (eq 'citation-reference (org-element-type datum))
(org-element-property :key datum)
  (user-error "Not a citation reference")))
   (files (org-cite-list-bibliography-files))
   (file (if (> (length files) 1)
 (tsd/choose-file files)
   (nth 0 files
  (ebib file key)))
  (require 'oc-biblatex)
  (require 'oc-csl)
  (org-cite-register-processor 'ebib
  :follow #'tsd/ebib-follow)
  (setq org-cite-follow-processor 'ebib)

Also, it was easy to configure ebib to insert citations with the
org-cite syntax.

All the best,
Tom

Joost Kremers  writes:

> On Fri, Aug 06 2021, Thomas S. Dye wrote:
>> Yes, I have set the basic follow processor and org-open-at-point takes
>> me to the .bib file at the entry for the key at point.
>
> Unfortunately, I haven't had the time yet to update Ebib for the new
> functionality. Ebib needs to implement a follow processor so that
> `org-open-at-point` takes you to the entry in Ebib.
>
>> Surprisingly (to me), M-x ebib sometimes displays the entry for the key
>> at point, too.
>
> That's because when you start Ebib with `M-x ebib` (or a key bound to that
> function, of course), it checks to see if point is at something that looks 
> like
> a key and tries to find a corresponding entry in the current database. That
> functionality is not customisable and not very well implemented, so it doesn't
> always work. (Also, if point is at the `cite` prefix, it doesn't work.)


--
Thomas S. Dye
https://tsdye.online/tsdye



Re: Org-cite follow function for ebib

2021-08-07 Thread Joost Kremers


On Fri, Aug 06 2021, Thomas S. Dye wrote:
> Yes, I have set the basic follow processor and org-open-at-point takes
> me to the .bib file at the entry for the key at point.

Unfortunately, I haven't had the time yet to update Ebib for the new
functionality. Ebib needs to implement a follow processor so that
`org-open-at-point` takes you to the entry in Ebib.

> Surprisingly (to me), M-x ebib sometimes displays the entry for the key
> at point, too.

That's because when you start Ebib with `M-x ebib` (or a key bound to that
function, of course), it checks to see if point is at something that looks like
a key and tries to find a corresponding entry in the current database. That
functionality is not customisable and not very well implemented, so it doesn't
always work. (Also, if point is at the `cite` prefix, it doesn't work.)

-- 
Joost Kremers
Life has its moments



Re: Org-cite follow function for ebib

2021-08-06 Thread Thomas S. Dye
Yes, I have set the basic follow processor and org-open-at-point takes
me to the .bib file at the entry for the key at point.

Surprisingly (to me), M-x ebib sometimes displays the entry for the key
at point, too.

All the best,
Tom

Bruce D'Arcus  writes:

> On Fri, Aug 6, 2021 at 12:47 PM Thomas S. Dye  wrote:
>>
>> Aloha Bruce,
>>
>> So, I tried calling ebib() with point on a key and it works in some
>> instances but not in others.
>
> Just to make sure I'm being clear, I mean this in your config:
>
> (setq org-cite-follow-processor 'basic)
>
> ... and then, when point is on citation and/or key:
>
> M-x org-open-at-point
>
> ... which is what calls the follow processor.
>
> If that doesn't work, you can probably look at the oc-basic code and
> see how to adapt it for ebib.
>
> Bruce


--
Thomas S. Dye
https://tsdye.online/tsdye



Re: Org-cite follow function for ebib

2021-08-06 Thread Bruce D'Arcus
On Fri, Aug 6, 2021 at 12:47 PM Thomas S. Dye  wrote:
>
> Aloha Bruce,
>
> So, I tried calling ebib() with point on a key and it works in some
> instances but not in others.

Just to make sure I'm being clear, I mean this in your config:

(setq org-cite-follow-processor 'basic)

... and then, when point is on citation and/or key:

M-x org-open-at-point

... which is what calls the follow processor.

If that doesn't work, you can probably look at the oc-basic code and
see how to adapt it for ebib.

Bruce



Re: Org-cite follow function for ebib

2021-08-06 Thread Thomas S. Dye
Aloha Bruce,

So, I tried calling ebib() with point on a key and it works in some
instances but not in others.

So far, it works sometimes on plain cite: keys, but never on styles or
variants, like cite/a/f:

It would be magical if something this simple would do the trick.

All the best,
Tom

Bruce D'Arcus  writes:

> On Fri, Aug 6, 2021 at 11:50 AM Thomas S. Dye  wrote:
>>
>> Aloha Eric,
>>
>> That function opens a window on the ebib database and displays the
>> record with the key at point.
>
> So does the oc-basic follow function not provide this?
>
> I guess I'm unclear if one can configure ebib to open bib files by
> default. If yes, I would think oc-basic would be sufficient.
>
> If not, FWIW, org-ref-cite-follow is extensible via hydra+ (as is
> bibtex-actions-follow via a custom embark keymap).
>
> Depends if you want just a single function to run, or you want a menu
> of choices.
>
> Bruce


--
Thomas S. Dye
https://tsdye.online/tsdye



Re: Org-cite follow function for ebib

2021-08-06 Thread Bruce D'Arcus
On Fri, Aug 6, 2021 at 11:50 AM Thomas S. Dye  wrote:
>
> Aloha Eric,
>
> That function opens a window on the ebib database and displays the
> record with the key at point.

So does the oc-basic follow function not provide this?

I guess I'm unclear if one can configure ebib to open bib files by
default. If yes, I would think oc-basic would be sufficient.

If not, FWIW, org-ref-cite-follow is extensible via hydra+ (as is
bibtex-actions-follow via a custom embark keymap).

Depends if you want just a single function to run, or you want a menu
of choices.

Bruce



Re: Org-cite follow function for ebib

2021-08-06 Thread Thomas S. Dye
Aloha Eric,

That function opens a window on the ebib database and displays the
record with the key at point.

At this point, I'm just checking to see if someone has a similar
function working for the new org-cite framework.

I do appreciate the pointers to functions that do something similar
outside ebib.  They'll be useful if I try to write a function myself.

All the best,
Tom

Eric S Fraga  writes:

> On Thursday,  5 Aug 2021 at 10:12, Thomas S. Dye wrote:
>> I want to open the bib entry, something similar to org-ebib-open,
>> which works on Org mode links.
>
> Tom,
>
> maybe clarify what org-ebib-open does?
>
> For me, org-open-at-point, bound to C-c C-o, on a [cite:@key] entry,
> will open the bibliography file and place me at the correct entry.  What
> is it you want to do beyond this?
>
> (I have not used ebib in years and have forgotten what it is it might
> do.)


--
Thomas S. Dye
https://tsdye.online/tsdye



Re: Org-cite follow function for ebib

2021-08-06 Thread Eric S Fraga
On Thursday,  5 Aug 2021 at 10:12, Thomas S. Dye wrote:
> I want to open the bib entry, something similar to org-ebib-open,
> which works on Org mode links.

Tom,

maybe clarify what org-ebib-open does?

For me, org-open-at-point, bound to C-c C-o, on a [cite:@key] entry,
will open the bibliography file and place me at the correct entry.  What
is it you want to do beyond this?

(I have not used ebib in years and have forgotten what it is it might
do.)

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.4.6-607-g185706
: Latest paper written in org: https://arxiv.org/abs/2106.05096



Re: Org-cite follow function for ebib

2021-08-05 Thread Thomas S. Dye
I want to open the bib entry, something similar to org-ebib-open, 
which works on Org mode links.


All the best,
Tom

Bruce D'Arcus  writes:

What kind of functionality do you want associated with your 
citations

(when you run `org-open-at-point` on them)?

Is some or all of it specific to ebib?

Or is it more generic; opening the bib entry, notes, PDFs, etc?

Because the modular nature of org-cite makes it easy to 
mix-and-match

pieces from different projects.

For example, bibtex-actions offers an embark-based follow 
processor,
that uses bibtex-completion behind-the-scenes, and org-ref-cite 
does

similar for a hydra.

On Thu, Aug 5, 2021 at 2:38 PM Thomas S. Dye  
wrote:


Aloha all,

My googling came up empty.  Does anyone have such a function?

All the best,
Tom
--
Thomas S. Dye
https://tsdye.online/tsdye




--
Thomas S. Dye
https://tsdye.online/tsdye



Re: Org-cite follow function for ebib

2021-08-05 Thread Bruce D'Arcus
What kind of functionality do you want associated with your citations
(when you run `org-open-at-point` on them)?

Is some or all of it specific to ebib?

Or is it more generic; opening the bib entry, notes, PDFs, etc?

Because the modular nature of org-cite makes it easy to mix-and-match
pieces from different projects.

For example, bibtex-actions offers an embark-based follow processor,
that uses bibtex-completion behind-the-scenes, and org-ref-cite does
similar for a hydra.

On Thu, Aug 5, 2021 at 2:38 PM Thomas S. Dye  wrote:
>
> Aloha all,
>
> My googling came up empty.  Does anyone have such a function?
>
> All the best,
> Tom
> --
> Thomas S. Dye
> https://tsdye.online/tsdye
>



Org-cite follow function for ebib

2021-08-05 Thread Thomas S. Dye

Aloha all,

My googling came up empty.  Does anyone have such a function?

All the best,
Tom
--
Thomas S. Dye
https://tsdye.online/tsdye