1

I am attempting to modify the python major mode to work slightly differently. Specifically, I would like to change python-indent-region. I believe I have figured out what change I need to make (it involves changing line #1070 to be (beginning-of-line)). I have tried to change it like that by copying the function into my init.el file and changing that line. However, when I then try to use that function I get the following error:

Lisp error: (void-function python-rx)

I've done some research and it looks like the issue is that python-rx is actually defined using a defmacro in python.el. Since python.el is distributed with emacs it is already compiled and seems to reside in /usr/share/emacs/24.5/lisp/progmodes/python.elc. I was reading about macro compilation here and as I understand it, the macro has been compiled so when I try to reference it it's no longer available.

This comes down to two questions:

  1. Am I correct in my above understanding?
  2. How can I accomplish my goal of redefining this function to be mostly the same, despite the fact that it relies on the macro python-rx?

Thanks in advance for any help!

Drew
  • 29,895
  • 7
  • 74
  • 104
Kurt Wheeler
  • 419
  • 3
  • 12
  • What changes do you want to make? – Daniel Apr 07 '17 at 12:02
  • @jenesaisquoi That didn't work, `python-rx` was still undefined. I figured out another way to solve my issue. I wanted python's region indentation function to indent the first line of the region even if point was in the middle of the line. I was able to get this behavior by adding a hook to set `indent-region-function` to nil when entering `elpy-mode`. This caused the `indent-according-to-mode` function to be run on each line in the region. – Kurt Wheeler Apr 07 '17 at 14:46

0 Answers0