all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Insert ; after closing parenthesis when on it
@ 2007-02-14 18:44 Jiri Pejchal
  0 siblings, 0 replies; 11+ messages in thread
From: Jiri Pejchal @ 2007-02-14 18:44 UTC (permalink / raw)
  To: help-gnu-emacs


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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Insert ; after closing parenthesis when on it
       [not found] <mailman.4516.1171478780.2155.help-gnu-emacs@gnu.org>
@ 2007-02-14 19:03 ` weber
  2007-02-14 20:09   ` Jiri Pejchal
       [not found]   ` <mailman.4523.1171483812.2155.help-gnu-emacs@gnu.org>
  2007-02-14 19:08 ` weber
  1 sibling, 2 replies; 11+ messages in thread
From: weber @ 2007-02-14 19:03 UTC (permalink / raw)
  To: help-gnu-emacs

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 ";" 'insert-closepar)

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

(defun insert-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 ";" 'insert-closepar)

Hope I could help,
weber


Cheers,
weber

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Insert ; after closing parenthesis when on it
       [not found] <mailman.4516.1171478780.2155.help-gnu-emacs@gnu.org>
  2007-02-14 19:03 ` Insert ; after closing parenthesis when on it weber
@ 2007-02-14 19:08 ` weber
  1 sibling, 0 replies; 11+ messages in thread
From: weber @ 2007-02-14 19:08 UTC (permalink / raw)
  To: help-gnu-emacs

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)

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Insert ; after closing parenthesis when on it
  2007-02-14 19:03 ` Insert ; after closing parenthesis when on it weber
@ 2007-02-14 20:09   ` Jiri Pejchal
  2007-02-14 20:41     ` Matthew Flaschen
  2007-02-15  2:36     ` Herbert Euler
       [not found]   ` <mailman.4523.1171483812.2155.help-gnu-emacs@gnu.org>
  1 sibling, 2 replies; 11+ messages in thread
From: Jiri Pejchal @ 2007-02-14 20:09 UTC (permalink / raw)
  To: help-gnu-emacs

"weber" <hugows@gmail.com> writes:

> There's probably a faster way, but the way I know is remapping the ';'
> key like this:
>
> (global-set-key ";" 'insert-closepar)
>
> where the function insert-closepar would be something like this
> (tested) :
>
> (defun insert-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 ";" 'insert-closepar)

Thanks a lot! But I would like to keep the electric behaviour of ';'
too. It's bound to  c-electric-semi&comma.


--
Jiri Pejchal

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Insert ; after closing parenthesis when on it
       [not found]   ` <mailman.4523.1171483812.2155.help-gnu-emacs@gnu.org>
@ 2007-02-14 20:36     ` weber
  2007-02-14 21:36       ` Jiri Pejchal
       [not found]       ` <mailman.4529.1171488981.2155.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 11+ messages in thread
From: weber @ 2007-02-14 20:36 UTC (permalink / raw)
  To: help-gnu-emacs

On 14 fev, 17:09, Jiri Pejchal <jiri.pejc...@gmail.com> wrote:
> "weber" <hug...@gmail.com> writes:
> > There's probably a faster way, but the way I know is remapping the ';'
> > key like this:
>
> > (global-set-key ";" 'insert-closepar)
>
> > where the function insert-closepar would be something like this
> > (tested) :
>
> > (defun insert-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 ";" 'insert-closepar)
>
> Thanks a lot! But I would like to keep the electric behaviour of ';'
> too. It's bound to  c-electric-semi&comma.
>
> --
> Jiri Pejchal

I couldn't test that here, but maybe just doing something like this
works ?

(defun jump-closepar ()
 "Close parenthesis Jiri's way"
 (interactive)
 (if (looking-at ")")
               (forward-char))
 (c-electric-semi&comma))

Just a guess...
cheers,
weber

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Insert ; after closing parenthesis when on it
  2007-02-14 20:09   ` Jiri Pejchal
@ 2007-02-14 20:41     ` Matthew Flaschen
  2007-02-15  2:36     ` Herbert Euler
  1 sibling, 0 replies; 11+ messages in thread
From: Matthew Flaschen @ 2007-02-14 20:41 UTC (permalink / raw)
  To: emacs


