help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Insert ; after closing parenthesis when on it


From: weber
Subject: Re: Insert ; after closing parenthesis when on it
Date: 14 Feb 2007 11:08:49 -0800
User-agent: G2/1.0

On 14 fev, 15:44, Jiri Pejchal <jiri.pejc...@gmail.com> wrote:
> Hi,
>
> Netbeans has a following nice feature: when the cursor is on the last
> parenthesis of a function call and you press ';', the semicolon is
> automatically inserted after the parenthesis. This is very useful
> because the opening parenthesis usually inserts also the closing
> parenthesis. In emacs after adding arguments you are left with the
> cursor on the closing one. Then you have to press right and then ';'.
>
> What I would like to achieve:
>
> object.methodCall(a, b|)
>                       ^
>                       |
>                       |
>                       cursor here
>                       (actually on the parenthesis)
>
> press ';' and get this:
>
> object.methodCall(a, b);|
>                         ^
>                         |
>                         |
>                         cursor here
>                         (or even on the next line)
>
> Is this possible in emacs and jdee (or c++ mode)?
>
> Thanks.
>
> --
> Jiri Pejchal


There's probably a faster way, but the way I know is remapping the ';'
key like this:

(global-set-key ";" 'jump-closepar)

where the function jump-closepar would be something like this
(tested) :

(defun jump-closepar ()
 "Close parenthesis Jiri's way"
 (interactive)
 (if (looking-at ")")
               (forward-char))
 (insert ";"))

Oh, and you probably don't want to make that binding global map,
because you are only going to use it on specific modes. Try doing:
 (define-key somelanguage-mode-map ";" 'jump-closepar)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]