emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [wip-cite-new] experimental citeproc-el based activation processor
@ 2021-06-12 11:30 András Simonyi
  2021-06-12 14:46 ` Nicolas Goaziou
  0 siblings, 1 reply; 8+ messages in thread
From: András Simonyi @ 2021-06-12 11:30 UTC (permalink / raw)
  To: emacs-orgmode list

Dear All,

playing with the new citation API (which is already very impressive
and usable!) I cobbled together an "activation processor" which
fontifies Org citations using citeproc-el generated previews (when the
cursor is elsewhere). It also shows the full references as a tooltip
on mouse-over. Currently everything is very experimental, but if any
of you is willing to give it a try it can be found at
https://github.com/andras-simonyi/org-cite-csl-activate, and, of
course, any feedback is welcome.

best regards,
András


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

* Re: [wip-cite-new] experimental citeproc-el based activation processor
  2021-06-12 11:30 [wip-cite-new] experimental citeproc-el based activation processor András Simonyi
@ 2021-06-12 14:46 ` Nicolas Goaziou
  2021-06-12 15:43   ` Timothy
  0 siblings, 1 reply; 8+ messages in thread
From: Nicolas Goaziou @ 2021-06-12 14:46 UTC (permalink / raw)
  To: András Simonyi; +Cc: emacs-orgmode list

Hello,

András Simonyi <andras.simonyi@gmail.com> writes:

> playing with the new citation API (which is already very impressive
> and usable!) I cobbled together an "activation processor" which
> fontifies Org citations using citeproc-el generated previews (when the
> cursor is elsewhere). It also shows the full references as a tooltip
> on mouse-over. Currently everything is very experimental, but if any
> of you is willing to give it a try it can be found at
> https://github.com/andras-simonyi/org-cite-csl-activate, and, of
> course, any feedback is welcome.

This looks very nice already! Thanks for sharing.

It may make sense to merge it with "oc-csl.el" at some point. If that
suits you, there are a few gotchas:

- `alist' library isn't usable in Org, as it didn't exist in Emacs 24.3.
  So, there's unfortunately no `alist-get' for us.

- `<=' was not a variadic function back in Emacs 24.3, so (<= beg
  (point) end) is not possible either.


In addition, I have a couple of comments:

- As suggested by Bruce D'Arcus, we might move `org-cite-get-boundaries'
  in `oc.el' proper, since it is also used elsewhere (at least in
  "oc-basic.el").

- Nitpick: (car element) => (org-element-type element)

- I think it is inefficient to call `org-element-context' in
  `org-cite-csl-activate--sensor-fun'. You may as well store the parsed
  object as a text property on the citation during fontification, and
  read the property in the function above to know where you are.

- I am also wondering about the call of `org-element-parse-buffer' in
  `org-cite-csl-activate-render-all'. It is not wrong per se, but it is
  only optimal when citation density in every part of the document is
  not low. This might not be the most common case. The other option is
  to `re-search-forward' for `org-element-citation-prefix-re' and then
  call `org-element-context' at point.

  Of course, optimizing `org-cite-csl-activate-render-all' may not be
  the top priority, since some latency is to be expected anyway.

WDYT?

Regards,
-- 
Nicolas Goaziou


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

* Re: [wip-cite-new] experimental citeproc-el based activation processor
  2021-06-12 14:46 ` Nicolas Goaziou
@ 2021-06-12 15:43   ` Timothy
  2021-06-12 15:45     ` Timothy
  0 siblings, 1 reply; 8+ messages in thread
From: Timothy @ 2021-06-12 15:43 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode, András Simonyi


Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> It may make sense to merge it with "oc-csl.el" at some point. If that
> suits you, there are a few gotchas:
>
> - `alist' library isn't usable in Org, as it didn't exist in Emacs 24.3.
>   So, there's unfortunately no `alist-get' for us.
>
> - `<=' was not a variadic function back in Emacs 24.3, so (<= beg
>   (point) end) is not possible either.

Regarding the Emacs 24.3 requirement, I haven't got the thread on hand
but IIRC Bastien said that he will bump Org's minimum Emacs to 25 in the
9.5 release. As long as I'm not mis-remembering, the above should be
fine.

--
Timothy


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

* Re: [wip-cite-new] experimental citeproc-el based activation processor
  2021-06-12 15:43   ` Timothy
