From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Michael Slass Newsgroups: gmane.emacs.help Subject: Re: best way to add commands to c-mode??.... Date: Wed, 23 Oct 2002 19:46:27 GMT Organization: AT&T Broadband Sender: help-gnu-emacs-admin@gnu.org Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1035402751 27957 80.91.224.249 (23 Oct 2002 19:52:31 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 23 Oct 2002 19:52:31 +0000 (UTC) Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 184RYL-0007Gf-00 for ; Wed, 23 Oct 2002 21:52:29 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 184RXe-0004Qs-00; Wed, 23 Oct 2002 15:51:46 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!logbridge.uoregon.edu!nntp-server.caltech.edu!attla2!ip.att.net!attbi_feed3!attbi.com!rwcrnsc53.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 47 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Original-NNTP-Posting-Host: 12.228.27.239 Original-X-Complaints-To: abuse@attbi.com Original-X-Trace: rwcrnsc53 1035402387 12.228.27.239 (Wed, 23 Oct 2002 19:46:27 GMT) Original-NNTP-Posting-Date: Wed, 23 Oct 2002 19:46:27 GMT Original-Xref: shelby.stanford.edu gnu.emacs.help:106312 Original-To: help-gnu-emacs@gnu.org Errors-To: help-gnu-emacs-admin@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.help:2862 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:2862 seberino@spawar.navy.mil writes: >Is this the simplest way to add commands to c-mode?... > >(defun cs-c-mode() (interactive) > (c-mode) > (c-set-style "K&R") > (setq c-basic-offset 3) > (local-set-key "\C-d" 'cs-kill-line)) > > >Did I have to define a new mode/function to add >these 3 commands?? > The most common paradigm is 1) define a function that does all your c-mode customizations 2) add your function to one of the c-mode hooks (defun cs-c-mode-setup () (c-set-style "K&R") (setq c-basic-offset 3) (local-set-key "\C-d" 'cs-kill-line)) (add-hook 'c-mode-hook 'cs-c-mode-setup) One of the last things c-mode does when it starts is to run all the functions listed in the c-mode-hook variable. Check out the documentation for hooks in the emacs manual C-h i m emacs m hook which talks about exactly what you're trying to do. Also, if you're using a newer emacs, there is another hook that's used for all c-like modes. Once you've loaded c-mode, try M-x apropos c.*common to see the names of the variables. -- Mike Slass