py-newline-and-close-THING

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

py-newline-and-close-THING

Andreas Röhler-2

Hi,

herewith a first solution to requests posted at python-list

(defun py-newline-and-close-block ()
 " "
 (interactive "*")
 (let ((ci (current-indentation)))
   (end-of-line)
   (newline)
   (indent-to-column (- ci py-indent-offset))))

If this proceeding seems acceptable, I'll figure out

py-newline-and-close-function

py-newline-and-close-class

py-newline-and-close-form (if, while, etc)

It would always close the adressed form above, choosing
the indent to proceed.

Below some examples of requests in python-list posted by
Eric S. Johansson <[hidden email]>

Title was: "special editor support for indentation needed":

;;;;;;;;;;;

here's an example of the problem:
class foo( object):
    def cat(self)
        self.x=1
        def dog
            self.x=2

this is legal Python but it's not what you need 99% of the time.  There is no
cue to the editor to tell it to outdent to give me what I really want which is:

class foo( object):
    def cat(self)
        self.x=1
    def dog
        self.x=2

;;;;;;;;;;;;;

and at another place

;;;;;;;;;;;;;

the current outdent capability conflates multiple outdent events.  The outdent
events are, at a minimum,:

Close block
close method
close class

Another way to look at these events are start method, start class and close
block.  Now using these events, let's compare a use case against the outdent
mechanism.

starting with an example of a previous message,

class pet (object):
    """
    """
    def cat(self):
        """
        """
        if food in bowl:
            self.empty = True

    def dog(self):

to start the dog method, after ending the Method, I would need to say something
like:

newline tab key Close block close block delta echo foxtrot dog left paren self
close paren colon...

But if the method ended like:

    ...

    def cat(self):
        """
        """
        self.empty = True

    def dog(self):

I would only want to use a single "close block" to outdent.  unfortunately, this
 context dependent behavior is frustratingly wrong when it comes to creating
speech driven macros to enter templates.  it requires user intervention to tell
you how may times to outdent and that's counterproductive at best and physically
damaging at worst for a disabled user.

;;;;;;;;;;;;;;;;;;;;

So far the report.
_______________________________________________
Python-mode mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-mode
Reply | Threaded
Open this post in threaded view
|

Re: py-newline-and-close-THING

Eric S. Johansson
Andreas Roehler wrote:
> Hi,
>
> herewith a first solution to requests posted at python-list

thank you so very much.  I need to find the current Pythonesta python mode lisp.
 The source Forge version is frighteningly old.  Would you be so kind as to let
me know where I can get the latest?

_______________________________________________
Python-mode mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-mode
Reply | Threaded
Open this post in threaded view
|

Re: py-newline-and-close-THING

Barry Warsaw
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Dec 2, 2008, at 12:46 AM, Eric S. Johansson wrote:

> Andreas Roehler wrote:
>> Hi,
>>
>> herewith a first solution to requests posted at python-list
>
> thank you so very much.  I need to find the current Pythonesta  
> python mode lisp.
> The source Forge version is frighteningly old.  Would you be so kind  
> as to let
> me know where I can get the latest?

The latest version of python-mode.el is available here:

https://edge.launchpad.net/python-mode/+download

- -Barry

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Darwin)

iQCVAwUBSTdWLHEjvBPtnXfVAQIfQAP7BhwspdNWgxVVTBIruK7F7vvCEdQ+TuXX
JB3QLSho3SXPXRdNzUHmzUH+dIZTvK1zbSpw3Dd63XOGa35k5L613hssGYeZt8m7
JKaYFVVfYYEjVd8sniFx3bdg3bbIwnnYUJAmQRzc516MBe86mLYeG1tCcsndhXH7
3sTFQOK2C9w=
=YUcQ
-----END PGP SIGNATURE-----
_______________________________________________
Python-mode mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-mode
Reply | Threaded
Open this post in threaded view
|

Re: py-newline-and-close-THING

Andreas Röhler-2
Barry Warsaw wrote:

> On Dec 2, 2008, at 12:46 AM, Eric S. Johansson wrote:
>
>> Andreas Roehler wrote:
>>> Hi,
>>>
>>> herewith a first solution to requests posted at python-list
>
>> thank you so very much.  I need to find the current Pythonesta python
>> mode lisp.
>> The source Forge version is frighteningly old.  Would you be so kind
>> as to let
>> me know where I can get the latest?
>
> The latest version of python-mode.el is available here:
>
> https://edge.launchpad.net/python-mode/+download
>
> -Barry
>

Hi Barry

seeing your announcement of "Python 3.0 final" I imagine
you being busy with other stuff...

Let's see if we can figure out how to contribute here
nonetheless.

Probably I got rights to check in already some months
ago.

However, I'm still hesitating, as it's not a matter of
bugs alone.

Different people usually have different opinions how
the code should look like.

