From: Leif Dyvik
Subject: newb and paredit
Date: 
Message-ID: <1138061955.484468.274670@f14g2000cwb.googlegroups.com>
Hello!

I use paredit.el. When I have written the following:

 (if (eql (+ 1 2

And press ) to enclose the + function call, the paredit plugin makes
the cursor jump down like this:

   (if (eql (+ 1 2)
	    ))

What I want is this:

   (if (eql (+ 1 2) ...)...)

Anyone know what is happening? And how to change/prevent it? Paredit is
nice otherwise!

---

Another problem that seem to happen now and then is that sometimes it
refuses to insert a parentheses! It tells me something about

  Scan error: "Unbalanced parentheses"

I have to turn the paredit mode of to insert the parentheses, and it
then works nice when I compile it... Any ideas?

From: senator
Subject: Re: newb and paredit
Date: 
Message-ID: <1138067954.344184.53620@g14g2000cwa.googlegroups.com>
I changed my key bindings to always inserted paired parentheses.

  (define-key slime-mode-map (kbd "(") 'paredit-open-list)
  (define-key slime-mode-map (kbd ")") 'paredit-close-list)

 so when I type ")", it moves me to the closing parenthesis, no matter
where I was, eg, if point (ie cursor) was at | within this sexp:

(+ (- 3 4 5 6 (+ |somevar 5 2)))

typing ) moves me to
(+ (- 3 4 5 6 (+ somevar 5 2)|))

right outside the sexp, and without newlines (the default option (from
paredit.el) that you have is (I believe)
    (define-key keymap ")"          'paredit-close-list-and-newline)
       ).

My M-( is actually a paredit-wrap-sexp, which is equivalent to calling
paredit-open-list with an argument of 1. To insert a lone parenthesis,
you can use C-q ( or C-q ), which is the standard emacs "escape
sequence". That also allows you to put spaces into the minibuffer for
example. If you do this too often, then you can rebind them to
something convenient.
From: Bill Atkins
Subject: Re: newb and paredit
Date: 
Message-ID: <874q3uxuip.fsf@rpi.edu>
"Leif Dyvik" <··········@gmail.com> writes:

> Hello!
>
> I use paredit.el. When I have written the following:
>
>  (if (eql (+ 1 2
>
> And press ) to enclose the + function call, the paredit plugin makes
> the cursor jump down like this:
>
>    (if (eql (+ 1 2)
> 	    ))
>
> What I want is this:
>
>    (if (eql (+ 1 2) ...)...)
>
> Anyone know what is happening? And how to change/prevent it? Paredit is
> nice otherwise!

I typically just do C-p C-e when that behaviour isn't appropriate.  I
bet there's a better solution, too.

> ---
>
> Another problem that seem to happen now and then is that sometimes it
> refuses to insert a parentheses! It tells me something about
>
>   Scan error: "Unbalanced parentheses"
>
> I have to turn the paredit mode of to insert the parentheses, and it
> then works nice when I compile it... Any ideas?

Typically, this means that you've managed to delete a parenthesis
without paredit realizing that this has happened.  If you want to
quickly insert a parenthesis without switching modes, use C-q ( 

--

Bill Atkins
From: Taylor Campbell
Subject: Re: newb and paredit
Date: 
Message-ID: <2006012401491416807%campbell@mumblenet>
(I don't read c.l.l, so it's better to address feedback & questions by
the means explained in paredit.el for contacting me.  Someone happened
to point out this thread to me tonight, though.  I'm unlikely to
respond much further on Usenet.)

The paredit command for the ) key by default will always insert a
newline and indentation after the closing round bracket.  If you want
not to insert the newline, you can use the M-) command instead.

I find the newline to be more commonly what I want and the absence of a
newline to be less common in my preference, which is why the default is
set up that way.  If you want to change it, you can add this to your
.emacs:

  (eval-after-load 'paredit
    '(progn (define-key paredit-mode-map ")" 'paredit-close-list)
            (define-key paredit-mode-map  (kbd "M-)")
              'paredit-close-list-and-newline)))

You should not encounter unbalanced parentheses if you are using
paredit.el.  In the latest release version, 17, the paredit-mode
command will even refuse to be enabled if there are unbalanced
parentheses in the file.  While there are ways to screw up the
structure of the S-expression in paredit-regulated buffers, since
obviously I can't instrument every single command possibly provided in
an Emacs buffer, it's generally pretty easy to avoid this:

  Paredit automatically instruments a lot of basic editing commands so
  that they won't accidentally destroy structure: character deletion,
  line killing, escape character insertion, string insertion, &c.

  Mark regions primarily with C-M-SPC (mark-sexp) so that you know they
  contain only complete S-expressions whose vanishment from the buffer,
  perhaps due to stray or even intentional C-w, will cause no undue
  harm on the rest of the structure.

  Be careful with comments: it's easy to inadvertently destroy
  structure with them, but contrariwise it's also easy to fix any such
  destroyed structure.

  Instead of working with round bracket characters yourself, use the
  higher-level paredit operations that manage parentheses automatically
  -- barfage, slurpage, wrappage, splicage, &c.

Even if you do end up with unbalanced parentheses accidentally, and if
undoing whatever you just did won't correct the error, then you can
pass prefix arguments to C-d & DEL so that they will just delete
characters without worrying about structure, and you can use C-q ( and
C-q ) to insert literal round bracket characters without automatically
balancing the structure.

Finally, I received a lot of feedback about the M-d & M-DEL commands,
which kill words from the point, and possibly intervening delimiters.
In the latest paredit.el beta, version 18, I have implemented
instrumented word killing commands for M-d & M-DEL that should fix
this by refusing to delete delimiters.  The beta is available at

  <http://mumble.net/~campbell/emacs/paredit-beta.el>;

any feedback is welcome (but preferably not via Usenet!).
From: Leif Dyvik
Subject: Re: newb and paredit
Date: 
Message-ID: <1138106534.045206.21400@o13g2000cwo.googlegroups.com>
Hello!

The M-) did the trick for me! I have not run into the "Scan error ..."
thing yet, but the C-q ) probably will work.

So thanks for answering!
From: David Trudgett
Subject: Re: newb and paredit
Date: 
Message-ID: <m31wyywhab.fsf@rr.trudgett>
"Leif Dyvik" <··········@gmail.com> writes:

> Hello!
>
> I use paredit.el. When I have written the following:
>
>  (if (eql (+ 1 2
>
> And press ) to enclose the + function call, the paredit plugin makes
> the cursor jump down like this:
>
>    (if (eql (+ 1 2)
> 	    ))
>
> What I want is this:
>
>    (if (eql (+ 1 2) ...)...)
>
> Anyone know what is happening? And how to change/prevent it? Paredit is
> nice otherwise!

Does it work any better if you use "M-(" to insert parenthesis pairs,
instead closing them manually?



> Another problem that seem to happen now and then is that sometimes it
> refuses to insert a parentheses! It tells me something about
>
>   Scan error: "Unbalanced parentheses"

Using "M-(" to insert paired parentheses will avoid most of these from
happening.


Sorry I don't have specific info on paredit.el itself.

David



-- 

David Trudgett
http://www.zeta.org.au/~wpower/

They were going to assist at the murder of their fathers or
grandfathers just as if they were going on a party of pleasure, or at
any rate on some quite ordinary business.

    -- Leo Tolstoy, "The Kingdom of God is Within You"