So my idea was to move onto something completely new but wouldn't you know it, I found a couple more indentation related functions that needed dealing with.
The functions/variables in question are:
python-guess-indent (both variable and function with this name)
And just for fun we'll throw in the key mapping for python-backspace
(define-key map "\177" 'python-backspace)
So let's quickly browse through these functions and see how they work and make sure each works as promised.
- python-guess-indent (variable)
Seems weird to me that there can be a variable and function with the same name. I'm guessing this is a due to emacslisp being a lisp-2
This guess seems to be confirmed by: http://coding.derkeiler.com/Archive/Lisp/comp.lang.lisp/2008-01/msg00683.html
In any case having this being true means that python mode will be using the following indentation guessing function.
- python-guess-indent (function)
This function does what it's name implies.
Looks for a ":" character and then moves to the beginning of that line. Then it moves to the following line and takes the difference. If the different is >= 2 and <= 8 then it take that as a guess. Otherwise it continues to the next ":".
If the value it found is different from the default value then it sets it to this new value.
Look for a regular expression consisting of space and either def or class.
This is a little trickier than python-beginning-of-defun. Here's another place where python's whitespace makes life hard. Good thing it's pretty to look at.
First find the beginning of the block we are currently in. If we are at the beginning of a line then but not at the start of a block, move forward until we find a block starting line.
From here python-end-of-block does the rest of the work.
Look at the list of valid indentation levels for the current line and then back track to the next smallest.
Also present a message explaining what block you just closed.
I'm now 40% through. Almost starting to seem like I might make it all the way through this puppy.