Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

org-ref invalid org-store-link in org babel #433

Closed
stardiviner opened this issue May 7, 2017 · 11 comments
Closed

org-ref invalid org-store-link in org babel #433

stardiviner opened this issue May 7, 2017 · 11 comments

Comments

@stardiviner
Copy link

When I try to org-store-link in an opened org babel src block like this:

#+BEGIN_SRC clojure
(defn ) 
#+END_SRC

It should be work like this:

#+BEGIN_SRC clojure
(defn )                                                             (ref:hello)
#+END_SRC

But it failed with error:

 Debugger entered--Lisp error: (wrong-type-argument stringp nil)
   looking-at(nil)
   org-element-context()
   org-label-store-link()
   org-store-link(nil)
   ...
   funcall-interactively(org-store-link nil)
   call-interactively(org-store-link nil nil)
   command-execute(org-store-link)

I tried to edebug this, found related to org-ref. Then I confirmed with minimal Emacs config emacs -q -l minimal-init.el.

Emacs version: 26.0.50 build from master source code
Org-mode version: 9.0.6 install from MELPA
org-ref version: 1.0.0 (git-commit 10dc99582ba866fb825443d1bd2132920b9db39f)

@jkitchin
Copy link
Owner

jkitchin commented May 7, 2017

I can't reproduce the error. (org-store-link) in a code block for me stores a reference to the heading the block is in. Where in org-ref did you find the problem to come from?

@stardiviner
Copy link
Author

Did you open the src block with [C-c '] then org-store-link? It will create a code ref like (ref:<string you input>), Then you can org-inser-link ([C-c C-l]) to insert link to (ref:<string you input>). Instead of the heading that the block is in.

@stardiviner
Copy link
Author

Have not found where the org-ref problem comes from, but I found if I toggle org-ref, then the error will occurs.

@jkitchin
Copy link
Owner

jkitchin commented May 7, 2017

yes, that works fine for me. below, i opened the block, ran org-store-link and typed in hello. Then closed the block and used C-c C-l to insert the link.

#+BEGIN_SRC python
print(5)                                                            (ref:hello)
#+END_SRC

[[(hello)]]

@jagrg
Copy link
Contributor

jagrg commented May 8, 2017

I think it's a bug in org-store-link. It works with the change below, but I'm not sure why it works with python, but not clojure. Maybe raise an issue in the Org-mode mailing list.

modified   lisp/org.el
@@ -9730,7 +9730,7 @@ active region."
 	     (setq sfuns
 		   (delq
 		    nil (mapcar (lambda (f)
-				  (let (fs) (if (funcall f) (push f fs))))
+				  (let (fs) (if (and (stringp f) (funcall f)) (push f fs))))
 				(org-store-link-functions)))
 		   sfunsn (mapcar (lambda (fu) (symbol-name (car fu))) sfuns))
 	     (or (and (cdr sfuns)

@stardiviner
Copy link
Author

Confirmed, this patch works. @jagrg Can you send this patch to Org-mode Mailing List?

@jagrg
Copy link
Contributor

jagrg commented May 8, 2017 via email

@stardiviner
Copy link
Author

Ok, I will send this patch to mailing list. Thanks for this patch.

jkitchin added a commit that referenced this issue May 9, 2017
The issue is from trying to store a link in a non-org-buffer.
@jkitchin
Copy link
Owner

jkitchin commented May 9, 2017

It was org-ref after all. I think I have pushed a fix for it. That patch should be unnecessary now. Thanks for reporting it and digging into it!

@jagrg
Copy link
Contributor

jagrg commented May 9, 2017 via email

@jkitchin
Copy link
Owner

jkitchin commented May 9, 2017

it did eventually confirm org-ref was to blame ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants