Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Parenthesis matching

8 views
Skip to first unread message

christophe...@googlemail.com

unread,
Mar 15, 2009, 7:28:19 PM3/15/09
to
Hi,

added these lines to my .emacs-file, so that parenthesis are
automatically matched:
(setq skeleton-pair t)
(global-set-key (kbd "(") 'skeleton-pair-insert-maybe)
(global-set-key (kbd "{") 'skeleton-pair-insert-maybe)

But it does not work in cc-mode. Any idea?

Regards,

Chris

Martin

unread,
Mar 16, 2009, 2:45:10 AM3/16/09
to

"christopher.morris" writes:

Hi,

how about

(global-set-key (kbd "\(") 'skeleton-pair-insert-maybe)
(global-set-key (kbd "\{") 'skeleton-pair-insert-maybe)

?

Cheers

Martin
--
parozusa at web dot de

steve

unread,
Jul 19, 2021, 12:39:30 AM7/19/21
to
"christophe...@googlemail.com"
I got one for you. this is called si-superparen. It's used in lisp when
closing a function; it reindents and fills in the appropriate number of
parens. There is probably a better implentation out there; slime or
so...

I don't think I wrote this myself; I don't even remeber how it works.
What was I thinking? I've been using it for years...


(defun si:super-paren (prefix)
"Indent and insert closing parens for the sexp at point.
When prefix argument is given no indentation is performed."
(interactive "P")
(unless prefix
(lisp-indent-line))
(delete-char
(save-excursion (skip-chars-backward ") \t")))
(delete-horizontal-space)
(save-restriction
(narrow-to-region (point)
(save-excursion
(beginning-of-defun)
(point)))
(let (p)
(while (progn
(setq p (point))
(beginning-of-defun)
(condition-case nil
(progn (forward-sexp 1) nil)
(error t)))
(goto-char p)
(insert ?\) ))
(when (> (point) p)
(delete-region p (point)))))
(unless prefix
(beginning-of-defun)
(if (not (eq major-mode 'emacs-lisp-mode))
(condition-case nil
(lisp-indent-function (point) 'defun)
(error t))
(indent-sexp))
(forward-sexp 1)))


Huh?
0 new messages