unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Carlos Pita <carlosjosepita@gmail.com>
To: 18796@debbugs.gnu.org
Cc: fabian@anue.biz
Subject: bug#18796:
Date: Wed, 22 Oct 2014 15:11:24 -0300	[thread overview]
Message-ID: <CAELgYhd_JKOWMJRkm8ivuNv5-PNU+Ofb8zEWrBaZS=sBwAPxpQ@mail.gmail.com> (raw)
In-Reply-To: <82d29k3v37.fsf@gmail.com>

I've doing some debugging. I found out why the bug happens, but I
still have to think of a way to fix it:

Say you are in a dedenter line like "else:". In python-indent-region
delete-horizontal-space gets executed, so the dedenter "else:" moves
to the first column and the current indentation becomes 0. Now
python-info-dedenter-opening-block-position initializes indentation as
the value returned by (current-indentation), that is 0. Then the
opening block position is calculated and the following code gets
executed:

        (if (<= (current-indentation) indentation)
            (setq position (car positions))
          (setq positions (cdr positions)))))

In this code (current-indentation) returns the indentation of the
opening block, which is fine. But it gets compared to indentation,
which is always 0. So the else branch is taken every time and
positions is set to nil (cdr positions).

Obviously the problem is that at the point
python-info-dedenter-opening-block-position is called the original
dedenter indentation was lost.

Maybe the original indentation should be saved as a dynamic variable
before deleting the horizontal space. Or the horizontal space
shouldn't be deleted at all and indentation should happen as a
displacement from the original position instead of a displacement from
the left margin.





  parent reply	other threads:[~2014-10-22 18:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-22 16:52 bug#18796: 24.4; python indent-for-tab-command fails to recognize if-elif-else Carlos Pita
2014-10-22 17:00 ` bug#18796: Carlos Pita
2014-10-22 18:11 ` Carlos Pita [this message]
2014-10-22 18:20   ` bug#18796: Carlos Pita

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAELgYhd_JKOWMJRkm8ivuNv5-PNU+Ofb8zEWrBaZS=sBwAPxpQ@mail.gmail.com' \
    --to=carlosjosepita@gmail.com \
    --cc=18796@debbugs.gnu.org \
    --cc=fabian@anue.biz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).