From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: efrem Newsgroups: gmane.emacs.help Subject: Re: programming file-extensions in .emacs Date: Wed, 27 Feb 2008 23:36:01 -0800 (PST) Organization: http://groups.google.com Message-ID: References: <6d54fc34-7e67-4dd0-9c99-be7796283cdb@e25g2000prg.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1204184435 21295 80.91.229.12 (28 Feb 2008 07:40:35 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 28 Feb 2008 07:40:35 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Feb 28 08:41:00 2008 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 1JUdNz-0007ys-3C for geh-help-gnu-emacs@m.gmane.org; Thu, 28 Feb 2008 08:40:59 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JUdNS-000854-So for geh-help-gnu-emacs@m.gmane.org; Thu, 28 Feb 2008 02:40:26 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!p73g2000hsd.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 53 Original-NNTP-Posting-Host: 159.93.70.126 Original-X-Trace: posting.google.com 1204184161 12777 127.0.0.1 (28 Feb 2008 07:36:01 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Thu, 28 Feb 2008 07:36:01 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: p73g2000hsd.googlegroups.com; posting-host=159.93.70.126; posting-account=BOgndwoAAADBBHoqOGJLIQsUNUBaJ_CW User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.9) Gecko/20061222 CentOS/1.5.0.9-0.1.el4.centos4 Firefox/1.5.0.9, gzip(gfe), gzip(gfe) Original-Xref: shelby.stanford.edu gnu.emacs.help:156561 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:51929 Archived-At: On Feb 27, 7:55 pm, Harald Hanche-Olsen wrote: > + efrem : > > > I'd like to change the .emacs file in order to > > make some key-setting for the cases of xxxx.f and xxxx.cc files. > > Then take advantage of the work that emacs already does for you, and > change the key definitions for the corresponding modes. *.f and *.cc > are edited using fortran-mode and c++-mode respectively. And these > modes, when activated, cause the running of hooks name fortran-mode-hook > and c++-mode-hook respectively. So instead of > > > (let (fname suffix) > > (setq fname (buffer-file-name)) > > (setq suffix (file-name-extension fname)) > > (if (equal suffix "cc") > > (progn > > (global-set-key [f2] 'insert-cout1) > > (global-set-key [f3] 'insert-cout4) > > )) > > (if (equal suffix "f") > > (progn > > (global-set-key [f8] 'nn3) > > (global-set-key [f9] 'delete-backward-char) > > )) > > you may try this in your .emacs: > > (defun set-my-c++-keys () > (local-set-key [f2] 'insert-cout1) > (local-set-key [f3] 'insert-cout4)) > > (add-hook 'c++-mode-hook 'set-my-c++-keys) > > (defun set-my-fortran-keys () > (local-set-key [f8] 'nn3) > (local-set-key [f9] 'delete-backward-char)) > > (add-hook 'fortran-mode-hook 'set-my-fortran-keys) > > Note that I use local-set-key. There is little point, I think, in > polluting the global keymap with mode specific bindings. > > -- > * Harald Hanche-Olsen > - It is undesirable to believe a proposition > when there is no ground whatsoever for supposing it is true. > -- Bertrand Russell It's good. Thank you very much! Best wishes Oleg