Re: [PATCH] oc-csl: Add support for nocite citations

2022-07-07 Thread Ihor Radchenko
"Bruce D'Arcus"  writes:

> On Mon, Jul 4, 2022 at 7:54 AM Ihor Radchenko  wrote:
>
>> Since the fontification part appears to be unrelated to this particular
>> patch, I'd like to ask people who use CSL to test the patch.
>
> I just tested it, and it works as expected.

Thanks!
Applied onto main via b3b17cdb6.

Best,
Ihor



Re: [PATCH] oc-csl: Add support for nocite citations

2022-07-05 Thread Bruce D'Arcus
On Tue, Jul 5, 2022 at 3:28 PM Bruce D'Arcus  wrote:

> > Except, and I'm not sure if I'm misunderstanding some org detail, but
> > this doesn't suppress the global bibliography. Should it?
>
> Yes, and it does in oc-biblatex.

Sorry for the noise; disregard.

It was something with my testing setup.

Bruce



Re: [PATCH] oc-csl: Add support for nocite citations

2022-07-05 Thread Bruce D'Arcus
On Tue, Jul 5, 2022 at 3:17 PM Bruce D'Arcus  wrote:
>
> On Mon, Jul 4, 2022 at 7:54 AM Ihor Radchenko  wrote:
>
> > Since the fontification part appears to be unrelated to this particular
> > patch, I'd like to ask people who use CSL to test the patch.
>
> I just tested it, and it works as expected.
>
> Except, and I'm not sure if I'm misunderstanding some org detail, but
> this doesn't suppress the global bibliography. Should it?

Yes, and it does in oc-biblatex.

Bruce



Re: [PATCH] oc-csl: Add support for nocite citations

2022-07-05 Thread Bruce D'Arcus
On Mon, Jul 4, 2022 at 7:54 AM Ihor Radchenko  wrote:

> Since the fontification part appears to be unrelated to this particular
> patch, I'd like to ask people who use CSL to test the patch.

I just tested it, and it works as expected.

Except, and I'm not sure if I'm misunderstanding some org detail, but
this doesn't suppress the global bibliography. Should it?

#+bibliography: test.bib
#+cite_export: csl
[cite/nocite:@*]
#+print_bibliography:

# Local Variables:
# org-cite-global-bibliography: nil
# End:

Bruce



Re: [BUG] @* in [cite/nocite:@*] is a valid special LaTeX bibliography key, but it is highlighted using "error" face by oc.el (was: [PATCH] oc-csl: Add support for nocite citations)

2022-07-04 Thread Bruce D'Arcus
On Mon, Jul 4, 2022 at 8:57 AM András Simonyi  wrote:
> It seems to me that "*" as a key is sophisticated enough that if we have to 
> make a decision
> about the default fontification then it is better to err on the side
> of supposing that a user using it knows what they are doing,

+1

Bruce



Re: [BUG] @* in [cite/nocite:@*] is a valid special LaTeX bibliography key, but it is highlighted using "error" face by oc.el (was: [PATCH] oc-csl: Add support for nocite citations)

2022-07-04 Thread András Simonyi
Dear All,

On Mon, 4 Jul 2022 at 14:27, Ihor Radchenko  wrote:

> András Simonyi  writes:

> I do not agree.
> If someone sets up natbib for latex export and basic for other formats,
> "*" will not be correctly exported in those other formats (because basic
> does not support @* syntax) - something fontification should better
> highlight for the user.

yes, the basic export processor is, well, basic in certain respects.
But then this is the case with more advanced citation styles, e.g.
"locators" as well, which is supported by the biblatex export
processor and not by "basic"; nonetheless, the "basic" activation
processor's fontification doesn't signal "error" if someone uses the
"locators"  style, in fact it doesn't check whether a used citation
style is supported by any of the processors. It seems to me that "*"
as a key is sophisticated enough that if we have to make a decision
about the default fontification then it is better to err on the side
of supposing that a user using it knows what they are doing, Of
course, others' mileage may vary, and it'd be very interesting to hear
other opinions.

best wishes,
András



