emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: Jeremias Gonzalez <jerzor@pacbell.net>
Cc: Org-Mode Mailing List <emacs-orgmode@gnu.org>
Subject: Re: org-bibtex-yank failing with error Wrong type argument: stringp, nil
Date: Sun, 13 Aug 2023 15:44:43 +0000	[thread overview]
Message-ID: <87r0o7dk0k.fsf@localhost> (raw)
In-Reply-To: <CAKmvNNRe7L=RwTxBYS_Yf1gG7wi0Z5k2y3M24uATCF+8p35XQg@mail.gmail.com>

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

Jeremias Gonzalez <jerzor@pacbell.net> writes:

>> Do I understand correctly that you attempted to run org-bibtex-read from
>> a non-bibtex buffer?
>>
>
> At a top level, I was using org-bibtex-yank with an org buffer (and in my
> ideal case with no bibtex buffers whatsoever) as the documentation for that
> function only requires bibtex to be in the kill ring. However, yes,
> org-bibtex-yank calls org-bibtex-read, and I was doing so (in the ideal
> case) with a non-bibtex buffer.

Does the attached patch fix the problem?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-bibtex-yank-Fix-bibtex-parser-not-initialized-in.patch --]
[-- Type: text/x-patch, Size: 1354 bytes --]

From 67c15a645f98f25af4db37830d632e9daf875e5e Mon Sep 17 00:00:00 2001
Message-ID: <67c15a645f98f25af4db37830d632e9daf875e5e.1691941444.git.yantar92@posteo.net>
From: Ihor Radchenko <yantar92@posteo.net>
Date: Sun, 13 Aug 2023 18:41:59 +0300
Subject: [PATCH] org-bibtex-yank: Fix bibtex parser not initialized in temp
 buffer

* lisp/ol-bibtex.el (org-bibtex-yank): Make sure that we parse bibtex
entry from the kill ring in a `bibtex-mode' buffer.  Otherwise,
calling `org-bibtex-read' (that calls `bibtex-parse-entry') may err
because some Bibtex parser variables are not initialized.

Reported-by: J. G. <jerzor@pacbell.net>
Link: https://orgmode.org/list/1939460027.3272000.1691771671040@mail.yahoo.com
---
 lisp/ol-bibtex.el | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lisp/ol-bibtex.el b/lisp/ol-bibtex.el
index 4308424a3..17fbb9fbd 100644
--- a/lisp/ol-bibtex.el
+++ b/lisp/ol-bibtex.el
@@ -765,7 +765,10 @@ (defun org-bibtex-yank ()
   "If kill ring holds a bibtex entry yank it as an Org headline."
   (interactive)
   (let (entry)
-    (with-temp-buffer (yank 1) (setf entry (org-bibtex-read)))
+    (with-temp-buffer
+      (yank 1)
+      (bibtex-mode)
+      (setf entry (org-bibtex-read)))
     (if entry
 	(org-bibtex-write)
       (error "Yanked text does not appear to contain a BibTeX entry"))))
-- 
2.41.0


[-- 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>

  reply	other threads:[~2023-08-13 15:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1939460027.3272000.1691771671040.ref@mail.yahoo.com>
2023-08-11 16:34 ` org-bibtex-yank failing with error Wrong type argument: stringp, nil J. G.
2023-08-12  4:15   ` J. G.
2023-08-13  7:57     ` Ihor Radchenko
2023-08-13 15:30       ` Jeremias Gonzalez
2023-08-13 15:44         ` Ihor Radchenko [this message]
2023-08-13 16:15           ` Jeremias Gonzalez
2023-08-13 16:25             ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r0o7dk0k.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=emacs-orgmode@gnu.org \
    --cc=jerzor@pacbell.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).