() indentation

Bug #818669 reported by Glenn Linderman
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
python-mode.el
Fix Released
Medium
Andreas Roehler

Bug Description

abc( def,
    ghi

Typing the above produces what seems to me to be incorrect alignment of the continuation line. Ignoring the variable width font used here, the g is aligned one space past the open parenthesis, whereas the older version lined it up with the d in def.

Revision history for this message
Glenn Linderman (v+python) wrote :

Forgot to mention: emacs 22.1.1 Windows python-mode 6.0

Revision history for this message
Andreas Roehler (a-roehler) wrote :

Hi,

indents here until "d" in `def' as requested.

May any other person confirm the bug?

Thanks,

Andreas

Changed in python-mode:
assignee: nobody → Andreas Roehler (a-roehler)
importance: Undecided → Low
Changed in python-mode:
status: New → Incomplete
Revision history for this message
Glenn Linderman (v+python) wrote :

I can still reproduce it, and would be happy to allow you VNC access to my machine to demonstrate it or debug it, if that would help.

Revision history for this message
Glenn Linderman (v+python) wrote :

Or try debugging versions of python-mode.el, which produce debug messages exposing the problem, or whatever the typical diagnostic technique is... I'm ignorant of how people debug emacs Lisp, as I'm nearly ignorant of how to code in it too. I'd like an emacs that had Python as an extension language!

Revision history for this message
Andreas Roehler (a-roehler) wrote : Re: [Bug 818669] Re: () indentation

Am 31.07.2011 23:44, schrieb Glenn Linderman:
> Or try debugging versions of python-mode.el, which produce debug
> messages exposing the problem,

if you want to trace how a function works, do

M-x edebug-defun

with cursor inside it's body.

Next time it's called, you will see the output of edebug.

Eval it normally to stop edebug again.

BTW there is also a `trace' command, reporting the moment, the function
is called

  or whatever the typical diagnostic
> technique is... I'm ignorant of how people debug emacs Lisp, as I'm
> nearly ignorant of how to code in it too. I'd like an emacs that had
> Python as an extension language!
>

Revision history for this message
Glenn Linderman (v+python) wrote :

Reading between the lines, that might mean:

Open a buffer using python-mode so it is loaded.
Open a buffer to the python-mode source code
Find the appropriate function in the buffer and place the cursor there

follow your instructions

I have no idea what you mean by eval it normally again, since I have no idea what eval it normally means. Maybe you mean reload the python-mode source? I suppose I could just close the instance of emacs as a sledge-hammer to achieve the same effect.

OK, so for the problem of interest, what function should I debug? After looking around a bit, I decided to try py-newline-and-indent, and indeed, choosing it, and returning to the python-mode-enabled buffer and typing my test cause caused the debugger to show up. The cursor was placed there at the beginning of the function. I had no idea what to do, so I hit the space bar, due to experience with File/buffer comparison, and that seemed to have been the correct thing, as it jumped along, and even showed a few values in the minibuffer.

All I understand after stepping through was that the current-indentation was 0, the current-column was 9, and newline-and-indent was called, resulting in a 4 space indent.

I guess newline-and-indent is the one built-in to emacs, as I couldn't find it in the python-mode.el file?

I couldn't get the trace to happen a second time, except by restarting emacs, and redoing the process.

Revision history for this message
Glenn Linderman (v+python) wrote :

Tried again, tracing py-compute-indentation, but the logic is pretty complex there, and long so it was boring to trace without knowing what was going on. And it seemed to trace multiple times, including recursively when I typed the same thing a second time in the buffer. Or maybe iteratively. Anyway, with more instruction, I might be able to produce useful diagnostic info for you?

Revision history for this message
Andreas Roehler (a-roehler) wrote :

> I have no idea what you mean by eval it normally again, since I have no
> idea what eval it normally means.

Hi,

while I'm strongly in favor making Emacs useful for every user right
from the spot, it
should be told that it unfolds it's power after having a look at Emacs Lisp.

At least it's my experience: after reading the info-file

Emacs Lisp Intro: (eintr). A simple introduction to Emacs Lisp
programming.

Emacs started being fun. Before it was hard sometimes.

Have a look also at Emacs and Elisp info files.

Andreas

Revision history for this message
Andreas Roehler (a-roehler) wrote :

Am 01.08.2011 09:42, schrieb Glenn Linderman:
> Tried again, tracing py-compute-indentation, but the logic is pretty
> complex there, and long so it was boring to trace without knowing what
> was going on. And it seemed to trace multiple times, including
> recursively when I typed the same thing a second time in the buffer. Or
> maybe iteratively. Anyway, with more instruction, I might be able to
> produce useful diagnostic info for you?
>

Hi Glenn,

thanks a lot for your care.

Think you must not dig in there for the moment, we will get it
collecting reports.

I'm aware of another indenting bug, so maybe that's gone too after
fixing it.

Andreas

Revision history for this message
Glenn Linderman (v+python) wrote :

Read that years ago. Never got around to trying to apply it. Too many other things seem more interesting to me than learning a language that uses a syntax that made my head hurt when I learned basic Lisp back in college, and makes it hurt again every time I look at emacs lisp. My definition of fun doesn't include having my head hurt from looking at Lisp syntax.

I have a vague recollection that eval-ing a defun is sort of like compiling it, or maybe running it, or maybe those are the same, but I have no clue how to do it, and am only doing what I'm doing in the interest of making python-mode better because I like Python, and use emacs, and you can't reproduce the problem.

So, if you can provide instruction that helps me help you diagnose the problem, fine. Otherwise, I guess the problem report will sit here unfixed, until you figure it out by staring at Lisp syntax or someone reports a different way of invoking the problem that you can reproduce.

Revision history for this message
Glenn Linderman (v+python) wrote :

So I poked around the web site (friendlier than Lisp syntax) until I figured out how to download python-mode.el from revision 478. It still has this reported bug.

Revision history for this message
Glenn Linderman (v+python) wrote :

If I try this bug at the end of a 1775 line, successfully compling Python script, it only indents 3 spaces instead of 4 (per this report) or 5 (which is what it should indent). While editing/updating this particular script, I'm noticing a fair number of places where the indentation is one level to the left of where it should be... another tab (or sometimes 2) pushes it to the right one level of where it should be, and then a backspace is required to get it where it belongs... but I haven't yet tried to reduce the test case to a minimal reproducible case. The other symptoms I'm seeing are more like the "if indentation" I reported earlier, but I think I'm using the version that contains that fix.

Revision history for this message
Glenn Linderman (v+python) wrote :

And if I try it in the middle of that same script, it doesn't indent the second line any further than the first.
Not having a clue how the indentation algorithms work, I'm not having a lot of luck making a test case from a few nearby lines of the script...

Revision history for this message
Andreas Roehler (a-roehler) wrote :

Am 03.08.2011 00:31, schrieb Glenn Linderman:
> And if I try it in the middle of that same script, it doesn't indent the second line any further than the first.
> Not having a clue how the indentation algorithms work, I'm not having a lot of luck making a test case from a few nearby lines of the script...
>

maybe send the whole script?

Without seeing the code you are talking can't neither confirm nor fix.

Andreas

Revision history for this message
Glenn Linderman (v+python) wrote :

Yes, I could send the whole script privately, along with a few specific spots where indentation problems occur.

Can you test with emacs 22.1.1 which I use? Or only with 23.x? I really don't know if that is the problem or not, but since you couldn't reproduce it, I started wondering....

Should I send the script to your email address used here in LaunchPad?

I'm seeing so many indentation problems, that I can hardly believe you aren't seeing some, which also makes me wonder if you are using some feature that varies in the different version of emacs.

Revision history for this message
Andreas Roehler (a-roehler) wrote :

Am 05.08.2011 11:11, schrieb Glenn Linderman:
> Yes, I could send the whole script privately, along with a few specific
> spots where indentation problems occur.
>

that's welcome, thanks.

> Can you test with emacs 22.1.1 which I use?

Sorry, no.

Or only with 23.x? I
> really don't know if that is the problem or not, but since you couldn't
> reproduce it, I started wondering....

There is no-one else which could reproduce AFAIS.
Which doesn't mean much yet...

>
> Should I send the script to your email address used here in LaunchPad?

Yes

>
> I'm seeing so many indentation problems, that I can hardly believe you
> aren't seeing some, which also makes me wonder if you are using some
> feature that varies in the different version of emacs.
>

Well, fixed bugs and some other scenario is tested here with a srcipt
running Emacs -Q from shell-script. Would not assume anything interferes
in this circumstances.

Revision history for this message
Andreas Roehler (a-roehler) wrote :

Hi Glenn,

could you make tracker entries from your examples sent privatly?
Need some comments from others still.

Here is the first example transcripted, which you may use:

#! /usr/bin/env python
# -*- coding: utf-8 -*-

if foo:
    bar.append(
        ht(
            T.a('Sorted Foo', href='#Blub', ),
            ' -- foo bar baz--',
            self.Tasdf( afsd ),
            self.Tasdf( asdf ),
            )
    )

Thanks,

Andreas

Revision history for this message
Glenn Linderman (v+python) wrote :

Sure. if you wish, you can provide the reduced test cases privately too, rather than clutter up this bug, although since they were sort of spawned from this one, that is OK too, on my part. I've opened a new bug for this one: Bug #821834

Changed in python-mode:
importance: Low → Medium
status: Incomplete → Fix Committed
milestone: none → 6.1
Revision history for this message
Andreas Roehler (a-roehler) wrote :

Hi Glenn,

finally could reproduce. Thanks being patient...

Fix committed.

BTW if you don't want to use bazaar to get the newest trunk,

you will have seen the download-button at

http://bazaar.launchpad.net/~python-mode-devs/python-mode/python-mode/view/head:/python-mode.el

Thanks again for your reports,

Andreas

Changed in python-mode:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.