From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Carlos Pita Newsgroups: gmane.emacs.bugs Subject: bug#18796: Date: Wed, 22 Oct 2014 15:20:23 -0300 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1414002088 14468 80.91.229.3 (22 Oct 2014 18:21:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 22 Oct 2014 18:21:28 +0000 (UTC) Cc: fabian@anue.biz To: 18796@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Oct 22 20:21:21 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Xh0XB-0002cF-AZ for geb-bug-gnu-emacs@m.gmane.org; Wed, 22 Oct 2014 20:21:21 +0200 Original-Received: from localhost ([::1]:59707 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xh0X9-0001Sl-Fl for geb-bug-gnu-emacs@m.gmane.org; Wed, 22 Oct 2014 14:21:20 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55711) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xh0Wz-0001JH-FT for bug-gnu-emacs@gnu.org; Wed, 22 Oct 2014 14:21:15 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xh0Wt-00058X-6A for bug-gnu-emacs@gnu.org; Wed, 22 Oct 2014 14:21:09 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:39883) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xh0Wt-00058S-33 for bug-gnu-emacs@gnu.org; Wed, 22 Oct 2014 14:21:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Xh0Ws-0006zi-Fu for bug-gnu-emacs@gnu.org; Wed, 22 Oct 2014 14:21:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Carlos Pita Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 22 Oct 2014 18:21:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 18796 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 18796-submit@debbugs.gnu.org id=B18796.141400205426863 (code B ref 18796); Wed, 22 Oct 2014 18:21:02 +0000 Original-Received: (at 18796) by debbugs.gnu.org; 22 Oct 2014 18:20:54 +0000 Original-Received: from localhost ([127.0.0.1]:60214 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xh0Wj-0006zC-Ta for submit@debbugs.gnu.org; Wed, 22 Oct 2014 14:20:54 -0400 Original-Received: from mail-lb0-f180.google.com ([209.85.217.180]:61572) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xh0Wh-0006yr-67 for 18796@debbugs.gnu.org; Wed, 22 Oct 2014 14:20:51 -0400 Original-Received: by mail-lb0-f180.google.com with SMTP id n15so3256038lbi.25 for <18796@debbugs.gnu.org>; Wed, 22 Oct 2014 11:20:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=qRibzo5sOyWExUggmewWwcfX+1tshU2zIRPwecJ8Obk=; b=yN70dvvY3HX0LQ8cMhVzwVDQ17xMhRBc5IvuINvgETrFa7NRdxsXp9vqFaCi06l7re QwHQbh+zdjwzanr7NO9K2jzGp2eroqpQ0ya1oEwgyaUVIxHllVl5yGH3Db2KNi1+++oy ytCtqJ5WNbPHRH5RF6QK/XAy9A4Re0s9TMpyjYkxVp7rqOS/90CayIPrOAUWVSBWn0GN XA0NJ1UkVdvdtQBsXbKB4hd+Zl6n9pwa26RsKxi+S/iNp/Wvo9ebX6GRQUhj/qSRvHSe TBY9ti2EAZh8gquBBGlIUUkS7a6Z2wA3+AkPPG5FDsHozaKDKg89XFXlRp34Ct9Ye/kT z+Wg== X-Received: by 10.152.121.68 with SMTP id li4mr42563641lab.77.1414002044865; Wed, 22 Oct 2014 11:20:44 -0700 (PDT) Original-Received: by 10.112.252.101 with HTTP; Wed, 22 Oct 2014 11:20:23 -0700 (PDT) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:94945 This fix seems to work: In python-indent-region replace: (delete-horizontal-space) (indent-to (python-indent-calculate-indentation))))) for (let ((indentation (python-indent-calculate-indentation))) (delete-horizontal-space) (indent-to indentation))))) So the new indentation is calculated on the basis of the original one (that is, before removing horizontal space). On Wed, Oct 22, 2014 at 3:11 PM, Carlos Pita wrote: > 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.