From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.help Subject: Re: Novice question: my add-hook binding for c-mode doesnt work :( Date: Sat, 3 Dec 2005 21:15:38 +0000 Organization: muc.de e.V. -- private internet access Message-ID: References: <1732372.post@talk.nabble.com> <8764q8yorw.fsf@totoz.gnu-rox.org> <20051202070701.B40573F28@rocksteady.printf.se> NNTP-Posting-Host: main.gmane.org X-Trace: sea.gmane.org 1133646999 9946 80.91.229.2 (3 Dec 2005 21:56:39 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 3 Dec 2005 21:56:39 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Dec 03 22:56:39 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EifLl-00016B-9Y for geh-help-gnu-emacs@m.gmane.org; Sat, 03 Dec 2005 22:55:21 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EifLn-0003xe-1L for geh-help-gnu-emacs@m.gmane.org; Sat, 03 Dec 2005 16:55:23 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed00.sul.t-online.de!t-online.de!newsfeed.freenet.de!news.space.net!news.muc.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 22 Original-NNTP-Posting-Host: acm.muc.de Original-X-Trace: marvin.muc.de 1133646514 57933 193.149.49.134 (3 Dec 2005 21:48:34 GMT) Original-X-Complaints-To: news-admin@muc.de Original-NNTP-Posting-Date: 3 Dec 2005 21:48:34 GMT User-Agent: tin/1.4.5-20010409 ("One More Nightmare") (UNIX) (Linux/2.0.35 (i686)) Original-Xref: shelby.stanford.edu gnu.emacs.help:136046 Original-To: help-gnu-emacs@gnu.org 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:31653 Archived-At: "Kpoxman (sent by Nabble.com)" wrote on Fri, 2 Dec 2005 01:10:36 -0800 (PST): > Thank you guys! > So, the correct code is (I've tested and it works): > (add-hook 'c-mode-common-hook > '(lambda () (define-key c-mode-base-map (kbd "M-o") 'kpox-switch-h-cpp)) > ) Just one small point: The above code "adds" the binding to the key map every time you open a CC Mode buffer. You really only need to add the key binding once: use CC Mode's initialization hook instead: (add-hook 'c-initialization-hook '(lambda () (define-key c-mode-base-map (kbd "M-o") 'kpox-switch-h-cpp))) -- Alan Mackenzie (Munich, Germany) Email: aacm@muuc.dee; to decode, wherever there is a repeated letter (like "aa"), remove half of them (leaving, say, "a").