GNU bug report logs - #19908
python.el: minimal cython indentation support

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: wishlist; Reported by: Carlos Pita <carlosjosepita@HIDDEN>; dated Fri, 20 Feb 2015 00:28:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 19908 <at> debbugs.gnu.org:


Received: (at 19908) by debbugs.gnu.org; 14 Aug 2015 17:11:24 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Aug 14 13:11:24 2015
Received: from localhost ([127.0.0.1]:55948 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ZQIVo-0003Es-6K
	for submit <at> debbugs.gnu.org; Fri, 14 Aug 2015 13:11:24 -0400
Received: from hq.genarts.com ([173.9.65.1]:59030 helo=mail.hq.genarts.com)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <nweston@HIDDEN>) id 1ZQIKp-0002wG-R0
 for 19908 <at> debbugs.gnu.org; Fri, 14 Aug 2015 13:00:06 -0400
Received: from localhost (localhost [127.0.0.1])
 by mail.hq.genarts.com (Postfix) with ESMTP id E6DA5BE1157
 for <19908 <at> debbugs.gnu.org>; Fri, 14 Aug 2015 13:00:02 -0400 (EDT)
Received: from mail.hq.genarts.com ([127.0.0.1])
 by localhost (mail.hq.genarts.com [127.0.0.1]) (amavisd-new, port 10032)
 with ESMTP id gX8nTMt-FjrP for <19908 <at> debbugs.gnu.org>;
 Fri, 14 Aug 2015 12:59:58 -0400 (EDT)
Received: from localhost (localhost [127.0.0.1])
 by mail.hq.genarts.com (Postfix) with ESMTP id 442C5BE10FE
 for <19908 <at> debbugs.gnu.org>; Fri, 14 Aug 2015 12:59:58 -0400 (EDT)
X-Virus-Scanned: amavisd-new at mail.hq.genarts.com
Received: from mail.hq.genarts.com ([127.0.0.1])
 by localhost (mail.hq.genarts.com [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id yd6ZZ8kP8pXI for <19908 <at> debbugs.gnu.org>;
 Fri, 14 Aug 2015 12:59:58 -0400 (EDT)
Received: from [192.168.1.148]
 (146-115-181-71.c3-0.wtr-ubr1.sbo-wtr.ma.cable.rcn.com [146.115.181.71])
 by mail.hq.genarts.com (Postfix) with ESMTPSA id 10E69BE10D8
 for <19908 <at> debbugs.gnu.org>; Fri, 14 Aug 2015 12:59:58 -0400 (EDT)
Message-ID: <55CE1E8D.9090303@HIDDEN>
Date: Fri, 14 Aug 2015 12:59:57 -0400
From: Nathan Weston <nweston@HIDDEN>
User-Agent: Mozilla/5.0 (X11; Linux x86_64;
 rv:31.0) Gecko/20100101 Thunderbird/31.7.0
MIME-Version: 1.0
To: 19908 <at> debbugs.gnu.org
Subject: python.el: minimal cython indentation support
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 19908
X-Mailman-Approved-At: Fri, 14 Aug 2015 13:11:22 -0400
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

I've encountered similar problems writing a mode for Enaml.

What I really want is to override python-rx for enaml-mode, while 
leaving the original definition for python-mode. But that doesn't seem 
to be possible.

For Enaml, I was able to get indentation working by advising 
python-indent-context, but it's not particularly elegant. And other 
function which use (python-rx 'block-start) don't work correctly in 
enaml-mode.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#19908; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 20 Feb 2015 00:27:50 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Feb 19 19:27:50 2015
Received: from localhost ([127.0.0.1]:49012 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1YObRe-0006GI-DE
	for submit <at> debbugs.gnu.org; Thu, 19 Feb 2015 19:27:50 -0500
Received: from eggs.gnu.org ([208.118.235.92]:51222)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <carlosjosepita@HIDDEN>) id 1YObRd-0006GB-0U
 for submit <at> debbugs.gnu.org; Thu, 19 Feb 2015 19:27:49 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <carlosjosepita@HIDDEN>) id 1YObRb-0004h4-Q1
 for submit <at> debbugs.gnu.org; Thu, 19 Feb 2015 19:27:48 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM,
 T_DKIM_INVALID autolearn=disabled version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:33630)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <carlosjosepita@HIDDEN>) id 1YObRb-0004h0-N8
 for submit <at> debbugs.gnu.org; Thu, 19 Feb 2015 19:27:47 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:52938)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <carlosjosepita@HIDDEN>) id 1YObRa-0007Nx-RS
 for bug-gnu-emacs@HIDDEN; Thu, 19 Feb 2015 19:27:47 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <carlosjosepita@HIDDEN>) id 1YObRZ-0004go-V3
 for bug-gnu-emacs@HIDDEN; Thu, 19 Feb 2015 19:27:46 -0500
