emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [BUG] Exporting non-existent citations in oc-basic [9.6-pre (release_9.5.5-989-gd972cf @ /home/yantar92/.emacs.d/straight/build/org/)]
@ 2022-10-17  7:30 Ihor Radchenko
  2022-11-16  4:34 ` [PATCH] Display ?? for missing citations on export (was: [BUG] Exporting non-existent citations in oc-basic [9.6-pre (release_9.5.5-989-gd972cf @ /home/yantar92/.emacs.d/straight/build/org/)]) Ihor Radchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Ihor Radchenko @ 2022-10-17  7:30 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

Consider the following Org file:

------------
[cite:@key]
#+print_bibliography:
That’s it!
------------
@key is not in the default bibliography and the bibliography processor is set to basic

Open the file and execute C-c C-e t U (export to ascii)

An error is thrown and export fails when attempting to print the
bibliography.

It does not matter if default bibliography actually contains anything.
Just that the key is not valid.

Can someone using citations often confirm?


Emacs  : GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.34, cairo version 1.16.0)
 of 2022-10-13
Package: Org mode version 9.6-pre (release_9.5.5-989-gd972cf @
 /home/yantar92/.emacs.d/straight/build/org/)

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


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

* [PATCH] Display ?? for missing citations on export (was: [BUG] Exporting non-existent citations in oc-basic [9.6-pre (release_9.5.5-989-gd972cf @ /home/yantar92/.emacs.d/straight/build/org/)])
  2022-10-17  7:30 [BUG] Exporting non-existent citations in oc-basic [9.6-pre (release_9.5.5-989-gd972cf @ /home/yantar92/.emacs.d/straight/build/org/)] Ihor Radchenko
@ 2022-11-16  4:34 ` Ihor Radchenko
  2022-12-29 14:26   ` Ihor Radchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Ihor Radchenko @ 2022-11-16  4:34 UTC (permalink / raw)
  To: emacs-orgmode

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

Ihor Radchenko <yantar92@posteo.net> writes:

> Consider the following Org file:
>
> ------------
> [cite:@key]
> #+print_bibliography:
> That’s it!
> ------------
> @key is not in the default bibliography and the bibliography processor is set to basic
>
> Open the file and execute C-c C-e t U (export to ascii)
>
> An error is thrown and export fails when attempting to print the
> bibliography.

The problem with error has been solved in another patch.

However, the non-existing keys are exported awkwardly as "(, )".

I suggest approaching the missing citations similar to LaTeX and
highlight them with ??: (??, ????) by default.

See the attached patch.

WDYT?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-oc-basic-Display-in-place-of-missing-citations-on-ex.patch --]
[-- Type: text/x-patch, Size: 2498 bytes --]

From dc26b1d84c7745080f26e0f194a4deb003a0f88f Mon Sep 17 00:00:00 2001
Message-Id: <dc26b1d84c7745080f26e0f194a4deb003a0f88f.1668573145.git.yantar92@posteo.net>
From: Ihor Radchenko <yantar92@posteo.net>
Date: Wed, 16 Nov 2022 12:29:17 +0800
Subject: [PATCH] oc-basic: Display ?? in place of missing citations on export

* lisp/oc-basic.el (org-cite-basic--format-author-year):
(org-cite-basic-export-citation): Display "????" for missing year and
"??"  for missing other fields.

Reported-by: Ihor Radchenko <yantar92@posteo.net>
Link: https://orgmode.org/list/871qr6kiuv.fsf@localhost
---
 lisp/oc-basic.el | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/lisp/oc-basic.el b/lisp/oc-basic.el
index 3ef7a37e3..fdfee849e 100644
--- a/lisp/oc-basic.el
+++ b/lisp/oc-basic.el
@@ -580,8 +580,8 @@ (defun org-cite-basic--format-author-year (citation format-cite format-ref info)
                      (suffix (org-element-property :suffix ref)))
                  (funcall format-ref
                           prefix
-                          (org-cite-basic--get-author k info)
-                          (org-cite-basic--get-year k info)
+                          (or (org-cite-basic--get-author k info) "??")
+                          (or (org-cite-basic--get-year k info) "????")
                           suffix)))
              (org-cite-get-references citation)
              org-cite-basic-author-year-separator)
@@ -652,15 +652,17 @@ (defun org-cite-basic-export-citation (citation style _ info)
          (org-export-data
           (mapconcat
            (lambda (key)
-             (let ((author (org-cite-basic--get-author key info)))
-               (if caps (capitalize author) author)))
+             (or
+              (let ((author (org-cite-basic--get-author key info)))
+                (if caps (capitalize author) author))
+              "??"))
            (org-cite-get-references citation t)
            org-cite-basic-author-year-separator)
           info)))
       ;; "noauthor" style.
       (`(,(or "noauthor" "na") . ,variant)
        (format (if (funcall has-variant-p variant 'bare) "%s" "(%s)")
-               (mapconcat (lambda (key) (org-cite-basic--get-year key info))
+               (mapconcat (lambda (key) (or (org-cite-basic--get-year key info) "????"))
                           (org-cite-get-references citation t)
                           org-cite-basic-author-year-separator)))
       ;; "nocite" style.
-- 
2.35.1


[-- Attachment #3: Type: text/plain, Size: 224 bytes --]


-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

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

* Re: [PATCH] Display ?? for missing citations on export (was: [BUG] Exporting non-existent citations in oc-basic [9.6-pre (release_9.5.5-989-gd972cf @ /home/yantar92/.emacs.d/straight/build/org/)])
  2022-11-16  4:34 ` [PATCH] Display ?? for missing citations on export (was: [BUG] Exporting non-existent citations in oc-basic [9.6-pre (release_9.5.5-989-gd972cf @ /home/yantar92/.emacs.d/straight/build/org/)]) Ihor Radchenko
@ 2022-12-29 14:26   ` Ihor Radchenko
  0 siblings, 0 replies; 3+ messages in thread
From: Ihor Radchenko @ 2022-12-29 14:26 UTC (permalink / raw)
  To: emacs-orgmode

Ihor Radchenko <yantar92@posteo.net> writes:

> The problem with error has been solved in another patch.
>
> However, the non-existing keys are exported awkwardly as "(, )".
>
> I suggest approaching the missing citations similar to LaTeX and
> highlight them with ??: (??, ????) by default.
>
> See the attached patch.
>
> WDYT?

Applied onto main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=fbd08a0d9

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


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

end of thread, other threads:[~2022-12-29 14:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-17  7:30 [BUG] Exporting non-existent citations in oc-basic [9.6-pre (release_9.5.5-989-gd972cf @ /home/yantar92/.emacs.d/straight/build/org/)] Ihor Radchenko
2022-11-16  4:34 ` [PATCH] Display ?? for missing citations on export (was: [BUG] Exporting non-existent citations in oc-basic [9.6-pre (release_9.5.5-989-gd972cf @ /home/yantar92/.emacs.d/straight/build/org/)]) Ihor Radchenko
2022-12-29 14:26   ` Ihor Radchenko

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