help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: key map entry for shift-return?


From: Teemu Likonen
Subject: Re: key map entry for shift-return?
Date: Wed, 08 Jul 2009 15:17:24 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux)

On 2009-07-08 12:51 (+0100), Chris Withers wrote:

> Peter Dyballa wrote:
>> So you can use:
>>
>>     (global-set-key [S-return]     'some-function)
>
> Well, I now have the following in my .emacs:
>
> (add-hook 'python-mode-hook '(lambda () (define-key python-mode-map
> "\C-m" 'newline-and-indent)))
>
> (add-hook 'python-mode-hook '(lambda () (define-key python-mode-map
> "S-return" 'newline)))

That's not good practice. You should write your python-mode settings to
a single hook function and add function's "name" to the
python-mode-hook. For example, put these lines in your .emacs file:

    (add-hook 'python-mode-hook 'my-python-mode-hook)

    (defun my-python-mode-hook ()
      (define-key python-mode-map "\C-m" 'newline-and-indent)
      (define-key python-mode-map [S-return] 'newline))

Now if you need to change the settings you can just edit the function
and evaluate it with C-M-x.

(Note that python-mode-hook is a variable which may contain your
previous hook experiments "(lambda ...)" if you haven't restarted your
Emacs session. You should set the variable to nil before evaluating the
above code or you can just restart Emacs.)

> The first one works, the second one doesn't. What did I do wrong?

Note that I used [S-return], not "S-return". See Peter's message once
again.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]