@ 2021-06-12 15:45     ` Timothy
  2021-06-12 16:03       ` Bruce D'Arcus
  2021-06-12 19:43       ` Nicolas Goaziou
  0 siblings, 2 replies; 8+ messages in thread
From: Timothy @ 2021-06-12 15:45 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode, András Simonyi


Update: I found the thread, https://orgmode.org/list/87lf90b5ey.fsf@gnu.org/

Timothy <tecosaur@gmail.com> writes:

> Regarding the Emacs 24.3 requirement, I haven't got the thread on hand
> but IIRC Bastien said that he will bump Org's minimum Emacs to 25 in the
> 9.5 release. As long as I'm not mis-remembering, the above should be
> fine.


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

* Re: [wip-cite-new] experimental citeproc-el based activation processor
  2021-06-12 15:45     ` Timothy
@ 2021-06-12 16:03       ` Bruce D'Arcus
  2021-06-12 19:43       ` Nicolas Goaziou
  1 sibling, 0 replies; 8+ messages in thread
From: Bruce D'Arcus @ 2021-06-12 16:03 UTC (permalink / raw)
  To: Timothy; +Cc: org-mode-email, András Simonyi, Nicolas Goaziou

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

Good; I was wondering about that!

On Sat, Jun 12, 2021, 8:47 AM Timothy <tecosaur@gmail.com> wrote:

>
> Update: I found the thread,
> https://orgmode.org/list/87lf90b5ey.fsf@gnu.org/
>
> Timothy <tecosaur@gmail.com> writes:
>
> > Regarding the Emacs 24.3 requirement, I haven't got the thread on hand
> > but IIRC Bastien said that he will bump Org's minimum Emacs to 25 in the
> > 9.5 release. As long as I'm not mis-remembering, the above should be
> > fine.
>
>

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

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

* Re: [wip-cite-new] experimental citeproc-el based activation processor
  2021-06-12 15:45     ` Timothy
  2021-06-12 16:03       ` Bruce D'Arcus
@ 2021-06-12 19:43       ` Nicolas Goaziou
  2021-06-15  7:12         ` András Simonyi
  1 sibling, 1 reply; 8+ messages in thread
From: Nicolas Goaziou @ 2021-06-12 19:43 UTC (permalink / raw)
  To: Timothy; +Cc: emacs-orgmode, András Simonyi

Hello,

Timothy <tecosaur@gmail.com> writes:

> Update: I found the thread,
> https://orgmode.org/list/87lf90b5ey.fsf@gnu.org/

Ah! I forgot about that. Thanks for the heads-up.

András: feel free to disregard that part of my message.

Regards,
-- 
Nicolas Goaziou


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

* Re: [wip-cite-new] experimental citeproc-el based activation processor
  2021-06-12 19:43       ` Nicolas Goaziou
@ 2021-06-15  7:12         ` András Simonyi
  2021-06-22 18:08           ` Nicolas Goaziou
  0 siblings, 1 reply; 8+ messages in thread
From: András Simonyi @ 2021-06-15  7:12 UTC (permalink / raw)
  To: Timothy, emacs-orgmode list, András Simonyi

Dear All,

thanks for the positive feedback, and sorry for the late reply.

On Sat, 12 Jun 2021 at 16:46, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:

> It may make sense to merge it with "oc-csl.el" at some point. If that
> suits you,

Absolutely, thanks for the suggestion!

> In addition, I have a couple of comments:
>
> - As suggested by Bruce D'Arcus, we might move `org-cite-get-boundaries'
>   in `oc.el' proper, since it is also used elsewhere (at least in
>   "oc-basic.el").

sure, it makes more sense there, especially because I took the
fragment from your code IIRC (apologies for the lack of explicit
attribution)

> - Nitpick: (car element) => (org-element-type element)

I was actually wondering about this when I wrote the code and if I may
nitpick on the nitpick, I find the documentation a bit confusing in
this respect. If the list representation is meant to be
internal/private only (I guess that is the case), then maybe this
should be more explicit in the docstrings, because now the docstring
of `org-element-context' says

