[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-mode
Subject:    [Python-mode] py-newline-and-close-THING
From:       andreas.roehler () online ! de (Andreas Roehler)
Date:       2008-11-30 16:45:21
Message-ID: 4932C321.305 () online ! de
[Download RAW message or body]


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 <esj at harvee.org>

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.

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic