Discussion:
Parenthesis matching
(too old to reply)
c***@googlemail.com
2009-03-15 23:28:19 UTC
Permalink
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
2009-03-16 06:45:10 UTC
Permalink
Post by c***@googlemail.com
Hi,
added these lines to my .emacs-file, so that parenthesis are
(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
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
2021-07-19 04:39:24 UTC
Permalink
Post by c***@googlemail.com
Hi,
added these lines to my .emacs-file, so that parenthesis are
(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
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?

Continue reading on narkive:
Loading...