"Return smallest element or object around point.

Return value is a list like (TYPE PROPS) [...]"

Omitting the second part or having something like "Internally, return
value is [...]" would go a long way toward conveying the message that
one shouldn't rely on the list representation.

> - I think it is inefficient to call `org-element-context' in
>   `org-cite-csl-activate--sensor-fun'. You may as well store the parsed
>   object as a text property on the citation during fontification, and
>   read the property in the function above to know where you are.

Thanks for the suggestion, I'll certainly implement this!

> - I am also wondering about the call of `org-element-parse-buffer' in
>   `org-cite-csl-activate-render-all'. It is not wrong per se, but it is
>   only optimal when citation density in every part of the document is
>   not low. This might not be the most common case. The other option is
>   to `re-search-forward' for `org-element-citation-prefix-re' and then
>   call `org-element-context' at point.

>   Of course, optimizing `org-cite-csl-activate-render-all' may not be
>   the top priority, since some latency is to be expected anyway.

Thanks for this as well, I'll switch to the more efficient approach
you suggested.

Best regards,
András


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

* Re: [wip-cite-new] experimental citeproc-el based activation processor
  2021-06-15  7:12         ` András Simonyi
@ 2021-06-22 18:08           ` Nicolas Goaziou
  0 siblings, 0 replies; 8+ messages in thread
From: Nicolas Goaziou @ 2021-06-22 18:08 UTC (permalink / raw)
  To: András Simonyi; +Cc: emacs-orgmode list, Timothy

Hello,

András Simonyi <andras.simonyi@gmail.com> writes:

>> - As suggested by Bruce D'Arcus, we might move `org-cite-get-boundaries'
>>   in `oc.el' proper, since it is also used elsewhere (at least in
>>   "oc-basic.el").
>
> sure, it makes more sense there, especially because I took the
> fragment from your code IIRC (apologies for the lack of explicit
> attribution)

No problem: I stole it back from you! ;) I added `org-cite-boundaries'
to "oc.el", so your library can make use of it (after a rebase).

>> - Nitpick: (car element) => (org-element-type element)
>
> I was actually wondering about this when I wrote the code and if I may
> nitpick on the nitpick, I find the documentation a bit confusing in
> this respect. If the list representation is meant to be
> internal/private only (I guess that is the case), then maybe this
> should be more explicit in the docstrings, because now the docstring
> of `org-element-context' says
>
> "Return smallest element or object around point.
>
> Return value is a list like (TYPE PROPS) [...]"
>
> Omitting the second part or having something like "Internally, return
> value is [...]" would go a long way toward conveying the message that
> one shouldn't rely on the list representation.

It's not that one shouldn't rely on the list representation, but the
expressiveness of `car' is very low, whereas `org-element-type' is
explicit. I was merely suggesting to lean towards expressiveness here.

Regards,
-- 
Nicolas Goaziou


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

end of thread, other threads:[~2021-06-22 18:10 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-06-12 11:30 [wip-cite-new] experimental citeproc-el based activation processor András Simonyi
2021-06-12 14:46 ` Nicolas Goaziou
2021-06-12 15:43   ` Timothy
2021-06-12 15:45     ` Timothy
2021-06-12 16:03       ` Bruce D'Arcus
2021-06-12 19:43       ` Nicolas Goaziou
2021-06-15  7:12         ` András Simonyi
2021-06-22 18:08           ` Nicolas Goaziou

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).