[-- Attachment #1.1: Type: text/plain, Size: 975 bytes --]

Jiri Pejchal wrote:
> "weber" <hugows@gmail.com> writes:
> 
>> There's probably a faster way, but the way I know is remapping the ';'
>> key like this:
>>
>> (global-set-key ";" 'insert-closepar)
>>
>> where the function insert-closepar would be something like this
>> (tested) :
>>
>> (defun insert-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 ";" 'insert-closepar)
> 
> Thanks a lot! But I would like to keep the electric behaviour of ';'
> too. It's bound to  c-electric-semi&comma.

Try changing it to:

(defun insert-closepar ()
 "Close parenthesis Jiri's way"
   (interactive)
   (if (looking-at ")")
 		(forward-char))
   (c-electric-semi&comma))

Matthew Flaschen


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]

[-- Attachment #2: Type: text/plain, Size: 152 bytes --]

_______________________________________________
help-gnu-emacs mailing list
help-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Insert ; after closing parenthesis when on it
  2007-02-14 20:36     ` weber
@ 2007-02-14 21:36       ` Jiri Pejchal
       [not found]       ` <mailman.4529.1171488981.2155.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 11+ messages in thread
From: Jiri Pejchal @ 2007-02-14 21:36 UTC (permalink / raw)
  To: help-gnu-emacs

"weber" <hugows@gmail.com> writes:
> I couldn't test that here, but maybe just doing something like this
> works ?
>
> (defun jump-closepar ()
>  "Close parenthesis Jiri's way"
>  (interactive)
>  (if (looking-at ")")
>                (forward-char))
>  (c-electric-semi&comma))

It wants an argument:

(defun c-electric-semi&comma (arg)
  "Insert a comma or semicolon.

And (c-electric-semi&comma ";") inserts ^E for me.

--
Jiri Pejchal

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Insert ; after closing parenthesis when on it
  2007-02-14 20:09   ` Jiri Pejchal
  2007-02-14 20:41     ` Matthew Flaschen
@ 2007-02-15  2:36     ` Herbert Euler
  2007-02-15  2:40       ` Herbert Euler
  1 sibling, 1 reply; 11+ messages in thread
From: Herbert Euler @ 2007-02-15  2:36 UTC (permalink / raw)
  To: jiri.pejchal, help-gnu-emacs

>Thanks a lot! But I would like to keep the electric behaviour of ';'
>too. It's bound to  c-electric-semi&comma.

I wrote a package for doing this, you can try it out.

http://sourceforge.net/projects/casi-mode

Please contact me if you have any problems.  And any suggestions
are welcomed.

Thanks.

Regards,
Guanpeng Xu

_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar - get it now! 
http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Insert ; after closing parenthesis when on it
  2007-02-15  2:36     ` Herbert Euler
@ 2007-02-15  2:40       ` Herbert Euler
  0 siblings, 0 replies; 11+ messages in thread
From: Herbert Euler @ 2007-02-15  2:40 UTC (permalink / raw)
  To: herberteuler, jiri.pejchal, help-gnu-emacs

>>Thanks a lot! But I would like to keep the electric behaviour of ';'
>>too. It's bound to  c-electric-semi&comma.
>
>I wrote a package for doing this, you can try it out.
>
>http://sourceforge.net/projects/casi-mode

Hmmm...  If you do want to try it, please download the code from CVS.
It is newer than the released file.

http://casi-mode.cvs.sourceforge.net/casi-mode/casi-mode/

Regards,
Guanpeng Xu

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE! 
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Insert ; after closing parenthesis when on it
       [not found]       ` <mailman.4529.1171488981.2155.help-gnu-emacs@gnu.org>
@ 2007-02-16  7:34         ` Markus Triska
  2007-02-16 18:32           ` Jiri Pejchal
  0 siblings, 1 reply; 11+ messages in thread
From: Markus Triska @ 2007-02-16  7:34 UTC (permalink / raw)
  To: help-gnu-emacs

Jiri Pejchal <jiri.pejchal@gmail.com> writes:

> And (c-electric-semi&comma ";") inserts ^E for me.

Try:  (c-electric-semi&comma nil)

All the best,
Markus Triska

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Insert ; after closing parenthesis when on it
  2007-02-16  7:34         ` Markus Triska
@ 2007-02-16 18:32           ` Jiri Pejchal
  0 siblings, 0 replies; 11+ messages in thread
From: Jiri Pejchal @ 2007-02-16 18:32 UTC (permalink / raw)
  To: help-gnu-emacs

Markus Triska <e0225855@stud4.tuwien.ac.at> writes:

> Jiri Pejchal <jiri.pejchal@gmail.com> writes:
>
>> And (c-electric-semi&comma ";") inserts ^E for me.
>
> Try:  (c-electric-semi&comma nil)
>
> All the best,
> Markus Triska

I see. Thanks. I have also changed if to while and the final version is:

(defun jump-closepar ()
 "Close parenthesis Jiri's way"
 (interactive)
 (while (looking-at ")")
               (forward-char))
 (c-electric-semi&comma nil))


 --
 Jiri Pejchal

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2007-02-16 18:32 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.4516.1171478780.2155.help-gnu-emacs@gnu.org>
2007-02-14 19:03 ` Insert ; after closing parenthesis when on it weber
2007-02-14 20:09   ` Jiri Pejchal
2007-02-14 20:41     ` Matthew Flaschen
2007-02-15  2:36     ` Herbert Euler
2007-02-15  2:40       ` Herbert Euler
     [not found]   ` <mailman.4523.1171483812.2155.help-gnu-emacs@gnu.org>
2007-02-14 20:36     ` weber
2007-02-14 21:36       ` Jiri Pejchal
     [not found]       ` <mailman.4529.1171488981.2155.help-gnu-emacs@gnu.org>
2007-02-16  7:34         ` Markus Triska
2007-02-16 18:32           ` Jiri Pejchal
2007-02-14 19:08 ` weber
2007-02-14 18:44 Jiri Pejchal

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.