From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#11974: 24.1.50; python-nav-forward-sexp-function doesn't skip over strings Date: Thu, 19 Jul 2012 03:52:02 -0400 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1342685825 12709 80.91.229.3 (19 Jul 2012 08:17:05 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 19 Jul 2012 08:17:05 +0000 (UTC) Cc: 11974@debbugs.gnu.org To: Ivan Andrus Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jul 19 10:17:04 2012 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 1Srluy-0007DJ-2d for geb-bug-gnu-emacs@m.gmane.org; Thu, 19 Jul 2012 10:17:04 +0200 Original-Received: from localhost ([::1]:36234 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Srlux-0001xD-31 for geb-bug-gnu-emacs@m.gmane.org; Thu, 19 Jul 2012 04:17:03 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:47322) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Srlur-0001wz-RO for bug-gnu-emacs@gnu.org; Thu, 19 Jul 2012 04:17:01 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Srlul-0000GX-UJ for bug-gnu-emacs@gnu.org; Thu, 19 Jul 2012 04:16:57 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:39952) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Srlul-0000GT-QO for bug-gnu-emacs@gnu.org; Thu, 19 Jul 2012 04:16:51 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1Srm0j-0002QY-Op for bug-gnu-emacs@gnu.org; Thu, 19 Jul 2012 04:23:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 19 Jul 2012 08:23:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 11974 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 11974-submit@debbugs.gnu.org id=B11974.13426861699309 (code B ref 11974); Thu, 19 Jul 2012 08:23:01 +0000 Original-Received: (at 11974) by debbugs.gnu.org; 19 Jul 2012 08:22:49 +0000 Original-Received: from localhost ([127.0.0.1]:49498 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Srm0W-0002Q6-OB for submit@debbugs.gnu.org; Thu, 19 Jul 2012 04:22:49 -0400 Original-Received: from pruche.dit.umontreal.ca ([132.204.246.22]:53344) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Srm0V-0002Pz-5L for 11974@debbugs.gnu.org; Thu, 19 Jul 2012 04:22:47 -0400 Original-Received: from fmsmemgm.homelinux.net (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id q6J8GZnH003944; Thu, 19 Jul 2012 04:16:35 -0400 Original-Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id BE01DAE20D; Thu, 19 Jul 2012 03:52:02 -0400 (EDT) In-Reply-To: (Ivan Andrus's message of "Wed, 18 Jul 2012 14:29:39 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux) X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV4283=0 X-NAI-Spam-Version: 2.2.0.9309 : core <4283> : streams <787094> : uri <1169144> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) 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:62146 Archived-At: > (let* ((bos (python-info-ppss-context 'string))) > (goto-char bos) > (forward-sexp 1) > (narrow-to-region bos (point))) > This is broken now since forward-sexp goes to the end of the block, far > past the end of the string (or not moving at all). If you have any > undindented code at the end of your buffer, then forward-sexp (and up-list) > will refuse to move past it e.g. There's a similar problem in SMIE's implementation of forward-sexp. Basically, the issue is that there are several "sexp"s that start at point and forward-sexp has to choose which one to skip over. Every choice is valid, but since there's no way for the user to say which choice she wants, any choice is bound to disappoint and/or surprise the user sometimes. That doesn't mean that it's a hopeless problem and that we shouldn't try to improve the behavior, tho: in practice (maybe just for historical reasons), I find that I generally prefer "the smallest sexp", especially since I can repeat forward-sexp if it didn't skip enough. I.e. Python's forward-sexp should only try to skip over indentation-delimited blocks when it has a clear indication that only skipping the current line/statement would be wrong, or that there's an easy/intuitive way for the user to get the other behavior (e.g. by starting the forward-sexp from elsewhere). For example, with SMIE if I have a + b * c and I'm before "b", forward-sexp will only skip over "b", but if I move to just before the "+", then forward-sexp will skip to after "c". I'm not sure if Python's indentation-delimited blocks can find a similar "convention" for the user to express her intention. > What I would expect form a "perfect" python forward-sexp is to skip over > a block if and only if you are at the very beginning of the block. You mean that forward-sexp would generally skip over just a statement, except if it's the first statement of a block in which case it skips the whole block? That sounds a bit arbitrary, making it difficult for the user to skip over just the first statement. [ Bear in mind, I never write Python. ] How 'bout def foo(): toto bar if I'm before `toto' on the same line, forward-sexp should skip over "toto", but if I'm right after the ":" (and before the \n) then forward-sexp should skip to after "bar". Stefan