[Python-mode] highlight-indentation

Andreas Röhler andreas.roehler at online.de
Fri Mar 11 18:30:55 CET 2011


Am 11.03.2011 13:47, schrieb Barry Warsaw:
> On Mar 09, 2011, at 10:24 PM, Andreas Röhler wrote:
>
>> just seeing highlight-indentation by Anton Johansson - thanks a lot to him
>> BTW - which I suggest to include into next release.
>>
>> It delivers graphical bars indicating the indent-level, makes em more
>> impressive. Might be useful in certain circumstances.
>
> Hi Andreas, Anton,
>

Hi Barry,

> Indeed, I agree that this could be very useful in some situations.

good news :-)

  It can be
> a little distracting, so it probably should not be turned on by default,


as it's just a function, user may call them or not. It doesn't interfere.

BTW exists still another nice tool of the same author at:

http://stackoverflow.com/questions/1587972/how-to-display-indentation-guides-in-emacs


(defun aj-toggle-fold ()
   "Toggle fold all lines larger than indentation on current line"
   (interactive)
   (let ((col 1))
     (save-excursion
       (back-to-indentation)
       (setq col (+ 1 (current-column)))
       (set-selective-display
        (if selective-display nil (or col 1))))))

(global-set-key [(M C i)] 'aj-toggle-fold)

Maybe have look.


  but
> for those cases where the indentation is really hard to follow, I think this
> could be a very nice addition.
>
> Is this file going to be added to Emacs?  It seems more general than just for
> Python (e.g. turn it on in python-mode.el).
>
> One minor nit: I wonder if it makes sense to highlight columns that are not in
> the leading whitespace.  For example, turn it on and look at the define-key
> lines starting at about line 845 in python-mode.el.  There are some
> highlighted indentation extents after the "\C-c:" string.  Those don't seem
> useful.

Yes, seeing that too.

AFAIU it will be hard to cure, as the function sets consecutive 
whitespaces as keywords. Trailing whitespaces are marked that way too.

Also it only occurs if large whitespaces are somewhere between.

For the purpose of quickly indicating multiple indents it's fine.
So don't see a need to ask for a change at this state.


Andreas




>
> Thanks for pointing it out, and thanks to Anton for writing it.
>
> Cheers,
> -Barry



More information about the Python-mode mailing list