emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [wip-cite-new] Quick note about citation insertion
@ 2021-07-02 16:10 Nicolas Goaziou
  2021-07-02 19:21 ` Bruce D'Arcus
  2021-07-02 19:47 ` Bruce D'Arcus
  0 siblings, 2 replies; 33+ messages in thread
From: Nicolas Goaziou @ 2021-07-02 16:10 UTC (permalink / raw)
  To: Org Mode List

Hello,

I just added an interface to unify functions responsible for inserting
citations in a buffer. The default binding is <C-c C-x @>.

I also plugged a rather crude function with that interface. In order to
use it, you can evaluate:

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

Internally, this will bind <C-c C-x @> to `org-cite-basic-insert', which
can insert citations, or edit existing ones, depending on the point.

From a developer point of view, you can specify two new keywords when
registering a new processor: :insert and :cite-styles. See
`org-cite-register-processor' for details. See also an application in
"oc-basic.el", for example.

Regards,
-- 
Nicolas Goaziou


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [wip-cite-new] Quick note about citation insertion
  2021-07-02 16:10 [wip-cite-new] Quick note about citation insertion Nicolas Goaziou
@ 2021-07-02 19:21 ` Bruce D'Arcus
  2021-07-02 20:05   ` Nicolas Goaziou
  2021-07-02 19:47 ` Bruce D'Arcus
  1 sibling, 1 reply; 33+ messages in thread
From: Bruce D'Arcus @ 2021-07-02 19:21 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Org Mode List

Looking good Nicolas.

Just one small thing.

If I run on a citation, I get a list of styles, including "nil".

If I select that, "nil" is added to the citation, so that the result
is "[cite/nil:@key]".


On Fri, Jul 2, 2021 at 12:11 PM Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
>
> Hello,
>
> I just added an interface to unify functions responsible for inserting
> citations in a buffer. The default binding is <C-c C-x @>.
>
> I also plugged a rather crude function with that interface. In order to
> use it, you can evaluate:
>
>   (setq org-cite-insert-processor 'basic)
>
> Internally, this will bind <C-c C-x @> to `org-cite-basic-insert', which
> can insert citations, or edit existing ones, depending on the point.
>
> From a developer point of view, you can specify two new keywords when
> registering a new processor: :insert and :cite-styles. See
> `org-cite-register-processor' for details. See also an application in
> "oc-basic.el", for example.
>
> Regards,
> --
> Nicolas Goaziou
>


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [wip-cite-new] Quick note about citation insertion
  2021-07-02 16:10 [wip-cite-new] Quick note about citation insertion Nicolas Goaziou
  2021-07-02 19:21 ` Bruce D'Arcus
@ 2021-07-02 19:47 ` Bruce D'Arcus
  2021-07-02 20:14   ` Nicolas Goaziou
  1 sibling, 1 reply; 33+ messages in thread
From: Bruce D'Arcus @ 2021-07-02 19:47 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Org Mode List

Also:

1. I don't see a way to add a key to an existing citation. Editing an
existing key uses completing-read, rather than
completing-read-multiple (as for a new citation), and places point
after the existing key means the style editing UI will pop up.
2. If I use CRM to add multiple keys, for reasons I haven't
determined, I get a "match required" error if I complete the second
key. I can only get it to work if I hit enter before fully completing
the key. I don't know if this is just some selectrum oddity/bug or
not.