> Also, are there any similar non-key constructs in latex in addition to "*"?
>
> Best,
> Ihor



Re: [BUG] @* in [cite/nocite:@*] is a valid special LaTeX bibliography key, but it is highlighted using "error" face by oc.el (was: [PATCH] oc-csl: Add support for nocite citations)

2022-07-04 Thread Ihor Radchenko
András Simonyi  writes:

> I think that the problem with simply adding one or more new activation
> processors with different fontification for the "*" key is that Org
> has no way of knowing (at least for sure) which export processor will
> be used for a exporting a certain Org buffer, since it can depend on
> the chosen export backend (see the variable
> org-cite-export-processors). E.g., org-cite could be set up to use the
> "natbib" processor for "LaTeX" export and the "basic" processor for
> any other format.  I think that it'd be more in the spirit of the
> "basic" activation processor to be more permissive and not treat "*"
> as an error, similarly to citation styles not supported by the "basic"
> export processor but supported by others.

I do not agree.
If someone sets up natbib for latex export and basic for other formats,
"*" will not be correctly exported in those other formats (because basic
does not support @* syntax) - something fontification should better
highlight for the user.

Also, are there any similar non-key constructs in latex in addition to "*"?

Best,
Ihor



Re: [PATCH] oc-csl: Add support for nocite citations

2022-07-04 Thread Ihor Radchenko
András Simonyi  writes:

> Thanks, I have tried to address your comments in the attached new
> version of the patch.
> Note that the quotes around "csl" follow the manual's "Citation
> handling" chapter.

Since the fontification part appears to be unrelated to this particular
patch, I'd like to ask people who use CSL to test the patch. I do not
use CSL myself.

I have no further comments on the lisp part.

Best,
Ihor



Re: [BUG] @* in [cite/nocite:@*] is a valid special LaTeX bibliography key, but it is highlighted using "error" face by oc.el (was: [PATCH] oc-csl: Add support for nocite citations)

2022-07-04 Thread András Simonyi
Dear All,

On Sun, 3 Jul 2022 at 15:09, Ihor Radchenko  wrote:

> Then, oc-natbib, oc-biblatex, and oc-csl should be modified to provide
> an alternative activation function that will not highlight @* as
> non-existing key.
>
> Probably, we can even use an alternative "special" key face, not
> 'org-cite-key.

AFAICS, the situation is rather complex: Org (the main branch)
currently contains five export processors (basic, bibtex, natbib,
biblatex and csl), but only a single activation processor called
"basic". Of the five export processors the three LaTeX-based ones
already support the "*" key in nocite citations, and the CSL processor
could also with my proposed patch, leaving only the "basic" one
without this feature.

I think that the problem with simply adding one or more new activation
processors with different fontification for the "*" key is that Org
has no way of knowing (at least for sure) which export processor will
be used for a exporting a certain Org buffer, since it can depend on
the chosen export backend (see the variable
org-cite-export-processors). E.g., org-cite could be set up to use the
"natbib" processor for "LaTeX" export and the "basic" processor for
any other format.  I think that it'd be more in the spirit of the
"basic" activation processor to be more permissive and not treat "*"
as an error, similarly to citation styles not supported by the "basic"
export processor but supported by others.

best wishes,
András



[BUG] @* in [cite/nocite:@*] is a valid special LaTeX bibliography key, but it is highlighted using "error" face by oc.el (was: [PATCH] oc-csl: Add support for nocite citations)

2022-07-03 Thread Ihor Radchenko
John Kitchin  writes:

> It is a special command. See
>
> https://texfaq.org/FAQ-nocitestar
>
> It is used to put all entries in a bibtex file in the bibliography.
>
> Here is a minimal example Tex file that should list all the entries in
> mybibliography.bib
>
> \documentstyle{article}
> \begin{document}
> \nocite{*}
> \bibliographystyle{unsrt}
> \bibliography{mybibliography}
> \end{document}

Thanks for the clarification!
Then, oc-natbib, oc-biblatex, and oc-csl should be modified to provide
an alternative activation function that will not highlight @* as
non-existing key.

