0

I have the following in my .emacs.d/init.el, along the lines of what is suggested here:

(require 'importmagic)
(add-hook 'python-mode-hook 'importmagic-mode)
(define-key importmagic-mode-map (kbd "C-c C-l") 'importmagic-fix-symbol-at-point)
;; I want to bind to C-c C-l 

I have installed importmagic and epc in my python environment. And I have a .dir-locals.el that sets the environment and the importmagic-python-interpreter as suggested in the github:

((python-mode . (
                 (eval . (pyvenv-workon (concat (projectile-project-root) "envs/default")))
                 (eval . (pyvenv-activate (concat (projectile-project-root)  "envs/default")))
                 (eval .
                       (setq-local importmagic-python-interpreter (concat (projectile-project-root) "envs/default/bin/python"))
                       )

                 )
))

However, for example when I open up a python file like so:

y = os.path.dirname(__file__)

And place my cursor over os "C-c C-l" will either do nothing or maps to the default elpy python-shell-send-file

How can I make emacs recognize my keybinding?

My messages tab does say this:

For information about GNU Emacs and the GNU system, type C-h C-a.
Package cl is deprecated
(New file)
Importmagic and/or epc not found. importmagic.el will not be working.
Starting a new list of tags tables
user-error: No definitions found for: os

I'm additionally confused that the behavior sometimes seems to invoke import magic and fails, and other times summons an entirely different keymapping. I'd expect deterministic behavior.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.