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

support jedi:goto-definition from within dedicated src-block buffers in org-babel #350

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

methuselah-0
Copy link

No description provided.

@immerrr
Copy link
Collaborator

immerrr commented Oct 22, 2020

Could you elaborate what is the problem that you are fixing here? I don't think I understand how jedi:source-dir, which AFAIR is the directory where jedi-core.el is stored, is related to org-babel.

@methuselah-0
Copy link
Author

methuselah-0 commented Oct 22, 2020

Yes, so jedi:source-dir is trying to find the source-directory of the file that is opened in the current-buffer, which is so that jedi can figure out where python modules are located and find definitions-at-point. So, say you have import ABC in the source, then you need to look and see if ABC.py exist in the same directory as the file you have opened in the current buffer. Now, when you open a src-block like below in a dedicated buffer using C-c '

#+BEGIN_SRC python :session full
some code
#+END_SRC

and from that new buffer run M-x eval-expression RET (buffer-file-name) you get nil back instead of the file-name of the org-file from which you opened the new buffer. So, in the special case of Org Src buffers, you need to do some extra work to provide the correct source directory.

jedi-core.el Outdated
default-directory))
(defvar jedi:source-dir
(if (string-match "\*Org Src" (buffer-name (current-buffer)))
(file-name-directory (buffer-file-name (org-src-source-buffer (current-buffer))))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should actually be just (org-src-source-buffer) without (current-buffer) as argument to it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need to touch this variable, because it is the location of jedi's own sources. It probably wouldn't work anyway, because this is only evaluated once, when jedi itself is loaded.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, you are totally right. It all works fine without changing this one - everything is solved by fixing jedi:-buffer-file-name.

@methuselah-0
Copy link
Author

Fixed so that jedi:source-dir is not changed.

…ers in org-babel - C-c ' - based on content in the org-src-source-buffer
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

Successfully merging this pull request may close these issues.

2 participants