From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.help Subject: Re: Indentation in python.el after "Enter" Date: Wed, 11 Jul 2007 05:46:51 -0400 Message-ID: References: NNTP-Posting-Host: lo.gmane.org X-Trace: sea.gmane.org 1184147283 8930 80.91.229.12 (11 Jul 2007 09:48:03 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 11 Jul 2007 09:48:03 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Jul 11 11:48:02 2007 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 1I8Yng-0001nL-GU for geh-help-gnu-emacs@m.gmane.org; Wed, 11 Jul 2007 11:48:00 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1I8Yng-00082p-2h for geh-help-gnu-emacs@m.gmane.org; Wed, 11 Jul 2007 05:48:00 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1I8YmD-0007AS-D3 for help-gnu-emacs@gnu.org; Wed, 11 Jul 2007 05:46:29 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1I8YmB-0007AC-V3 for help-gnu-emacs@gnu.org; Wed, 11 Jul 2007 05:46:28 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1I8YmA-0007A6-42 for help-gnu-emacs@gnu.org; Wed, 11 Jul 2007 05:46:27 -0400 Original-Received: from fencepost.gnu.org ([140.186.70.10]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1I8Ym9-0006D9-QE for help-gnu-emacs@gnu.org; Wed, 11 Jul 2007 05:46:25 -0400 Original-Received: from eliz by fencepost.gnu.org with local (Exim 4.60) (envelope-from ) id 1I8YmZ-000153-Ia for help-gnu-emacs@gnu.org; Wed, 11 Jul 2007 05:46:51 -0400 In-reply-to: (astsmtl@gmail.com) X-detected-kernel: Linux 2.6, seldom 2.4 (older, 4) 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:45591 Archived-At: > Date: Wed, 11 Jul 2007 14:07:13 +0500 > From: "Alexander Tsamutali" > > I added the following to my .emacs: > > (add-hook 'python-mode-hook > (lambda () (define-key python-mode-map "\C-m" 'newline-and-indent))) > > Then i found solution to my problem on EmacsWiki > (http://www.emacswiki.org/cgi-bin/wiki/PythonMode) > They recommend to add the following to .emacs: > > (define-key python-mode-map "\C-m" 'newline-and-indent) > > I can guess that first variant modifies key bindings only in python > mode and second modifies key bindings globally. Am i right? No, they both bind the Enter key in Python mode only, but the Wiki solution requires that you load python.el in your .emacs, before you bind the key, because otherwise python-mode-map is not defined, and Emacs will barf. The add-hook method is the better one, because it binds the key whenever a buffer enters the Python mode, exactly when you need that.