Received: from mail-la0-x233.google.com ([2a00:1450:4010:c03::233]:34595)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <carlosjosepita@HIDDEN>) id 1YObRZ-0004gk-MH
 for bug-gnu-emacs@HIDDEN; Thu, 19 Feb 2015 19:27:45 -0500
Received: by labhs14 with SMTP id hs14so3180494lab.1
 for <bug-gnu-emacs@HIDDEN>; Thu, 19 Feb 2015 16:27:44 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
 h=mime-version:from:date:message-id:subject:to:content-type;
 bh=+VsNfgxciwm2h2HuAl4a0ZGOGeZcbFaD/t1dmHuRioM=;
 b=uDsyQLbv/H1F6sH7+plwhZK1XgyVeCC2/0SC1rPrJ1Y+8qX/qOMZw7v3qmoqtmCdMB
 sreeqweOBQpkSe8pfWPZLQ1tYTKpI2bXUveULlS1DSJGlm5mouX68bjuK6YlwkvT8pD3
 LojnitNVq8WZltCFck7UGoEB4hCrf4idETSmgZ/jvzHIRgduszj792ivLKWS1c8RwLkr
 D5935tRrYdnYZ5hAI8Dwnfv2h4SndR7gGbYqhrgKBffOKJtyZ4qVwcVOlCqkcf++efo1
 Vmhi5aw/PYnpEbbI8clrdYWOPLZuMjHIYqfpd3dzlwlBxvP4mMi1pcqG/5c+QQyW7cdj
 QiRw==
X-Received: by 10.112.126.98 with SMTP id mx2mr6267448lbb.52.1424392064067;
 Thu, 19 Feb 2015 16:27:44 -0800 (PST)
MIME-Version: 1.0
Received: by 10.112.6.74 with HTTP; Thu, 19 Feb 2015 16:27:23 -0800 (PST)
From: Carlos Pita <carlosjosepita@HIDDEN>
Date: Thu, 19 Feb 2015 21:27:23 -0300
Message-ID: <CAELgYhdCywg3aHSBFV-VmBURaeqTcNbReH6fgMBdnDqrmhX9Mg@HIDDEN>
Subject: python.el: minimal cython indentation support
To: bug-gnu-emacs@HIDDEN
Content-Type: text/plain; charset=UTF-8
X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address
 (bad octet value).
X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address
 (bad octet value).
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -4.0 (----)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -4.0 (----)

X-Debbugs-CC: fgallina@HIDDEN

This isn't a bug in python.el at all. But as it tries to be so smart at
indenting it could be difficult for inherited modes to leverage this
cleverness.

What is needed for cython-mode indentation to work (AFAICS):

* To add cdef, cpdef, enum, struct, union, IF, ELIF and ELSE as
  block starters.

* To add ELIF and ELSE as dedenters.

* To add cdef and cpdef as defuns.

Hopefully the above will also make navigation commands to work with
cython source.

It would be pretty easy to add this directly into python.el (but a
kludge, except you plan to support cython directly). I've done it in my
working copy of python.el and seems to do the job quite well.

This report is about finding a good extension point for the above, in
order to make possible cython-mode to better extend
python-mode. Briefly, it's necessary to extend python-rx-constituents
some way, and at compilation time. Maybe it's already possible in a
clean way I'm not aware of. Or maybe you plan to support cython directly
(+1 it shouldn't be difficult at all).

I will gladly add a pull request to the cython project in github with
the result of the discussion and suggestions here. Or help integrating
cython-mode.el into python.el. In it's current shape cython-mode
indentation and navigation really sucks.

Cheers
--
Carlos




Acknowledgement sent to Carlos Pita <carlosjosepita@HIDDEN>:
New bug report received and forwarded. Copy sent to fgallina@HIDDEN, bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to fgallina@HIDDEN, bug-gnu-emacs@HIDDEN:
bug#19908; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 25 Nov 2019 12:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.