From: dstein64
Subject: Parens Matching
Date: 
Message-ID: <fd63d53f-9b7d-4963-8430-356a8c8164be@y24g2000hsd.googlegroups.com>
I am still new to emacs and Common Lisp, so this may be a trivial
question. When I am working in SLIME, I typically have 2 buffers, one
for the REPL, and one for editing code. When a function is small, and
I close a parenthesis, emacs quickly flashes the corresponding
parenthesis that is being closed. However, when a function is very
long, I can not see what open parenthesis corresponds to the closed
parenthesis I just typed. This is because it is above what is viewable
on the screen. How should I deal with this? Is there any key binding
in SLIME that allows me to quickly flash the corresponding open paren
that I am working in? Thanks.

From: danb
Subject: Re: Parens Matching
Date: 
Message-ID: <1902ee14-cdd8-42bc-81b2-2ca28e157e03@n58g2000hsf.googlegroups.com>
On Mar 30, 10:51 am, dstein64 <········@gmail.com> wrote:
> when a function is very long, I can not see what
> open parenthesis corresponds to the closed parenthesis
> I just typed.

Doesn't it display "Matches (foo ..." at the bottom of
the screen?  I don't know if there's a better way, but
I usually just delete the right paren and then retype it.

--Dan

------------------------------------------------
Dan Bensen
http://www.prairienet.org/~dsb/
From: Rudy Neeser
Subject: Re: Parens Matching
Date: 
Message-ID: <W_qdnSXxVpaMI3LanZ2dnUVZ8qjinZ2d@saix.net>
On Sun, 30 Mar 2008 09:12:28 -0700, danb wrote:

> On Mar 30, 10:51 am, dstein64 <········@gmail.com> wrote:
>> when a function is very long, I can not see what open parenthesis
>> corresponds to the closed parenthesis I just typed.
> 
> Doesn't it display "Matches (foo ..." at the bottom of the screen?  I
> don't know if there's a better way, but I usually just delete the right
> paren and then retype it.

Yeah, that's been a feature of GNU emacs for a while now. I'm not sure if 
xemacs does the same, though.

You can also try using C-M-f and C-M-b to move forward and backwards over 
Lisp forms, rather than deleting the last parenthesis (in fact, this will 
work in any major-mode, unless it rebinds the keys). 

Rudy
From: Rudy Neeser
Subject: Re: Parens Matching
Date: 
Message-ID: <w8SdnaGdDuuyI3LanZ2dneKdnZydnZ2d@saix.net>
On Sun, 30 Mar 2008 09:12:28 -0700, danb wrote:

> On Mar 30, 10:51 am, dstein64 <········@gmail.com> wrote:
>> when a function is very long, I can not see what open parenthesis
>> corresponds to the closed parenthesis I just typed.
> 
> Doesn't it display "Matches (foo ..." at the bottom of the screen?  I
> don't know if there's a better way, but I usually just delete the right
> paren and then retype it.

Yeah, that's been a feature of GNU emacs for a while now. I'm not sure if 
xemacs does the same, though.

You can also try using C-M-f and C-M-b to move forward and backwards over 
Lisp forms, rather than deleting the last parenthesis (in fact, this will 
work in any major-mode, unless it rebinds the keys). 

Rudy
From: Rupert Swarbrick
Subject: Re: Parens Matching
Date: 
Message-ID: <3P2dnahDgO71JHLanZ2dnUVZ8vOdnZ2d@giganews.com>
On Sun, 30 Mar 2008 08:51:18 -0700, dstein64 wrote:

> I am still new to emacs and Common Lisp, so this may be a trivial
> question. When I am working in SLIME, I typically have 2 buffers, one
> for the REPL, and one for editing code. When a function is small, and I
> close a parenthesis, emacs quickly flashes the corresponding parenthesis
> that is being closed. However, when a function is very long, I can not
> see what open parenthesis corresponds to the closed parenthesis I just
> typed. This is because it is above what is viewable on the screen. How
> should I deal with this? Is there any key binding in SLIME that allows
> me to quickly flash the corresponding open paren that I am working in?
> Thanks.

You might want to try show-paren-mode. It always highlights the matching 
paren.

I've got it activated as part of a lisp-mode hook:

(add-hook 'lisp-mode-hook
  (lambda () (show-paren-mode 1)))


Rupert
From: Timofei Shatrov
Subject: Re: Parens Matching
Date: 
Message-ID: <47efc040.52340521@news.motzarella.org>
On Sun, 30 Mar 2008 08:51:18 -0700 (PDT), dstein64 <········@gmail.com> tried to
confuse everyone with this message:

>I am still new to emacs and Common Lisp, so this may be a trivial
>question. When I am working in SLIME, I typically have 2 buffers, one
>for the REPL, and one for editing code. When a function is small, and
>I close a parenthesis, emacs quickly flashes the corresponding
>parenthesis that is being closed. However, when a function is very
>long, I can not see what open parenthesis corresponds to the closed
>parenthesis I just typed. This is because it is above what is viewable
>on the screen. How should I deal with this? Is there any key binding
>in SLIME that allows me to quickly flash the corresponding open paren
>that I am working in? Thanks.

1. Watch the minibuffer when you close the paren, it should show the line
with the opening paren.
2. Use C-M-right C-M-left to quickly jump to the opening paren and back.
3. Use some keybinding in SLIME to add closing parens DWIM-style 
(I think it was C-c C-q)

