all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dima Kogan <lists@dima.secretsauce.net>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: Python interactive navigation around nested functions
Date: Fri, 24 Jun 2016 15:10:51 -0700	[thread overview]
Message-ID: <87twgick5w.fsf@secretsauce.net> (raw)
In-Reply-To: <jwvtwgn83wq.fsf-monnier+gmane.emacs.devel@gnu.org>

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> 2. If we're NOT on a function-definition line, C-M-a should go up to the
>> previous definition, at a HIGHER AST level.
>
> That's a significant change.  It means that if we're between two
> functions (e.g. on a static var declaration in a C file), C-M-a would
> jump to BOB.

Hi. So to be clear, my thinking here is about getting do-what-I-mean
behavior out of C-M-a.

The current implementation in emacs already has special-case behavior if
no leading block-start is found: instead of going to BOB, the point is
left where it is. The proposal could be modified slightly to
special-case it differently, and try to go to the prev-defun-start at
the same-or-higher level, which would produce the current behavior in
this case.

Here's a case where the current behavior is not what the user wants (at
least never what I want). Say you have this:

  defun f1():

    # stuff

    defun f2():
      # stuff

    # stuff
    # stuff
    # lots and lots of stuff
    # So much stuff that when I'm here I know I'm in f1(), but f2 isn't
    #   something i'm thinking about at all

If I C-M-a, at the end of f1(), I, the human editing this source am
thinking about f1(), but not thinking about f1() at all, and I want to
go to the start of f1(). I could hit C-M-u instead, but that will stop
at any if/while/etc blocks.

The behavior the feels "right" is implemented here:

  https://github.com/dkogan/emacs-snapshot/blob/python_indent/lisp/progmodes/python.el

There're a few more fixes in that tree that I'll submit separately in a
bit.


> Of course by C-M-a we can mean different things:
> - the backend navigation code provided by the major mode via
>   *-of-defun-function.
> - the command bound to C-M-a.
> - the beginning-of-defun command.
>
> They don't do exactly the same thing either, and the constraints w.r.t
> changing them are slightly different (e.g. some allow the introduction
> of a whole new backend API, or the rebinding of C-M-a to another command).

Yeah, I'd rather not proliferate multiple similar-yet-slightly-different
behaviors, so I'll simply use my own python nav functions in my work if
this gets rejected.

Thanks

dima



  reply	other threads:[~2016-06-24 22:10 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-19  4:52 Python interactive navigation around nested functions Dima Kogan
2016-06-20  2:43 ` Stefan Monnier
2016-06-20  7:14   ` Andreas Röhler
2016-06-20  7:34     ` Stefan Monnier
2016-06-20  8:28       ` Andreas Röhler
2016-06-20 13:57         ` Clément Pit--Claudel
2016-06-20 16:23           ` Andreas Röhler
2016-06-21  5:45   ` Dima Kogan
2016-06-21  6:05     ` Dima Kogan
2016-06-21  6:21       ` Stefan Monnier
2016-06-24 22:10         ` Dima Kogan [this message]
2016-06-24 23:23           ` Clément Pit--Claudel
2016-06-26 19:29             ` Andreas Röhler
2016-06-27  0:39               ` Clément Pit--Claudel
2016-06-27  6:02                 ` Andreas Röhler
2016-06-25  0:18           ` Stefan Monnier
2016-06-26 19:37             ` Andreas Röhler
2016-06-21  6:32       ` Andreas Röhler
2016-06-21  6:26     ` Andreas Röhler

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

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

  git send-email \
    --in-reply-to=87twgick5w.fsf@secretsauce.net \
    --to=lists@dima.secretsauce.net \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.