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

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

Re: skeleton-pair-insert-maybe parenthesis in cc-mode


From: Kevin Rodgers
Subject: Re: skeleton-pair-insert-maybe parenthesis in cc-mode
Date: Tue, 06 Mar 2007 21:58:02 -0700
User-agent: Thunderbird 1.5.0.10 (Macintosh/20070221)

[Please don't top-post.]

stuart.tett@gmail.com wrote:
( runs the command c-electric-paren
   which is an interactive compiled Lisp function in `cc-cmds.el'.
It is bound to ), (.
When I am in a cc-mode file it returns:

(c-electric-paren arg)

Insert a parenthesis.

If `c-syntactic-indentation' and `c-electric-flag' are both non-nil,
the
line is reindented unless a numeric arg is supplied, or the
parenthesis
is inserted inside a literal.

Whitespace between a function name and the parenthesis may get added
or
removed; see the variable `c-cleanup-list'.

Also, if `c-electric-flag' and `c-auto-newline' are both non-nil, some
newline cleanups are done if appropriate; see the variable `c-cleanup-
list'.

In the *scratch* buffer it returns:

( runs the command skeleton-pair-insert-maybe
   which is an interactive compiled Lisp function in `skeleton.el'.
It is bound to {, [, <, (, ', ".
(skeleton-pair-insert-maybe arg)

Insert the character you type arg times.

With no arg, if `skeleton-pair' is non-nil, pairing can occur.  If the
region
is visible the pair is wrapped around it depending on `skeleton-
autowrap'.
Else, if `skeleton-pair-on-word' is non-nil or we are not before or
inside a
word, and if `skeleton-pair-filter-function' returns nil, pairing is
performed.
Pairing is also prohibited if we are right after a quoting character
such as backslash.

If a match is found in `skeleton-pair-alist', that is inserted, else
the defaults are used.  These are (), [], {}, <> and `' for the
symmetrical ones, and the same character twice for the others.

Isn't it obvious:

(add-hook 'c-mode-common-hook
          (lambda ()
            (local-set-key "(" 'skeleton-pair-insert-maybe)))

--
Kevin Rodgers
Denver, Colorado, USA





reply via email to

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