There are also other options like using Paredit editing mode.

-- 
|Don't believe this - you're not worthless              ,gr---------.ru
|It's us against millions and we can't take them all... |  ue     il   |
|But we can take them on!                               |     @ma      |
|                       (A Wilhelm Scream - The Rip)    |______________|
From: dstein64
Subject: Re: Parens Matching
Date: 
Message-ID: <da200177-725e-4b00-aaf4-5c81f9a7b15c@a23g2000hsc.googlegroups.com>
Wow thanks for all the quick replies. The function definitely is too
big, and I plan on 'abstract[ing] away'. However, I will need to use
macros, which I have not really learned yet (I read the macros chapter
in PCL, but I haven't written any yet). My minibuffer is not not
displaying anything. I am using SLIME with SBCL. Any ideas what might
be the problem? Thanks.
From: Scott Burson
Subject: Re: Parens Matching
Date: 
Message-ID: <65e2194c-4444-4e10-85c5-d2018157a582@u10g2000prn.googlegroups.com>
On Mar 30, 9:36 am, ····@mail.ru (Timofei Shatrov) wrote:

> There are also other options like using Paredit editing mode.

Yes, I was hoping someone would mention Paredit.  Parens should never
be unbalanced in the first place!!!

http://mumble.net/~campbell/emacs/paredit.el

I think David Chapman and I get credit for being the first to make an
Emacs-class editor support balanced-paren Lisp editing; we did it for
Zmacs c. 1980.  I've edited Lisp that way ever since.

-- Scott
From: vanekl
Subject: Re: Parens Matching
Date: 
Message-ID: <fsohid$6nq$1@aioe.org>
dstein64 wrote:
> I am still new to emacs and Common Lisp, so this may be a trivial
> question. When I am working in SLIME, I typically have 2 buffers, one
> for the REPL, and one for editing code. When a function is small, and
> I close a parenthesis, emacs quickly flashes the corresponding
> parenthesis that is being closed. However, when a function is very
> long, I can not see what open parenthesis corresponds to the closed
> parenthesis I just typed. This is because it is above what is viewable
> on the screen. How should I deal with this? Is there any key binding
> in SLIME that allows me to quickly flash the corresponding open paren
> that I am working in? Thanks.

(defun goto-match-paren (arg)
   "Go to the matching parenthesis if on parenthesis."
   (interactive "p")
   (cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1))
         ((looking-at "\\s\)") (forward-char 1) (backward-list 1))
         (t nil)))

(global-set-key [(control c) (\])] 'goto-match-paren)
From: Pascal Bourguignon
Subject: Re: Parens Matching
Date: 
Message-ID: <87sky8nqm4.fsf@thalassa.informatimago.com>
dstein64 <········@gmail.com> writes:

> I am still new to emacs and Common Lisp, so this may be a trivial
> question. When I am working in SLIME, I typically have 2 buffers, one
> for the REPL, and one for editing code. When a function is small, and
> I close a parenthesis, emacs quickly flashes the corresponding
> parenthesis that is being closed. However, when a function is very
> long, I can not see what open parenthesis corresponds to the closed
> parenthesis I just typed. This is because it is above what is viewable
> on the screen. How should I deal with this? Is there any key binding
> in SLIME that allows me to quickly flash the corresponding open paren
> that I am working in? Thanks.

If you cannot see the opening parenthesis, it means your function is
way too big.  Factorize!  Abstract away!

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

READ THIS BEFORE OPENING PACKAGE: According to certain suggested
versions of the Grand Unified Theory, the primary particles
constituting this product may decay to nothingness within the next
four hundred million years.
From: ebzzry
Subject: Re: Parens Matching
Date: 
Message-ID: <250aeba0-6297-49de-9ae0-ab2f53be1577@d4g2000prg.googlegroups.com>
On Mar 30, 11:51 pm, dstein64 <········@gmail.com> wrote:
> I am still new to emacs and Common Lisp, so this may be a trivial
> question. When I am working in SLIME, I typically have 2 buffers, one
> for the REPL, and one for editing code. When a function is small, and
> I close a parenthesis, emacs quickly flashes the corresponding
> parenthesis that is being closed. However, when a function is very
> long, I can not see what open parenthesis corresponds to the closed
> parenthesis I just typed. This is because it is above what is viewable
> on the screen. How should I deal with this? Is there any key binding
> in SLIME that allows me to quickly flash the corresponding open paren
> that I am working in? Thanks.

I use mic-paren for that. You can get mic-paren.el from:

  http://www.emacswiki.org/cgi-bin/emacs/download/mic-paren.el

Then put mic-paren.el in your emacs load path
(http://www.gnu.org/software/emacs/emacs-lisp-intro/html_node/Loading-
Files.html).

Then put the following in your .emacs:

(require 'mic-paren)
(paren-activate)
(setq paren-display-message 'only)

However, for some reason, if a parenthesized expression is
very long, matching of parentheses will fail. To fix that,
put the following in your .emacs:

(setq blink-matching-paren-distance nil)

More info on the aforementioned function(s) and variables
can be accesed via the emacs help system:

C-h f paren-activate RET
C-h v paren-display-message RET
C-h v blink-matching-paren-distance RET

(^o^)
--
Rommel M. Martinez