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

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

Redefine "(" and ")" keys in every mode


From: TheLonelyStar
Subject: Redefine "(" and ")" keys in every mode
Date: Sat, 3 Jan 2009 07:31:00 -0800 (PST)

Hi,

I use the following functions (bellow) for redifine the insertions if ( and
).
The Idea is: When I type (, I want () inserted. When I type ) and the next
character is ), I want to just jump over it.

The Problem is: This works, as long as the mode I am in does not overwrite
the "(" or ")" key.
And, at the same time, when the mode overwrites this keys, it normaly has a
reason for it.

Has somebody an Idea how this can be done, so that it works in every mode?
Thanks!
Nathan

The functions:
-----------------------------------
(defun bracket (arg)
  (interactive "*P")
  (insert "()")
  (backward-char))
(define-key global-map (kbd "(") 'bracket)

;;Jump after character on insertion
(defun end-insertion (arg)
  (interactive "*p")
  (if (looking-at (concat "[\n \t]*" (this-command-keys))) (goto-char
(match-end 0)) (insert (this-command-keys)) (indent-according-to-mode))
)

(define-key global-map (kbd ")") 'end-insertion)
(define-key c-mode-base-map (kbd ")") 'end-insertion)
------------------------------
-- 
View this message in context: 
http://www.nabble.com/Redefine-%22%28%22-and-%22%29%22-keys-in-every-mode-tp21265910p21265910.html
Sent from the Emacs - Help mailing list archive at Nabble.com.





reply via email to

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