Probably, we can even use an alternative "special" key face, not
'org-cite-key.

Best,
Ihor



Re: [PATCH] oc-csl: Add support for nocite citations

2022-07-03 Thread John Kitchin
It is a special command. See

https://texfaq.org/FAQ-nocitestar

It is used to put all entries in a bibtex file in the bibliography.

Here is a minimal example Tex file that should list all the entries in
mybibliography.bib

\documentstyle{article}
\begin{document}
\nocite{*}
\bibliographystyle{unsrt}
\bibliography{mybibliography}
\end{document}


On Sun, Jul 3, 2022 at 8:35 AM Ihor Radchenko  wrote:

> "Bruce D'Arcus"  writes:
>
> > Ihor - on *, he is bringing oc-csl in line with the oc-natbib and
> > oc-biblatex processors.
>
> I am sorry, but I still do not understand. AFAIK, \nocite{*} is not a
> valid LaTeX command.
>
> Best,
> Ihor
>
> --
John

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


Re: [PATCH] oc-csl: Add support for nocite citations

2022-07-03 Thread Bruce D'Arcus
I don't know the internals, I just know it works from org, though I'm not
near a computer ATM.

On Sun, Jul 3, 2022, 8:34 AM Ihor Radchenko  wrote:

> "Bruce D'Arcus"  writes:
>
> > Ihor - on *, he is bringing oc-csl in line with the oc-natbib and
> > oc-biblatex processors.
>
> I am sorry, but I still do not understand. AFAIK, \nocite{*} is not a
> valid LaTeX command.
>
> Best,
> Ihor
>


Re: [PATCH] oc-csl: Add support for nocite citations

2022-07-03 Thread Ihor Radchenko
"Bruce D'Arcus"  writes:

> Ihor - on *, he is bringing oc-csl in line with the oc-natbib and
> oc-biblatex processors.

I am sorry, but I still do not understand. AFAIK, \nocite{*} is not a
valid LaTeX command.

Best,
Ihor



Re: [PATCH] oc-csl: Add support for nocite citations

2022-07-03 Thread Bruce D'Arcus
Ihor - on *, he is bringing oc-csl in line with the oc-natbib and
oc-biblatex processors.

On Sun, Jul 3, 2022, 7:57 AM Ihor Radchenko  wrote:

> András Simonyi  writes:
>
> >> By "*", do you mean something like [cite/n:@*]?
> >> If so, will it be correctly fontified as an existing citation?
> >
> > ... As for fontification, this is a very good
> > question! I've checked it now with the built-in "basic"
> > activation processor and it shows the "*" with an "error" face,
> > indicating that it's not a key in the bibliography file(s), which
> > might not be ideal. Nonetheless, this problem is not limited to or
> > introduced by this patch, because the same construct and
> > functionality is also supported by the "biblatex" and "natbib" export
> > processors.  Actually, the possibility of using "*" as a key comes
> > simply
> > from a citeproc-el change, not from oc-csl, I just thought that it is
> > obscure enough to merit an explicit mention in the NEWS file.
>
> I do understand that @* syntax is coming from citeproc-el. However, we
> are talking about changes to Org core. If Org highlights @* with 'error
> face, some users will be confused.
>
> Could you please elaborate about "the same construct and functionality
> is also supported by the "biblatex" and "natbib" export processors"?
> I cannot call myself expert in LaTeX, but I've never heard about LaTeX
> \cite/\nocite commands supporting "*" argument. I cannot find any traces
> of "*" functionality in oc-bibtelatex/oc-natbib as well.
>
> Best,
> Ihor
>
>
>


Re: [PATCH] oc-csl: Add support for nocite citations

2022-07-03 Thread Ihor Radchenko
András Simonyi  writes:

