From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: TheLonelyStar Newsgroups: gmane.emacs.help Subject: Redefine "(" and ")" keys in every mode Date: Sat, 3 Jan 2009 07:31:00 -0800 (PST) Message-ID: <21265910.post@talk.nabble.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1231013352 13307 80.91.229.12 (3 Jan 2009 20:09:12 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 3 Jan 2009 20:09:12 +0000 (UTC) To: Help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Jan 03 21:10:23 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LJCpB-0005Hi-0m for geh-help-gnu-emacs@m.gmane.org; Sat, 03 Jan 2009 21:10:21 +0100 Original-Received: from localhost ([127.0.0.1]:46647 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LJCnv-0003Tm-U1 for geh-help-gnu-emacs@m.gmane.org; Sat, 03 Jan 2009 15:09:03 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LJ8St-00008k-7P for help-gnu-emacs@gnu.org; Sat, 03 Jan 2009 10:31:03 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LJ8Sr-00008Y-Km for Help-gnu-emacs@gnu.org; Sat, 03 Jan 2009 10:31:01 -0500 Original-Received: from [199.232.76.173] (port=50772 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LJ8Sr-00008V-FL for Help-gnu-emacs@gnu.org; Sat, 03 Jan 2009 10:31:01 -0500 Original-Received: from kuber.nabble.com ([216.139.236.158]:50027) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LJ8Sr-0002iV-1H for Help-gnu-emacs@gnu.org; Sat, 03 Jan 2009 10:31:01 -0500 Original-Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1LJ8Sq-0004MF-1v for Help-gnu-emacs@gnu.org; Sat, 03 Jan 2009 07:31:00 -0800 X-Nabble-From: nabble2@lonely-star.org X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-Mailman-Approved-At: Sat, 03 Jan 2009 15:08:45 -0500 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:61039 Archived-At: 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.