I'm writing a package that provides some Python functionality. I want to use
python-rx, which is part of Emacs' python.el.
(eval-when-compile (require 'python)) (defun python-foo-starts-defun-p () "Return non-nil if the current statement opens a defun." (save-excursion (python-nav-beginning-of-statement) (looking-at (python-rx defun)))) (provide 'python-foo)
However, this gives me byte compilation errors:
the function `python-nav-beginning-of-statement' might not be defined at runtime. the function `python-rx' is not known to be defined.
This error is correct: when I run my code in a fresh Emacs, I do get an error about
python-rx. However, I can open python.el and run
M-x eval-buffer and then my code works.
I believe this is because
python-rx is wrapped in an
eval-when-compile in python.el. How can I use it in my code?