>> By "*", do you mean something like [cite/n:@*]?
>> If so, will it be correctly fontified as an existing citation?
>
> ... As for fontification, this is a very good
> question! I've checked it now with the built-in "basic"
> activation processor and it shows the "*" with an "error" face,
> indicating that it's not a key in the bibliography file(s), which
> might not be ideal. Nonetheless, this problem is not limited to or
> introduced by this patch, because the same construct and
> functionality is also supported by the "biblatex" and "natbib" export
> processors.  Actually, the possibility of using "*" as a key comes
> simply
> from a citeproc-el change, not from oc-csl, I just thought that it is
> obscure enough to merit an explicit mention in the NEWS file.

I do understand that @* syntax is coming from citeproc-el. However, we
are talking about changes to Org core. If Org highlights @* with 'error
face, some users will be confused.

Could you please elaborate about "the same construct and functionality
is also supported by the "biblatex" and "natbib" export processors"?
I cannot call myself expert in LaTeX, but I've never heard about LaTeX
\cite/\nocite commands supporting "*" argument. I cannot find any traces
of "*" functionality in oc-bibtelatex/oc-natbib as well.

Best,
Ihor




Re: [PATCH] oc-csl: Add support for nocite citations

2022-07-02 Thread András Simonyi
Dear Ihor,

thanks a lot for your reply!

On Sat, 2 Jul 2022 at 06:37, Ihor Radchenko  wrote:

> By "*", do you mean something like [cite/n:@*]?
> If so, will it be correctly fontified as an existing citation?

Yes I meant exactly that. As for fontification, this is a very good
question! I've checked it now with the built-in "basic"
activation processor and it shows the "*" with an "error" face,
indicating that it's not a key in the bibliography file(s), which
might not be ideal. Nonetheless, this problem is not limited to or
introduced by this patch, because the same construct and
functionality is also supported by the "biblatex" and "natbib" export
processors.  Actually, the possibility of using "*" as a key comes
simply
from a citeproc-el change, not from oc-csl, I just thought that it is
obscure enough to merit an explicit mention in the NEWS file.