May I check in `py-newline-and-close-block' and the
functions mentioned in this line?

Too I would refactor the existing code a little bit:
Split up functions to make them better readable, easier
to maintain and extend.

What about --given I have the rights already-- if I
send patches to this list, wait a week and check in if
no one objects?

Agreed?

Andreas Röhler






_______________________________________________
Python-mode mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-mode
Reply | Threaded
Open this post in threaded view
|

Re: py-newline-and-close-THING

Barry Warsaw
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Dec 4, 2008, at 1:53 PM, Andreas Roehler wrote:

> seeing your announcement of "Python 3.0 final" I imagine
> you being busy with other stuff...
>
> Let's see if we can figure out how to contribute here
> nonetheless.
>
> Probably I got rights to check in already some months
> ago.
>
> However, I'm still hesitating, as it's not a matter of
> bugs alone.
>
> Different people usually have different opinions how
> the code should look like.
>
> May I check in `py-newline-and-close-block' and the
> functions mentioned in this line?
>
> Too I would refactor the existing code a little bit:
> Split up functions to make them better readable, easier
> to maintain and extend.
>
> What about --given I have the rights already-- if I
> send patches to this list, wait a week and check in if
> no one objects?

The way I'd really like to see contributions like this handled is by  
using the features in Launchpad and Bazaar most effectively, like so:

* Open a bug on http://bugs.launchpad.net/python-mode for this  
enhancement
* Create a branch of the main line: bzr branch lp:python-mode
* <hack> <hack> <hack>
* Commit your changes locally: bzr commit --fixes=lp:123456
* Push your branch to Launchpad: bzr push lp:~<you>/python-mode/py-
newline-and-close
* Create a merge proposal for your branch, requesting review e.g. from  
me or skip
* Wait for the reviewer to approve it, addressing any issues that come  
up
* Once it's approved, merge it into the main line, commit and push
* Close the bug

I know it sounds like a lot, but it's really a fairly smooth workflow,  
and bzr can help a lot with that (there are plans to make it even  
easier).  The nice thing about all this is that there are artifacts we  
can use to track everything and we don't have to rely on people's  
inboxes to make decisions.

Can you give this a try?
- -Barry

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Darwin)

iQCVAwUBSTg0LHEjvBPtnXfVAQJThQP/cqm31evgPVXxcXxyBIir9O2iHWaRlnd7
TsLr2oL3cvwbE0CfSdEXmmEqegfjvlScpJGzg8MHmK4OBLemEqQ+tzgRm3nfzNtU
eWWyljzhMhZIfY1f/LPDLNgqcQ/Dy9fsITCIgIimJFAVFX3dsckPKovxo+bsMZ1g
M7dKdAFraOM=
=/u8G
-----END PGP SIGNATURE-----
_______________________________________________
Python-mode mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-mode
Reply | Threaded
Open this post in threaded view
|

Re: py-newline-and-close-THING

Andreas Röhler-2
Barry Warsaw wrote:

> On Dec 4, 2008, at 1:53 PM, Andreas Roehler wrote:
>
>> seeing your announcement of "Python 3.0 final" I imagine
>> you being busy with other stuff...
>
>> Let's see if we can figure out how to contribute here
>> nonetheless.
>
>> Probably I got rights to check in already some months
>> ago.
>
>> However, I'm still hesitating, as it's not a matter of
>> bugs alone.
>
>> Different people usually have different opinions how
>> the code should look like.
>
>> May I check in `py-newline-and-close-block' and the
>> functions mentioned in this line?
>
>> Too I would refactor the existing code a little bit:
>> Split up functions to make them better readable, easier
>> to maintain and extend.
>
>> What about --given I have the rights already-- if I
>> send patches to this list, wait a week and check in if
>> no one objects?
>
> The way I'd really like to see contributions like this handled is by
> using the features in Launchpad and Bazaar most effectively, like so:
>
> * Open a bug on http://bugs.launchpad.net/python-mode for this enhancement
> * Create a branch of the main line: bzr branch lp:python-mode
> * <hack> <hack> <hack>
> * Commit your changes locally: bzr commit --fixes=lp:123456
> * Push your branch to Launchpad: bzr push
> lp:~<you>/python-mode/py-newline-and-close
> * Create a merge proposal for your branch, requesting review e.g. from
> me or skip
> * Wait for the reviewer to approve it, addressing any issues that come up
> * Once it's approved, merge it into the main line, commit and push
> * Close the bug
>
> I know it sounds like a lot, but it's really a fairly smooth workflow,
> and bzr can help a lot with that (there are plans to make it even
> easier).  The nice thing about all this is that there are artifacts we
> can use to track everything and we don't have to rely on people's
> inboxes to make decisions.
>
> Can you give this a try?
> -Barry
>

Sure, let's go on, thanks.

Andreas

_______________________________________________
Python-mode mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-mode