all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "weber" <hugows@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Insert ; after closing parenthesis when on it
Date: 14 Feb 2007 11:03:36 -0800	[thread overview]
Message-ID: <1171479816.170529.163000@a75g2000cwd.googlegroups.com> (raw)
In-Reply-To: <mailman.4516.1171478780.2155.help-gnu-emacs@gnu.org>

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

       reply	other threads:[~2007-02-14 19:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.4516.1171478780.2155.help-gnu-emacs@gnu.org>
2007-02-14 19:03 ` weber [this message]
2007-02-14 20:09   ` Insert ; after closing parenthesis when on it 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1171479816.170529.163000@a75g2000cwd.googlegroups.com \
    --to=hugows@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.