> It would help to provide an example how to use "*" key.
> Also, I'd prefer if you follow doc/Documentation_Standards.org. Please
> use Org markup instead of `...' quotes.

Thanks, I have tried to address your comments in the attached new
version of the patch.
Note that the quotes around "csl" follow the manual's "Citation
handling" chapter.

> Why not simply
> (member (car (org-cite-citation-style citation info)) '("nocite" "n"))
> ?

Thanks, that is indeed simpler, I've changed the function's definition
accordingly.


best wishes,
András
From 7d2c6be97258ecbca4929e302d63b760bec078ad Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A1s=20Simonyi?= 
Date: Fri, 1 Jul 2022 10:24:17 +0200
Subject: [PATCH] oc-csl.el: Add support for nocite citations

* lisp/oc-csl.el (org-cite-csl--rendered-citations): Collect nocite
style citations in a separate list as required by the citeproc-el
API. Set the output of all nocite citations to the empty string.
(org-cite-csl--nocite-p): New helper predicate for checking whether a
citation is a nocite.
---
 etc/ORG-NEWS   | 11 +++
 lisp/oc-csl.el | 53 --
 2 files changed, 49 insertions(+), 15 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 902d70256..4cda357f1 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -239,7 +239,18 @@ This behaviour can be changed by supplying a =:align= parameter.
 
 The tabbing environment can be useful when generating simple tables which
 can be span multiple pages and when table cells are allowed to overflow.
+*** Support for =nocite= citations in the "csl" export processor
 
+The "csl" citation export processor now supports =nocite= style
+citations that add items to the printed bibliography without visible
+references in the text. Using the key =*= in a nocite citation, for
+instance,
+
+#+begin_src org
+[cite/n:@*]
+#+end_src
+
+includes all available items in the printed bibliography.
 ** New functions and changes in function arguments
 
 *** New function ~org-element-cache-map~ for quick mapping across Org elements
diff --git a/lisp/oc-csl.el b/lisp/oc-csl.el
index eb67092dd..a2bd6653c 100644
--- a/lisp/oc-csl.el
+++ b/lisp/oc-csl.el
@@ -59,9 +59,13 @@
 ;; - author (a), including bare (b), caps (c), bare-caps (bc), full (f),
 ;;   caps-full (cf), and bare-caps-full (bcf) variants,
 ;; - noauthor (na), including bare (b), caps (c) and bare-caps (bc) variants,
+;; - nocite (n),
 ;; - year (y), including a bare (b) variant,
 ;; - text (t). including caps (c), full (f), and caps-full (cf) variants,
 ;; - default style, including bare (b), caps (c) and bare-caps (bc) variants.
+;;
+;; Using "*" as a key in a nocite citation includes all available items in
+;; the printed bibliography.
 
 ;; CSL styles recognize "locator" in citation references' suffix.  For example,
 ;; in the citation
@@ -103,6 +107,7 @@
 (declare-function citeproc-create "ext:citeproc")
 (declare-function citeproc-citation-create "ext:citeproc")
 (declare-function citeproc-append-citations "ext:citeproc")
+(declare-function citeproc-add-uncited "ext:citeproc")
 (declare-function citeproc-render-citations "ext:citeproc")
 (declare-function citeproc-render-bib "ext:citeproc")
 (declare-function citeproc-hash-itemgetter-from-any "ext:citeproc")
@@ -296,6 +301,12 @@ INFO is the export state, as a property list."
(citeproc-proc-style
 (org-cite-csl--processor info
 
+(defun org-cite-csl--nocite-p (citation info)
+  "Non-nil when CITATION object's style is nocite.
+INFO is the export state, as a property list."
+  (member (car (org-cite-citation-style citation info))
+  '("nocite" "n")))
+
 (defun org-cite-csl--create-structure-params (citation info)
   "Return citeproc structure creation params for CITATION object.
 STYLE is the citation style, as a string or nil. INFO is the export state, as
@@ -535,20 +546,31 @@ INFO is the export state, as a property list.
 Return an alist (CITATION . OUTPUT) where CITATION object has been rendered as
 OUTPUT using Citeproc."
   (or (plist-get info :cite-citeproc-rendered-citations)
-  (let* ((citations 

Re: [PATCH] oc-csl: Add support for nocite citations

2022-07-01 Thread Ihor Radchenko
András Simonyi  writes:

> the attached patch adds support for nocite citations in the csl
> org-cite export processor, including support for using the special key
> "*" to include all entries in the bibliography.

Thanks!
By "*", do you mean something like [cite/n:@*]?
If so, will it be correctly fontified as an existing citation?

> +*** Support for nocite citations in the csl export processor
>  
> +The csl citation export processor now supports `nocite' style
> +citations that add items to the printed bibliography without visible
> +references in the text. Using the key `*' in a nocite citation
> +includes all available items in the printed bibliography.

It would help to provide an example how to use "*" key.
Also, I'd prefer if you follow doc/Documentation_Standards.org. Please
use Org markup instead of `...' quotes.

