From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: immerrr again Newsgroups: gmane.emacs.devel Subject: python.el: improve sexp-based navigation or make it optional? Date: Sat, 16 May 2020 15:16:44 +0200 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="31064"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat May 16 15:17:33 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jZwh3-0007zN-S0 for ged-emacs-devel@m.gmane-mx.org; Sat, 16 May 2020 15:17:33 +0200 Original-Received: from localhost ([::1]:37942 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZwh2-0003Ug-U2 for ged-emacs-devel@m.gmane-mx.org; Sat, 16 May 2020 09:17:32 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52134) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZwgW-0002iy-7z for emacs-devel@gnu.org; Sat, 16 May 2020 09:17:00 -0400 Original-Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]:33889) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jZwgV-0002Yj-C4 for emacs-devel@gnu.org; Sat, 16 May 2020 09:16:59 -0400 Original-Received: by mail-lf1-x129.google.com with SMTP id e125so3354386lfd.1 for ; Sat, 16 May 2020 06:16:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:from:date:message-id:subject:to; bh=t79aPZ1G0eBGFwlxhJvO+DGDvVCjVywU+04zpkNMcik=; b=anh1E/cQBDuehor46AY60THn1qvOHGQXALjRhaEryf8bZwfjwAs0PQpexHfu4ASsPs yOn0SrqeIYgIwOErmEw586fDQjNFc+PIcaQjnxYEVpXlzvxGXuJszogd1uzNsZSQ85hQ CuuYoedHAcL14ajAC3aRpmrdTP967wg8+lUZTXLgvoUW7WodQfKr6jKG5/CfBCYopmhl VG1vAEB2EfMDSS+a03gOmDhUlviU6PdGwlJJuMrSYUcKNH39J0s7qqz0CHITTYvi6ZyY vMGahC600eiiqjXyTCjydccoiduhywhO5Q+cGyJAa4fJ42CZ3ng741tqlPLA60pLcQn1 FxJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:from:date:message-id:subject :to; bh=t79aPZ1G0eBGFwlxhJvO+DGDvVCjVywU+04zpkNMcik=; b=AX3orQzdAVbgXSMoaxFsJnQd8v/dYFcT3fimeRrzPgYOZg4tGJ/nIUmpoVWIR1VTrJ HBmL/R82QxFuHPx88gSfoCVyqlXQcmcymr/uFltX8UeB8So0hyxGyy7Qcsa9T9MMpMto KwkYqZdPezmHRQwSOGcdNjCqA3m1c0oMkTe3DO3xQfBTUfQWya7/75Xt43GR4UwazWFP 15Ay3h/iqkP1fNQIVCkh4XAOICSYAlxN01Y9TZYMqp5XYVdsyQKjnJuTyrpmdpfYcs1P ptk3hF9LxOvZGDqqYxL7RM9GvSfYsyUyFr4PrqCDNYfK2SBvgVMk8OnItebic2M3NGDk YnRw== X-Gm-Message-State: AOAM532oZb0nsGIV72YaJ5CJMHogLNhNGmjeIYfbATzgDbpTNwu1f+Ml PIecf8rig+9hn6nYOi6lL1K+2xtXPF4oR3ra8+GwErjz X-Google-Smtp-Source: ABdhPJyI1WkAvm+Nv6IvvFknpOu8jmKPWgy3fkmA/qDDsm39f/IEvJn6PAn2xvAou5tNREqoZytYDxUnHIbPszh44NU= X-Received: by 2002:a19:6e48:: with SMTP id q8mr5701276lfk.185.1589635016385; Sat, 16 May 2020 06:16:56 -0700 (PDT) X-Google-Sender-Delegation: dshpektorov@gmail.com X-Google-Sender-Auth: 9XfTIWodWO0x7lpVmmsvmWDnHVw Received-SPF: pass client-ip=2a00:1450:4864:20::129; envelope-from=immerrr@gmail.com; helo=mail-lf1-x129.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:250487 Archived-At: Hi everyone, I'm a frequent user of python.el, and I have a qualm about its "smart" sexp navigation. As a long-time Emacs user, I have come to certain expectations about how Emacs behaves, and I cannot wrap my hand around some of the idiosyncrasies there. Below you can find a couple of examples. Where forward-sexp from 1 takes point to 2, and backward-sexp from 2 takes point back to 1. A. <1>x = 'foo'<2> B. <1>class Test: X = 'foo' Y = 'bar'<2> C. <1>def calc_foo(...): ... return foo<2> It seems logical to be able to skip an entire statement, or an entire defun/defclass, but what if I want to go select just the last literal in a statement? The problem here is that there is no way to unambiguously tell python-mode what symbol/literal/block do I want to skip. To clarify, let's pretend Python had parentheses around its syntactical blocks: <1>(<2>def<2'> my_func(x): <3>(if (x == 'foo'): <4>(Y = <5>'bar'<5'>)<4'>)<3'>)<1'> In this case it's easy to predict that forward/backward-sexp should establish the following pairs: 1 with 1', 2 with 2', 3 with 3' and so on. But without the parentheses, there is no way to distinguish between 1 and 2, or between 1', 3', 4', and 5'. Python.el essentially tries to make a guess, and curiously, this explicitly goes against one of the principles listed in the Zen of Python, > In the face of ambiguity, refuse the temptation to guess. Some kind of a visual-sexp mode for this type of navigation would reduce the uncertainty. A mode that would augment the code with some kind of an overlay, showing parentheses around each sexp composed of more than 1 symbol/literal, and provide visual guidance as to where will point end up after a sexp-based navigation command. However, IIRC overlays don't scale well, and it might require implementing yet another parser or hacking all the structural information to the pre-existing one, which is a quite tedious task. In absence of such mode, I wonder if it would be a welcome addition to introduce a configuration parameter that at least disables the smart navigation, making sexp skip one symbol or explicitly parenthesized/bracketed expression at a time. What do you think?