On Fri, Jul 2, 2021 at 12:11 PM Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
>
> Hello,
>
> I just added an interface to unify functions responsible for inserting
> citations in a buffer. The default binding is <C-c C-x @>.
>
> I also plugged a rather crude function with that interface. In order to
> use it, you can evaluate:
>
>   (setq org-cite-insert-processor 'basic)
>
> Internally, this will bind <C-c C-x @> to `org-cite-basic-insert', which
> can insert citations, or edit existing ones, depending on the point.
>
> From a developer point of view, you can specify two new keywords when
> registering a new processor: :insert and :cite-styles. See
> `org-cite-register-processor' for details. See also an application in
> "oc-basic.el", for example.
>
> Regards,
> --
> Nicolas Goaziou
>


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [wip-cite-new] Quick note about citation insertion
  2021-07-02 19:21 ` Bruce D'Arcus
@ 2021-07-02 20:05   ` Nicolas Goaziou
  2021-07-03  8:45     ` Bruce D'Arcus
  0 siblings, 1 reply; 33+ messages in thread
From: Nicolas Goaziou @ 2021-07-02 20:05 UTC (permalink / raw)
  To: Bruce D'Arcus; +Cc: Org Mode List

Hello,

"Bruce D'Arcus" <bdarcus@gmail.com> writes:

> Looking good Nicolas.
>
> Just one small thing.
>
> If I run on a citation, I get a list of styles, including "nil".
>
> If I select that, "nil" is added to the citation, so that the result
> is "[cite/nil:@key]".

That's expected. "nil" is the name of the processor's fall-back style,
ignoring any inheritance. It is different from the empty style (""),
which takes into account inheritance.

So, basically, in the following document:

  #+cite_export: biblatex whatever text
  [cite/nil:@doe21]
  [cite:@doe21]

the first citation will use \cite whereas the second one will use
\textcite.

Regards,
-- 
Nicolas Goaziou


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [wip-cite-new] Quick note about citation insertion
  2021-07-02 19:47 ` Bruce D'Arcus
@ 2021-07-02 20:14   ` Nicolas Goaziou
  2021-07-02 20:58     ` Bruce D'Arcus
  0 siblings, 1 reply; 33+ messages in thread
From: Nicolas Goaziou @ 2021-07-02 20:14 UTC (permalink / raw)
  To: Bruce D'Arcus; +Cc: Org Mode List

"Bruce D'Arcus" <bdarcus@gmail.com> writes:

> 1. I don't see a way to add a key to an existing citation. Editing an
> existing key uses completing-read, rather than
> completing-read-multiple (as for a new citation), and places point
> after the existing key means the style editing UI will pop up.

Indeed, there's no way to add a reference to an existing citation.
I admit I didn't think about it. What about appending a reference when
the function is called with C-u?

BTW, there's a reason for `completing-read'. When the function is called
on an existing references, it updates the reference, but preserves
affixes. It would make no sense to insert multiple references.

> 2. If I use CRM to add multiple keys, for reasons I haven't
> determined, I get a "match required" error if I complete the second
> key. I can only get it to work if I hit enter before fully completing
> the key. I don't know if this is just some selectrum oddity/bug or
> not.

I encountered this, too. I think this is a Selectrum bug, because when
I disable it, I can successfully use the UI.

Regards,



^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [wip-cite-new] Quick note about citation insertion
  2021-07-02 20:14   ` Nicolas Goaziou
@ 2021-07-02 20:58     ` Bruce D'Arcus
  2021-07-02 21:05       ` John Kitchin
  2021-07-02 21:48       ` Nicolas Goaziou
  0 siblings, 2 replies; 33+ messages in thread
From: Bruce D'Arcus @ 2021-07-02 20:58 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Org Mode List

[-- Attachment #1: Type: text/plain, Size: 1053 bytes --]

On Fri, Jul 2, 2021, 4:14 PM Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:

> "Bruce D'Arcus" <bdarcus@gmail.com> writes:
>
> > 1. I don't see a way to add a key to an existing citation. Editing an
> > existing key uses completing-read, rather than
> > completing-read-multiple (as for a new citation), and places point
> > after the existing key means the style editing UI will pop up.
>
> Indeed, there's no way to add a reference to an existing citation.
> I admit I didn't think about it. What about appending a reference when
> the function is called with C-u?


Probably that would work.

BTW, you may already be thinking this, but you may as well add completion
from the files registered with OC at this point. :-)

Only having the completion table populated with in-document keys won't be
very useful, particularly in a new document.

If you do, ideally it would be extensible/configurable.

Or is the latter already the case?

OTOH, IDK how much you feel the need to get everything done before merger,
or whether some pieces can wait?

Bruce

[-- Attachment #2: Type: text/html, Size: 1849 bytes --]

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [wip-cite-new] Quick note about citation insertion
  2021-07-02 20:58     ` Bruce D'Arcus
@ 2021-07-02 21:05       ` John Kitchin
  2021-07-02 21:21         ` Nicolas Goaziou
  2021-07-02 21:48       ` Nicolas Goaziou
  1 sibling, 1 reply; 33+ messages in thread
From: John Kitchin @ 2021-07-02 21:05 UTC (permalink / raw)
  To: Bruce D'Arcus; +Cc: Org Mode List, Nicolas Goaziou

[-- Attachment #1: Type: text/plain, Size: 1665 bytes --]

I would not use a prefix arg here. you should just check what is at the
point, and if it is a citation then append it after the citation at point,
and if not insert a new one (maybe after moving the point to an appropriate
place if needed).




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 Fri, Jul 2, 2021 at 4:59 PM Bruce D'Arcus <bdarcus@gmail.com> wrote:

>
>
> On Fri, Jul 2, 2021, 4:14 PM Nicolas Goaziou <mail@nicolasgoaziou.fr>
> wrote:
>
>> "Bruce D'Arcus" <bdarcus@gmail.com> writes:
>>
>> > 1. I don't see a way to add a key to an existing citation. Editing an
>> > existing key uses completing-read, rather than
>> > completing-read-multiple (as for a new citation), and places point
>> > after the existing key means the style editing UI will pop up.
>>
>> Indeed, there's no way to add a reference to an existing citation.
>> I admit I didn't think about it. What about appending a reference when
>> the function is called with C-u?
>
>
> Probably that would work.
>
> BTW, you may already be thinking this, but you may as well add completion
> from the files registered with OC at this point. :-)
>
> Only having the completion table populated with in-document keys won't be
> very useful, particularly in a new document.
>
> If you do, ideally it would be extensible/configurable.
>
> Or is the latter already the case?
>
> OTOH, IDK how much you feel the need to get everything done before merger,
> or whether some pieces can wait?
>
> Bruce
>
>

[-- Attachment #2: Type: text/html, Size: 3058 bytes --]

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [wip-cite-new] Quick note about citation insertion
  2021-07-02 21:05       ` John Kitchin
@ 2021-07-02 21:21         ` Nicolas Goaziou
  2021-07-03  0:21           ` Bruce D'Arcus
  0 siblings, 1 reply; 33+ messages in thread
From: Nicolas Goaziou @ 2021-07-02 21:21 UTC (permalink / raw)
  To: John Kitchin; +Cc: Org Mode List, Bruce D'Arcus

Hello,

John Kitchin <jkitchin@andrew.cmu.edu> writes:

> I would not use a prefix arg here. you should just check what is at the
> point, and if it is a citation then append it after the citation at point,
> and if not insert a new one (maybe after moving the point to an appropriate
> place if needed).

Well, currently, if there's a reference at point, the function updates
it, which I think is also a valid behaviour.

On other parts of the citation, the function updates its style. Styling
the citation is probably less important than adding a reference. So
I could use C-u for the style, and append a reference when point is not
on one of them already.

However, I'm not designing a canonical way to handle citations here. Any
library (e.g., Org Ref *hint*) is free to use the :insert property and
provide a different implementation. Then, for example,

  (setq org-cite-insert-processor 'org-ref)

will be enough to have it occupy the <C-c C-x @> binding :)

Regards,
-- 
Nicolas Goaziou


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [wip-cite-new] Quick note about citation insertion
  2021-07-02 20:58     ` Bruce D'Arcus
  2021-07-02 21:05       ` John Kitchin
@ 2021-07-02 21:48       ` Nicolas Goaziou
  2021-07-02 21:57         ` Bruce D'Arcus
  1 sibling, 1 reply; 33+ messages in thread
From: Nicolas Goaziou @ 2021-07-02 21:48 UTC (permalink / raw)
  To: Bruce D'Arcus; +Cc: Org Mode List

"Bruce D'Arcus" <bdarcus@gmail.com> writes:

> BTW, you may already be thinking this, but you may as well add completion
> from the files registered with OC at this point. :-)
>
> Only having the completion table populated with in-document keys won't be
> very useful, particularly in a new document.

The completion table is populated by all the keys in the bibliography.
It is not limited to in-document keys.

> If you do, ideally it would be extensible/configurable.
>
> Or is the latter already the case?

I am a bit lost. Would you mind explaining what should be
extensible/configurable?

> OTOH, IDK how much you feel the need to get everything done before merger,
> or whether some pieces can wait?

I'd like to add support for JSON bibliography in Org Cite Basic first.

I'm also wondering if some integration with pcomplete (M-/) is
warranted. It may not be with an efficient enough insertion function.
Maybe this can wait.

Otherwise, I'm mostly done.

Regards,


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [wip-cite-new] Quick note about citation insertion
  2021-07-02 21:48       ` Nicolas Goaziou
@ 2021-07-02 21:57         ` Bruce D'Arcus
  2021-07-02 22:33           ` Nicolas Goaziou
  0 siblings, 1 reply; 33+ messages in thread
From: Bruce D'Arcus @ 2021-07-02 21:57 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Org Mode List

[-- Attachment #1: Type: text/plain, Size: 1535 bytes --]

On Fri, Jul 2, 2021, 5:48 PM Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:

> "Bruce D'Arcus" <bdarcus@gmail.com> writes:
>
> > BTW, you may already be thinking this, but you may as well add completion
> > from the files registered with OC at this point. :-)
> >
> > Only having the completion table populated with in-document keys won't be
> > very useful, particularly in a new document.
>
> The completion table is populated by all the keys in the bibliography.
> It is not limited to in-document keys.
>

Oh good.

Let me revise then.

Rather than just completing the key, how about something like:

("title author date" . "key")

E.g. look up against the data, and return the key.

It's hard to remember keys if you have hundreds or thousands.

In bibtex-actions, I added some hidden data to the search string, including
the key, to ensure uniqueness.

> If you do, ideally it would be extensible/configurable.
> >
> > Or is the latter already the case?
>
> I am a bit lost. Would you mind explaining what should be
> extensible/configurable?
>

For example, plug in a different completion table or function?

> OTOH, IDK how much you feel the need to get everything done before merger,
> > or whether some pieces can wait?
>
> I'd like to add support for JSON bibliography in Org Cite Basic first.
>

Makes sense.

Bruce

I'm also wondering if some integration with pcomplete (M-/) is
> warranted. It may not be with an efficient enough insertion function.
> Maybe this can wait.
>
> Otherwise, I'm mostly done.
>
> Regards,
>

[-- Attachment #2: Type: text/html, Size: 3102 bytes --]

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [wip-cite-new] Quick note about citation insertion
  2021-07-02 21:57         ` Bruce D'Arcus
@ 2021-07-02 22:33           ` Nicolas Goaziou
  2021-07-02 23:59             ` Bruce D'Arcus
  2021-07-03  7:28             ` Eric S Fraga
  0 siblings, 2 replies; 33+ messages in thread
From: Nicolas Goaziou @ 2021-07-02 22:33 UTC (permalink / raw)
  To: Bruce D'Arcus; +Cc: Org Mode List

"Bruce D'Arcus" <bdarcus@gmail.com> writes:

> On Fri, Jul 2, 2021, 5:48 PM Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:

> Rather than just completing the key, how about something like:
>
> ("title author date" . "key")
>
> E.g. look up against the data, and return the key.

Well, I guess it's possible to do. Patches welcome!
>
> It's hard to remember keys if you have hundreds or thousands.

If you have so many keys, you shouldn't be using Org Cite Basics in the
first place!

>> I am a bit lost. Would you mind explaining what should be
>> extensible/configurable?

> For example, plug in a different completion table or function?

The completion table, if required, and the completion mechanism belong
to the insert function. So, you can plug anything you want.


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [wip-cite-new] Quick note about citation insertion
  2021-07-02 22:33           ` Nicolas Goaziou
@ 2021-07-02 23:59             ` Bruce D'Arcus
  2021-07-03  7:28             ` Eric S Fraga
  1 sibling, 0 replies; 33+ messages in thread
From: Bruce D'Arcus @ 2021-07-02 23:59 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Org Mode List

On Fri, Jul 2, 2021 at 6:33 PM Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:

> The completion table, if required, and the completion mechanism belong
> to the insert function. So, you can plug anything you want.

You're right.

It is likely less work, with better results, for me to adapt what you
do with the basic insert function to my package, than vice-versa.

> I encountered this, too. I think this is a Selectrum bug, because when
I disable it, I can successfully use the UI.

Confirmed.

Vertico has no such issue, with a very similar UI/UX to selectrum.

Bruce


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [wip-cite-new] Quick note about citation insertion
  2021-07-02 21:21         ` Nicolas Goaziou
@ 2021-07-03  0:21           ` Bruce D'Arcus
  0 siblings, 0 replies; 33+ messages in thread
From: Bruce D'Arcus @ 2021-07-03  0:21 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Org Mode List, John Kitchin

On Fri, Jul 2, 2021 at 5:21 PM Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
>
> Hello,
>
> John Kitchin <jkitchin@andrew.cmu.edu> writes:
>
> > I would not use a prefix arg here. you should just check what is at the
> > point, and if it is a citation then append it after the citation at point,
> > and if not insert a new one (maybe after moving the point to an appropriate
> > place if needed).
>
> Well, currently, if there's a reference at point, the function updates
> it, which I think is also a valid behaviour.
>
> On other parts of the citation, the function updates its style.

Is it possible to have three options?

1. if on "cite" prefix, edit style
2. if on citation-reference, edit reference
3. else (like where point is after a semi-colon but within the
citation), append reference

So the difference with current behavior is 1 would be more
constrained, and 3 would be a new option.

Bruce


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [wip-cite-new] Quick note about citation insertion
  2021-07-02 22:33           ` Nicolas Goaziou
  2021-07-02 23:59             ` Bruce D'Arcus
@ 2021-07-03  7:28             ` Eric S Fraga
  2021-07-03  7:58               ` Nicolas Goaziou
  1 sibling, 1 reply; 33+ messages in thread
From: Eric S Fraga @ 2021-07-03  7:28 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Org Mode List

On Saturday,  3 Jul 2021 at 00:33, Nicolas Goaziou wrote:
> If you have so many keys, you shouldn't be using Org Cite Basics in the
> first place!

Nicolas,

I think there's a conceptual misunderstanding here (and it could be
mine, of course).

My bibliography database contains thousands of entries, accumulated over
decades of research.  In a typical paper, however, I will cite 10-30 of
these.  Finding the actual paper to cite does require being able to
search on not just the keys.  The keys, these days, are automatically
generated by the journals often.

For the record, ivy-bibtex does a good job in completion for
bibliography entries.

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


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [wip-cite-new] Quick note about citation insertion
  2021-07-03  7:28             ` Eric S Fraga
@ 2021-07-03  7:58               ` Nicolas Goaziou
  2021-07-03 14:57                 ` Eric S Fraga
  2021-07-06 12:11                 ` Bruce D'Arcus
  0 siblings, 2 replies; 33+ messages in thread
From: Nicolas Goaziou @ 2021-07-03  7:58 UTC (permalink / raw)
  To: Org Mode List

Hello,

Eric S Fraga <e.fraga@ucl.ac.uk> writes:

> On Saturday,  3 Jul 2021 at 00:33, Nicolas Goaziou wrote:
>> If you have so many keys, you shouldn't be using Org Cite Basics in the
>> first place!

> I think there's a conceptual misunderstanding here

[...]

> My bibliography database contains thousands of entries, accumulated over
> decades of research.  In a typical paper, however, I will cite 10-30 of
> these.  Finding the actual paper to cite does require being able to
> search on not just the keys.  The keys, these days, are automatically
> generated by the journals often.

My tongue in cheek answer was about the weakness of the Org Cite _Basic_
library. I totally understand your need for a serious completion
mechanism that can handle thousands of entries. I was merely pointing
out that this is not the scope of the demo for the interface I wrote.
I hope, however, that really useful tools will be written from that
interface.

Anyway, I'll try to provide something a little more useful out of the
box, based on your comment and Bruce D'Arcus suggestion.

Sorry for not being clear!

Regards,
-- 
Nicolas Goaziou


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [wip-cite-new] Quick note about citation insertion
  2021-07-02 20:05   ` Nicolas Goaziou
@ 2021-07-03  8:45     ` Bruce D'Arcus
  2021-07-03  9:20       ` Nicolas Goaziou
  0 siblings, 1 reply; 33+ messages in thread
From: Bruce D'Arcus @ 2021-07-03  8:45 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Org Mode List

On Fri, Jul 2, 2021 at 4:05 PM Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:

> "Bruce D'Arcus" <bdarcus@gmail.com> writes:

> > If I select that, "nil" is added to the citation, so that the result
> > is "[cite/nil:@key]".
>
> That's expected. "nil" is the name of the processor's fall-back style,
> ignoring any inheritance. It is different from the empty style (""),
> which takes into account inheritance.

Two things:

First, after adding a style, I can't see how to subsequently remove it
using this interface, to just have "[cite:@key]". Is that possible?

In my formatting function for OC, which is simpler than your's in some
ways, I have a named "default" style, with that as the
ido-completing-read "initial-value", which is then removed if
selected.

In practice, what that means is if the user is prompted for the style
but hits return, they select "default", and hence the result is
"[cite:@key]".

But they can also, of course, select the other named styles instead.

It seems efficient and clear to me, and if the answer to my question
above is "no", it could be a reasonable approach to address this.

Second, the "nil" vs "empty" distinction was obviously not immediately
intuitive to me. I don't have a better name for "nil" ATM though, so
maybe it will be fine. Hopefully people won't have the need to use it
much.

Bruce


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [wip-cite-new] Quick note about citation insertion
  2021-07-03  8:45     ` Bruce D'Arcus
@ 2021-07-03  9:20       ` Nicolas Goaziou
  2021-07-03  9:56         ` Bruce D'Arcus
  0 siblings, 1 reply; 33+ messages in thread
From: Nicolas Goaziou @ 2021-07-03  9:20 UTC (permalink / raw)
  To: Bruce D'Arcus; +Cc: Org Mode List

Hello,

"Bruce D'Arcus" <bdarcus@gmail.com> writes:

> On Fri, Jul 2, 2021 at 4:05 PM Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:

>> That's expected. "nil" is the name of the processor's fall-back style,
>> ignoring any inheritance. It is different from the empty style (""),
>> which takes into account inheritance.
>
> Two things:
>
> First, after adding a style, I can't see how to subsequently remove it
> using this interface, to just have "[cite:@key]". Is that possible?

Of course. Just select the empty string instead of an entry. It is done
with C-j on Selectrum and `completing-read-default'. I assume this is
the same on other completion frameworks.

> In my formatting function for OC, which is simpler than your's in some
> ways, I have a named "default" style, with that as the
> ido-completing-read "initial-value", which is then removed if
> selected.
>
> In practice, what that means is if the user is prompted for the style
> but hits return, they select "default", and hence the result is
> "[cite:@key]".

Your "default" is equivalent to my empty string. But one day, an export
processor may use "default" as a name for a different style. Who knows?
Moreover, "default" may be ambiguous: does it mean user's or processor's
default style?

More importantly, we have to deal with the empty string anyway; this is
a valid return value from `completing-read'.

> Second, the "nil" vs "empty" distinction was obviously not immediately
> intuitive to me. I don't have a better name for "nil" ATM though, so
> maybe it will be fine. Hopefully people won't have the need to use it
> much.

Both are necessary. At some point, this will have to be documented.

Regards,
-- 
Nicolas Goaziou


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [wip-cite-new] Quick note about citation insertion
  2021-07-03  9:20       ` Nicolas Goaziou
@ 2021-07-03  9:56         ` Bruce D'Arcus
  0 siblings, 0 replies; 33+ messages in thread
From: Bruce D'Arcus @ 2021-07-03  9:56 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Org Mode List

On Sat, Jul 3, 2021 at 5:20 AM Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:

> > First, after adding a style, I can't see how to subsequently remove it
> > using this interface, to just have "[cite:@key]". Is that possible?
>
> Of course. Just select the empty string instead of an entry. It is done
> with C-j on Selectrum and `completing-read-default'. I assume this is
> the same on other completion frameworks.

I thought I tried that to edit an existing style, and it didn't work.

But I see now it does.

Good.

Bruce


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [wip-cite-new] Quick note about citation insertion
  2021-07-03  7:58               ` Nicolas Goaziou
@ 2021-07-03 14:57                 ` Eric S Fraga
  2021-07-03 15:09                   ` Bruce D'Arcus
  2021-07-06 12:11                 ` Bruce D'Arcus
  1 sibling, 1 reply; 33+ messages in thread
From: Eric S Fraga @ 2021-07-03 14:57 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Org Mode List

On Saturday,  3 Jul 2021 at 09:58, Nicolas Goaziou wrote:
> My tongue in cheek answer was about the weakness of the Org Cite
> _Basic_ library. [...] I was merely pointing out that this is not the
> scope of the demo for the interface I wrote.  

Ah ha, there was indeed a basic conceptual misunderstanding, and it was
on my side!  Thanks for clarifying.

> Anyway, I'll try to provide something a little more useful out of the
> box, based on your comment and Bruce D'Arcus suggestion.

But that's partly why I mentioned ivy-bibtex: solutions already exist
and there should be no need to re-invent the wheel?

Thank you,
eric

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


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [wip-cite-new] Quick note about citation insertion
  2021-07-03 14:57                 ` Eric S Fraga
@ 2021-07-03 15:09                   ` Bruce D'Arcus
  2021-07-05 13:29                     ` Eric S Fraga
  0 siblings, 1 reply; 33+ messages in thread
From: Bruce D'Arcus @ 2021-07-03 15:09 UTC (permalink / raw)
  To: Org Mode List; +Cc: Nicolas Goaziou

On Sat, Jul 3, 2021 at 10:58 AM Eric S Fraga <e.fraga@ucl.ac.uk> wrote:

> > Anyway, I'll try to provide something a little more useful out of the
> > box, based on your comment and Bruce D'Arcus suggestion.
>
> But that's partly why I mentioned ivy-bibtex: solutions already exist
> and there should be no need to re-invent the wheel?

I kind of disagree.

There's a middle ground between super minimal and fully-featured that
I think is appropriate for oc-basic.

Nicolas is doing things with even the basic insert function that are
not possible with the existing tools currently, in part as a
demonstration of the possibilities, and also just to provide a decent
default experience.

But as I said to him off-list, if he simply changes his completion
table from being a list of keys, to a list of cons like I mentioned,
and maybe even makes the table a variable, then third-party tools can
do one of two things:

1. if the variable, simply plug-in their own completion table, and so
get a richer UI (this is the case with bibtex-actions, which has the
same data structure)
2. the code itself can be a demo that can be easily adapted; in my
case, I can pretty much copy-and-paste it and just change the "all"
let variables

Practically speaking, the ivy-bibtex "insert citation" action, which
uses the bibtex-completion-insert-citation function behind-the-scenes,
can then be enhanced such that it is more fully-featured in the
context of org than it is in other modes, and that it is now.

So enhancing this a little bit will have both short-term and long-term
pay-off, both for default citations in org, and for third-party tools.

Bruce


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [wip-cite-new] Quick note about citation insertion
  2021-07-03 15:09                   ` Bruce D'Arcus
@ 2021-07-05 13:29                     ` Eric S Fraga
  0 siblings, 0 replies; 33+ messages in thread
From: Eric S Fraga @ 2021-07-05 13:29 UTC (permalink / raw)
  To: Bruce D'Arcus; +Cc: Org Mode List, Nicolas Goaziou

On Saturday,  3 Jul 2021 at 11:09, Bruce D'Arcus wrote:
> On Sat, Jul 3, 2021 at 10:58 AM Eric S Fraga <e.fraga@ucl.ac.uk> wrote:
>> But that's partly why I mentioned ivy-bibtex: solutions already exist
>> and there should be no need to re-invent the wheel?
>
> I kind of disagree.
>
> There's a middle ground between super minimal and fully-featured that
> I think is appropriate for oc-basic.

Sure.  I guess I am simply noting that an in-between solution, although
desirable, is not critical?  Of course, whatever gets implemented by
Nicolas will be excellent and I will likely end up using it!

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


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [wip-cite-new] Quick note about citation insertion
  2021-07-03  7:58               ` Nicolas Goaziou
  2021-07-03 14:57                 ` Eric S Fraga
@ 2021-07-06 12:11                 ` Bruce D'Arcus
  2021-07-07 22:59                   ` Nicolas Goaziou
  1 sibling, 1 reply; 33+ messages in thread
From: Bruce D'Arcus @ 2021-07-06 12:11 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Org Mode List

On Sat, Jul 3, 2021 at 3:58 AM Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:

> Anyway, I'll try to provide something a little more useful out of the
> box, based on your comment and Bruce D'Arcus suggestion.

Nicolas - I saw you pushed some changes, per the discussion.

First, my initial thought is the behavior at point is perfect.

Second, what's your intended way one enters a citation with two references?

In selectrum, I:

1. select one reference with RET
2. select another
3. C-j to exit

Is that the expected workflow and behavior?

Just want to confirm, as that doesn't work in Vertico, so I need to
figure out why (maybe a keybinding issue?).

Bruce


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [wip-cite-new] Quick note about citation insertion
  2021-07-06 12:11                 ` Bruce D'Arcus
@ 2021-07-07 22:59                   ` Nicolas Goaziou
  2021-07-08  0:38                     ` Bruce D'Arcus
  2021-07-08 11:41                     ` Bruce D'Arcus
  0 siblings, 2 replies; 33+ messages in thread
From: Nicolas Goaziou @ 2021-07-07 22:59 UTC (permalink / raw)
  To: Bruce D'Arcus; +Cc: Org Mode List

Hello,

"Bruce D'Arcus" <bdarcus@gmail.com> writes:

> Nicolas - I saw you pushed some changes, per the discussion.

Hey, that was a surprise ! ;)

So, here's an update. Now "oc-basic" provides a reasonable experience
for inserting references in a document. It also supports both CSL and
BibTeX bibliographies. Therefore, it is used as the default insertion
processor.

For a user, selecting another insertion processor is done by customizing
`org-cite-insert-processor' variable.


For a developer, there are now two ways to create an insert processor.

1. If you are happy with the global behaviour of "basic", but want to
   improve completion, I added the `org-cite-make-insert-processor'
   tool.

2. If you also want to change the behaviour, you need to write a new
   function from scratch.

Then you define the processor with either:

  (org-cite-register-processor 'my-insert-proc
    :insert (org-cite-make-insert-processor
             #'my-select-key
             #'my-select-style))                            ;situation 1

or

  (org-cite-register-processor 'my-insert-proc
   :insert #'my-function)                                   ;situation 2

> First, my initial thought is the behavior at point is perfect.

Ah!

> Second, what's your intended way one enters a citation with two references?
>
> In selectrum, I:
>
> 1. select one reference with RET
> 2. select another
> 3. C-j to exit
>
> Is that the expected workflow and behavior?

Yes, it is.  You need to enter the empty string to exit.  C-j is the way
to do that on Selectrum.  I don't know about Vertico.

Regards,
-- 
Nicolas Goaziou


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [wip-cite-new] Quick note about citation insertion
  2021-07-07 22:59                   ` Nicolas Goaziou
@ 2021-07-08  0:38                     ` Bruce D'Arcus
  2021-07-08 11:46                       ` Nicolas Goaziou
  2021-07-08 11:41                     ` Bruce D'Arcus
  1 sibling, 1 reply; 33+ messages in thread
From: Bruce D'Arcus @ 2021-07-08  0:38 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Org Mode List

On Wed, Jul 7, 2021 at 6:59 PM Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:

> For a developer, there are now two ways to create an insert processor.
>
> 1. If you are happy with the global behaviour of "basic", but want to
>    improve completion, I added the `org-cite-make-insert-processor'
>    tool.

Just a little thing:

Why is it:

org-cite-basic--complete-style

... rather than:

org-cite-basic-complete-style

I thought you would want to encourage reuse of that one, in particular?

Bruce


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [wip-cite-new] Quick note about citation insertion
  2021-07-07 22:59                   ` Nicolas Goaziou
  2021-07-08  0:38                     ` Bruce D'Arcus
@ 2021-07-08 11:41                     ` Bruce D'Arcus
  2021-07-08 11:44                       ` Nicolas Goaziou
  2021-07-08 12:48                       ` Eric S Fraga
  1 sibling, 2 replies; 33+ messages in thread
From: Bruce D'Arcus @ 2021-07-08 11:41 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Org Mode List

On Wed, Jul 7, 2021 at 6:59 PM Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:

> For a developer, there are now two ways to create an insert processor.
>
> 1. If you are happy with the global behaviour of "basic", but want to
>    improve completion, I added the `org-cite-make-insert-processor'
>    tool.

This was very helpful, so I just added a commit making use of it.

https://github.com/bdarcus/bibtex-actions#org-cite

So same org-cite-insert behavior as oc-basic, but using
bibtex-actions-read for the completion.

Bruce


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [wip-cite-new] Quick note about citation insertion
  2021-07-08 11:41                     ` Bruce D'Arcus
@ 2021-07-08 11:44                       ` Nicolas Goaziou
  2021-09-26 10:40                         ` Bastien
  2021-07-08 12:48                       ` Eric S Fraga
  1 sibling, 1 reply; 33+ messages in thread
From: Nicolas Goaziou @ 2021-07-08 11:44 UTC (permalink / raw)
  To: Bruce D'Arcus; +Cc: Org Mode List

Hello,

"Bruce D'Arcus" <bdarcus@gmail.com> writes:

> On Wed, Jul 7, 2021 at 6:59 PM Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
>
>> For a developer, there are now two ways to create an insert processor.
>>
>> 1. If you are happy with the global behaviour of "basic", but want to
>>    improve completion, I added the `org-cite-make-insert-processor'
>>    tool.
>
> This was very helpful, so I just added a commit making use of it.
>
> https://github.com/bdarcus/bibtex-actions#org-cite
>
> So same org-cite-insert behavior as oc-basic, but using
> bibtex-actions-read for the completion.

This is much better than "basic", indeed! :) Thank you for extending the
soon-to-be-born Org Cite ecosystem.

Regards,
-- 
Nicolas Goaziou


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [wip-cite-new] Quick note about citation insertion
  2021-07-08  0:38                     ` Bruce D'Arcus
@ 2021-07-08 11:46                       ` Nicolas Goaziou
  2021-07-08 11:52                         ` Bruce D'Arcus
  2021-07-08 13:19                         ` Bruce D'Arcus
  0 siblings, 2 replies; 33+ messages in thread
From: Nicolas Goaziou @ 2021-07-08 11:46 UTC (permalink / raw)
  To: Bruce D'Arcus; +Cc: Org Mode List

"Bruce D'Arcus" <bdarcus@gmail.com> writes:

> Just a little thing:
>
> Why is it:
>
> org-cite-basic--complete-style
>
> ... rather than:
>
> org-cite-basic-complete-style
>
> I thought you would want to encourage reuse of that one, in
> particular?

In this situation, the function I want to encourage re-using is
`org-cite-supported-styles'. `org-cite-basic--complete-style' is so
trivial that I didn't bother exporting it.


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [wip-cite-new] Quick note about citation insertion
  2021-07-08 11:46                       ` Nicolas Goaziou
@ 2021-07-08 11:52                         ` Bruce D'Arcus
  2021-07-08 13:19                         ` Bruce D'Arcus
  1 sibling, 0 replies; 33+ messages in thread
From: Bruce D'Arcus @ 2021-07-08 11:52 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Org Mode List

On Thu, Jul 8, 2021 at 7:46 AM Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:

> In this situation, the function I want to encourage re-using is
> `org-cite-supported-styles'. `org-cite-basic--complete-style' is so
> trivial that I didn't bother exporting it.

OK, I'll take a closer look at that.

Bruce


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [wip-cite-new] Quick note about citation insertion
  2021-07-08 11:41                     ` Bruce D'Arcus
  2021-07-08 11:44                       ` Nicolas Goaziou
@ 2021-07-08 12:48                       ` Eric S Fraga
  2021-07-08 13:04                         ` Bruce D'Arcus
  1 sibling, 1 reply; 33+ messages in thread
From: Eric S Fraga @ 2021-07-08 12:48 UTC (permalink / raw)
  To: Bruce D'Arcus; +Cc: Org Mode List, Nicolas Goaziou

On Thursday,  8 Jul 2021 at 07:41, Bruce D'Arcus wrote:
> This was very helpful, so I just added a commit making use of it.
>
> https://github.com/bdarcus/bibtex-actions#org-cite

Bruce,

this looks very good.

I know this is potentially off-topic for this list (not completely:
searching for references to cite is an integral part of my writing
activity) but I have lost track of what is going on in the emacs-sphere
when it comes to completion frameworks.  I use ivy/counsel.  Is there
somewhere a good summary of the state of play?  Would I wish to move to
another framework?

Thank you,
eric

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


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [wip-cite-new] Quick note about citation insertion
  2021-07-08 12:48                       ` Eric S Fraga
@ 2021-07-08 13:04                         ` Bruce D'Arcus
  2021-07-08 15:34                           ` Eric S Fraga
  0 siblings, 1 reply; 33+ messages in thread
From: Bruce D'Arcus @ 2021-07-08 13:04 UTC (permalink / raw)
  To: Org Mode List; +Cc: Nicolas Goaziou

On Thu, Jul 8, 2021 at 8:48 AM Eric S Fraga <e.fraga@ucl.ac.uk> wrote:
> ... I have lost track of what is going on in the emacs-sphere
> when it comes to completion frameworks.  I use ivy/counsel.  Is there
> somewhere a good summary of the state of play?  Would I wish to move to
> another framework?

You're not the only one. There's been a ton of activity on this new
generation of completing-read-based completion packages the past
year+.

And what's a bit difficult to grok initially is these are decoupled
packages that work together, which gives users more choice, but can
also be confusing.

Probably the best summary is on the Selectrum repo README. But there's
a lot there, so it might be a bit much.

I have also tried to summarize it on my README in a more focused way.

Note that that selectrum repo has some test scripts where you can kick
the tires with different options, using emacs -Q.

https://github.com/raxod502/selectrum/tree/master/test

I use an adapted version of those in my repo, so in that case you can
just do ./run.sh.

If you want to dive in, my suggestion is install and configure the
following, and experiment.

1. vertico and selectrum (completion UI; I prefer vertico these days,
but they're really similar, and they don't conflict if you have both
installed)
2. orderless (completion-style)
3. consult (counsel-like commands, and now enhanced multi-selection)
4. embark (contextual actions)

That should give you similar experience to what you have now, in a
more modular approach.

Bruce


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [wip-cite-new] Quick note about citation insertion
  2021-07-08 11:46                       ` Nicolas Goaziou
  2021-07-08 11:52                         ` Bruce D'Arcus
@ 2021-07-08 13:19                         ` Bruce D'Arcus
  1 sibling, 0 replies; 33+ messages in thread
From: Bruce D'Arcus @ 2021-07-08 13:19 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Org Mode List

On Thu, Jul 8, 2021 at 7:46 AM Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:

> In this situation, the function I want to encourage re-using is
> `org-cite-supported-styles'. `org-cite-basic--complete-style' is so
> trivial that I didn't bother exporting it.

Okay, I see now.

So `org-cite-supported-styles' returns what it sounds like; a list of styles.

((("author" "a")
  ("caps" "c"))
 (("noauthor" "na")
  ("bare" "b"))
 (("nocite" "n"))
 (("note" "ft")
  ("caps" "c")
  ("bare-caps" "bc"))
 (("numeric" "nb"))
 (("text" "t")
  ("caps" "c")
  ("bare-caps" "bc"))
 (("nil")
  ("caps" "c")
  ("bare-caps" "bc")
  ("bare" "b")))

 `org-cite-basic--complete-style' is "trivial" just in the sense it
only supports styles (not sub-styles), and one can imagine adding
annotations to make it easier for users to know what a given choice
will result in.

But that's not for you to worry about, or for oc-basic.

I'll think about it; not sure what the best path for a more
feature-full alternative would be ATM.

Bruce


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [wip-cite-new] Quick note about citation insertion
  2021-07-08 13:04                         ` Bruce D'Arcus
@ 2021-07-08 15:34                           ` Eric S Fraga
  0 siblings, 0 replies; 33+ messages in thread
From: Eric S Fraga @ 2021-07-08 15:34 UTC (permalink / raw)
  To: Bruce D'Arcus; +Cc: Org Mode List

Thank you for both the links and the suggestions!  Very helpful.  I will
start playing. :-)

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


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [wip-cite-new] Quick note about citation insertion
  2021-07-08 11:44                       ` Nicolas Goaziou
@ 2021-09-26 10:40                         ` Bastien
  0 siblings, 0 replies; 33+ messages in thread
From: Bastien @ 2021-09-26 10:40 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Org Mode List, Bruce D'Arcus

Hi all,

I'm marking the upstream bug as closed - feel free to resubmit it if
I misread the thread.

Thanks,

-- 
 Bastien


^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2021-09-26 10:41 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-02 16:10 [wip-cite-new] Quick note about citation insertion Nicolas Goaziou
2021-07-02 19:21 ` Bruce D'Arcus
2021-07-02 20:05   ` Nicolas Goaziou
2021-07-03  8:45     ` Bruce D'Arcus
2021-07-03  9:20       ` Nicolas Goaziou
2021-07-03  9:56         ` Bruce D'Arcus
2021-07-02 19:47 ` Bruce D'Arcus
2021-07-02 20:14   ` Nicolas Goaziou
2021-07-02 20:58     ` Bruce D'Arcus
2021-07-02 21:05       ` John Kitchin
2021-07-02 21:21         ` Nicolas Goaziou
2021-07-03  0:21           ` Bruce D'Arcus
2021-07-02 21:48       ` Nicolas Goaziou
2021-07-02 21:57         ` Bruce D'Arcus
2021-07-02 22:33           ` Nicolas Goaziou
2021-07-02 23:59             ` Bruce D'Arcus
2021-07-03  7:28             ` Eric S Fraga
2021-07-03  7:58               ` Nicolas Goaziou
2021-07-03 14:57                 ` Eric S Fraga
2021-07-03 15:09                   ` Bruce D'Arcus
2021-07-05 13:29                     ` Eric S Fraga
2021-07-06 12:11                 ` Bruce D'Arcus
2021-07-07 22:59                   ` Nicolas Goaziou
2021-07-08  0:38                     ` Bruce D'Arcus
2021-07-08 11:46                       ` Nicolas Goaziou
2021-07-08 11:52                         ` Bruce D'Arcus
2021-07-08 13:19                         ` Bruce D'Arcus
2021-07-08 11:41                     ` Bruce D'Arcus
2021-07-08 11:44                       ` Nicolas Goaziou
2021-09-26 10:40                         ` Bastien
2021-07-08 12:48                       ` Eric S Fraga
2021-07-08 13:04                         ` Bruce D'Arcus
2021-07-08 15:34                           ` Eric S Fraga

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).