> +(defun org-cite-csl--nocite-p (citation info)
> +  "Non-nil when CITATION object's style is nocite.
> +INFO is the export state, as a property list."
> +  (when-let ((style (car (org-cite-citation-style citation info
> +(or (string= style "nocite") (string= style "n"

Why not simply
(member (car (org-cite-citation-style citation info)) '("nocite" "n"))
?

Best,
Ihor



[PATCH] oc-csl: Add support for nocite citations

2022-07-01 Thread András Simonyi
Dear All,

the attached patch adds support for nocite citations in the csl
org-cite export processor, including support for using the special key
"*" to include all entries in the bibliography.


best wishes,
András
From 3e6514d2e2f4fa68462a02578880b126e3116739 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A1s=20Simonyi?= 
Date: Fri, 1 Jul 2022 10:24:17 +0200
Subject: [PATCH] oc-csl.el: Add support for nocite citations

* lisp/oc-csl.el (org-cite-csl--rendered-citations): Collect nocite
style citations in a separate list as required by the citeproc-el
API. Set the output of all nocite citations to the empty string.
(org-cite-csl--nocite-p): New helper predicate for checking whether a
citation is a nocite.
---
 etc/ORG-NEWS   |  5 +
 lisp/oc-csl.el | 53 --
 2 files changed, 43 insertions(+), 15 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 902d70256..0f7a9e825 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -239,7 +239,12 @@ This behaviour can be changed by supplying a =:align= parameter.
 
 The tabbing environment can be useful when generating simple tables which
 can be span multiple pages and when table cells are allowed to overflow.
+*** Support for nocite citations in the csl export processor
 
+The csl citation export processor now supports `nocite' style
+citations that add items to the printed bibliography without visible
+references in the text. Using the key `*' in a nocite citation
+includes all available items in the printed bibliography.
 ** New functions and changes in function arguments
 
 *** New function ~org-element-cache-map~ for quick mapping across Org elements
diff --git a/lisp/oc-csl.el b/lisp/oc-csl.el
index eb67092dd..05e4fa976 100644
--- a/lisp/oc-csl.el
+++ b/lisp/oc-csl.el
@@ -59,9 +59,13 @@
 ;; - author (a), including bare (b), caps (c), bare-caps (bc), full (f),
 ;;   caps-full (cf), and bare-caps-full (bcf) variants,
 ;; - noauthor (na), including bare (b), caps (c) and bare-caps (bc) variants,
+;; - nocite (n),
 ;; - year (y), including a bare (b) variant,
 ;; - text (t). including caps (c), full (f), and caps-full (cf) variants,
 ;; - default style, including bare (b), caps (c) and bare-caps (bc) variants.
+;;
+;; Using "*" as a key in a nocite citation includes all available items in
+;; the printed bibliography.
 
 ;; CSL styles recognize "locator" in citation references' suffix.  For example,
 ;; in the citation
@@ -103,6 +107,7 @@
 (declare-function citeproc-create "ext:citeproc")
 (declare-function citeproc-citation-create "ext:citeproc")
 (declare-function citeproc-append-citations "ext:citeproc")
+(declare-function citeproc-add-uncited "ext:citeproc")
 (declare-function citeproc-render-citations "ext:citeproc")
 (declare-function citeproc-render-bib "ext:citeproc")
 (declare-function citeproc-hash-itemgetter-from-any "ext:citeproc")
@@ -296,6 +301,12 @@ INFO is the export state, as a property list."
(citeproc-proc-style
 (org-cite-csl--processor info
 
+(defun org-cite-csl--nocite-p (citation info)
+  "Non-nil when CITATION object's style is nocite.
+INFO is the export state, as a property list."
+  (when-let ((style (car (org-cite-citation-style citation info
+(or (string= style "nocite") (string= style "n"
+
 (defun org-cite-csl--create-structure-params (citation info)
   "Return citeproc structure creation params for CITATION object.
 STYLE is the citation style, as a string or nil. INFO is the export state, as
@@ -535,20 +546,31 @@ INFO is the export state, as a property list.
 Return an alist (CITATION . OUTPUT) where CITATION object has been rendered as
 OUTPUT using Citeproc."
   (or (plist-get info :cite-citeproc-rendered-citations)
-  (let* ((citations (org-cite-list-citations info))
- (processor (org-cite-csl--processor info))
- (structures
-  (mapcar (lambda (c) (org-cite-csl--create-structure c info))
-  citations)))
-(citeproc-append-citations structures processor)
-(let* ((rendered
-(citeproc-render-citations
- processor
- (org-cite-csl--output-format info)
- (org-cite-csl--no-citelinks-p info)))
-   (result (seq-mapn #'cons citations rendered)))
-  (plist-put info :cite-citeproc-rendered-citations result)
-  result
+  (let ((citations (org-cite-list-citations info))
+	(processor (org-cite-csl--processor info))
+	normal-citations nocite-ids)
+	(dolist (citation citations)
+	  (if (org-cite-csl--nocite-p citation info)
+	  (setq nocite-ids (append (org-cite-get-references citation t) nocite-ids))
+	(push citation normal-citations)))
+	(let ((structures
+	   (mapcar (lambda (c) (org-cite-csl--create-structure c info))
+		   (nreverse normal-citations
+	  (citeproc-append-citations structures processor))
+	(when nocite-ids
+	  (citeproc-add-uncited nocite-ids