all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Binding M-n in info mode.
@ 2011-09-02  9:14 Dani Moncayo
  2011-09-02  9:25 ` Eli Zaretskii
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Dani Moncayo @ 2011-09-02  9:14 UTC (permalink / raw)
  To: help-gnu-emacs

Hi folks,

I want to bind M-p/M-n globally to
backward-paragraph/forward-paragraph, so that I wrote this in my
.emacs:

  (define-key global-map "\M-p" 'backward-paragraph)
  (define-key global-map "\M-n" 'forward-paragraph)

It worked right, but then I realized that info mode binds M-n to
clone-buffer.  In this mode I also want to bind M-n to
forward-paragraph, so that I added this:

  (define-key Info-mode-map "\M-n" 'forward-paragraph)

The problem is that this last remapping fails when starting my Emacs
because, at that time, the variable Info-mode-map doesn't not exits.

What is the right way of solving this?

TIA

-- 
Dani Moncayo



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Binding M-n in info mode.
  2011-09-02  9:14 Binding M-n in info mode Dani Moncayo
@ 2011-09-02  9:25 ` Eli Zaretskii
  2011-09-02  9:31   ` Dani Moncayo
  2011-09-02 10:14 ` Deniz Dogan
  2011-09-02 11:14 ` Thien-Thi Nguyen
  2 siblings, 1 reply; 10+ messages in thread
From: Eli Zaretskii @ 2011-09-02  9:25 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Fri, 2 Sep 2011 11:14:11 +0200
> From: Dani Moncayo <dmoncayo@gmail.com>
> 
> It worked right, but then I realized that info mode binds M-n to
> clone-buffer.  In this mode I also want to bind M-n to
> forward-paragraph, so that I added this:
> 
>   (define-key Info-mode-map "\M-n" 'forward-paragraph)
> 
> The problem is that this last remapping fails when starting my Emacs
> because, at that time, the variable Info-mode-map doesn't not exits.
> 
> What is the right way of solving this?

Do `(require 'info)' before you remap.



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Binding M-n in info mode.
  2011-09-02  9:25 ` Eli Zaretskii
@ 2011-09-02  9:31   ` Dani Moncayo
  0 siblings, 0 replies; 10+ messages in thread
From: Dani Moncayo @ 2011-09-02  9:31 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: help-gnu-emacs

> Do `(require 'info)' before you remap.

Solved.  Thank you Eli.

-- 
Dani Moncayo



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Binding M-n in info mode.
  2011-09-02  9:14 Binding M-n in info mode Dani Moncayo
  2011-09-02  9:25 ` Eli Zaretskii
@ 2011-09-02 10:14 ` Deniz Dogan
  2011-09-02 11:14 ` Thien-Thi Nguyen
  2 siblings, 0 replies; 10+ messages in thread
From: Deniz Dogan @ 2011-09-02 10:14 UTC (permalink / raw)
  To: Dani Moncayo; +Cc: help-gnu-emacs

On 2011-09-02 11:14, Dani Moncayo wrote:
> Hi folks,
>
> I want to bind M-p/M-n globally to
> backward-paragraph/forward-paragraph, so that I wrote this in my
> .emacs:
>

Cool idea! ;)

>    (define-key global-map "\M-p" 'backward-paragraph)
>    (define-key global-map "\M-n" 'forward-paragraph)
>
> It worked right, but then I realized that info mode binds M-n to
> clone-buffer.  In this mode I also want to bind M-n to
> forward-paragraph, so that I added this:
>
>    (define-key Info-mode-map "\M-n" 'forward-paragraph)
>
> The problem is that this last remapping fails when starting my Emacs
> because, at that time, the variable Info-mode-map doesn't not exits.
>
> What is the right way of solving this?
>
> TIA
>

You could either do it Eli's way or "my" way:

(eval-after-load "info"
   '(define-key Info-mode-map (kbd "M-n") 'forward-paragraph))

I'm not sure which is "better".



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Binding M-n in info mode.
  2011-09-02  9:14 Binding M-n in info mode Dani Moncayo
  2011-09-02  9:25 ` Eli Zaretskii
  2011-09-02 10:14 ` Deniz Dogan
@ 2011-09-02 11:14 ` Thien-Thi Nguyen
  2011-09-02 12:17   ` Dani Moncayo
  2 siblings, 1 reply; 10+ messages in thread
From: Thien-Thi Nguyen @ 2011-09-02 11:14 UTC (permalink / raw)
  To: Dani Moncayo; +Cc: help-gnu-emacs

() Dani Moncayo <dmoncayo@gmail.com>
() Fri, 2 Sep 2011 11:14:11 +0200

   What is the right way of solving this?

no worries to go w/ the pre-load
  (it's wee code), as Eli suggested above
but mayhaps one enjoys the parsimony
  (not always phony), of experience-wrested love:
‘eval-after-load’ delays the remapping
  (less memory-sapping), until you really need it;
‘add-hook’ denies the stoned noncing
  (o profligate consing): emacs grows as you feed it.



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Binding M-n in info mode.
  2011-09-02 11:14 ` Thien-Thi Nguyen
@ 2011-09-02 12:17   ` Dani Moncayo
  2011-09-02 16:07     ` Vijay Lakshminarayanan
  0 siblings, 1 reply; 10+ messages in thread
From: Dani Moncayo @ 2011-09-02 12:17 UTC (permalink / raw)
  To: Thien-Thi Nguyen; +Cc: help-gnu-emacs

> no worries to go w/ the pre-load
>  (it's wee code), as Eli suggested above
> but mayhaps one enjoys the parsimony
>  (not always phony), of experience-wrested love:
> ‘eval-after-load’ delays the remapping
>  (less memory-sapping), until you really need it;
> ‘add-hook’ denies the stoned noncing
>  (o profligate consing): emacs grows as you feed it.

What is that?  Poetry?? ;))

Well, thanks to all of you for helping!

-- 
Dani Moncayo



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Binding M-n in info mode.
  2011-09-02 12:17   ` Dani Moncayo
@ 2011-09-02 16:07     ` Vijay Lakshminarayanan
  2011-09-02 16:17       ` Deniz Dogan
  2011-09-02 19:59       ` Dani Moncayo
  0 siblings, 2 replies; 10+ messages in thread
From: Vijay Lakshminarayanan @ 2011-09-02 16:07 UTC (permalink / raw)
  To: Dani Moncayo; +Cc: help-gnu-emacs, Thien-Thi Nguyen

Dani Moncayo <dmoncayo@gmail.com> writes:

>> no worries to go w/ the pre-load
>>  (it's wee code), as Eli suggested above
>> but mayhaps one enjoys the parsimony
>>  (not always phony), of experience-wrested love:
>> ‘eval-after-load’ delays the remapping
>>  (less memory-sapping), until you really need it;
>> ‘add-hook’ denies the stoned noncing
>>  (o profligate consing): emacs grows as you feed it.
>
> What is that?  Poetry?? ;))

It is, and it's pretty good.  Nice one, Thien.

> Well, thanks to all of you for helping!

What Thien means is you should, in your .emacs, use

;; COMPLETELY untested
(eval-after-load "info"
  (progn 
    (define-key Info-mode-map (kbd "M-n") #'forward-paragraph)
    (define-key Info-mode-map (kbd "M-n") #'backward-paragraph)))

because it (a) delays the remapping and (b) is less memory sapping.
Furthermore, you could, to prevent "profligate consing", choose to
define the custom keybindings as an Info-mode-hook.

-- 
Cheers
~vijay

Gnus should be more complicated.



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Binding M-n in info mode.
  2011-09-02 16:07     ` Vijay Lakshminarayanan
@ 2011-09-02 16:17       ` Deniz Dogan
  2011-09-02 20:02         ` Dani Moncayo
  2011-09-02 19:59       ` Dani Moncayo
  1 sibling, 1 reply; 10+ messages in thread
From: Deniz Dogan @ 2011-09-02 16:17 UTC (permalink / raw)
  To: Vijay Lakshminarayanan; +Cc: help-gnu-emacs, Thien-Thi Nguyen

On 2011-09-02 18:07, Vijay Lakshminarayanan wrote:
>      (define-key Info-mode-map (kbd "M-n") #'forward-paragraph)
>      (define-key Info-mode-map (kbd "M-n") #'backward-paragraph)))
>

To Dani (and others): Note that the # prefix is not necessary in Emacs 
Lisp (it is ignored).  It is used by some Lisp dialects, such as Common 
Lisp to denote a function name.



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Binding M-n in info mode.
  2011-09-02 16:07     ` Vijay Lakshminarayanan
  2011-09-02 16:17       ` Deniz Dogan
@ 2011-09-02 19:59       ` Dani Moncayo
  1 sibling, 0 replies; 10+ messages in thread
From: Dani Moncayo @ 2011-09-02 19:59 UTC (permalink / raw)
  To: Vijay Lakshminarayanan; +Cc: help-gnu-emacs, Thien-Thi Nguyen

>> What is that?  Poetry?? ;))
>
> It is, and it's pretty good.  Nice one, Thien.

I agree, of course.

>> Well, thanks to all of you for helping!
>
> What Thien means is you should, in your .emacs, use
>
> ;; COMPLETELY untested
> (eval-after-load "info"
>  (progn
>    (define-key Info-mode-map (kbd "M-n") #'forward-paragraph)
>    (define-key Info-mode-map (kbd "M-n") #'backward-paragraph)))
>
> because it (a) delays the remapping and (b) is less memory sapping.
> Furthermore, you could, to prevent "profligate consing", choose to
> define the custom keybindings as an Info-mode-hook.

Thanks for the extra explanation.

-- 
Dani Moncayo



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Binding M-n in info mode.
  2011-09-02 16:17       ` Deniz Dogan
@ 2011-09-02 20:02         ` Dani Moncayo
  0 siblings, 0 replies; 10+ messages in thread
From: Dani Moncayo @ 2011-09-02 20:02 UTC (permalink / raw)
  To: Deniz Dogan; +Cc: help-gnu-emacs, Thien-Thi Nguyen

On Fri, Sep 2, 2011 at 18:17, Deniz Dogan <deniz@dogan.se> wrote:
> On 2011-09-02 18:07, Vijay Lakshminarayanan wrote:
>>
>>     (define-key Info-mode-map (kbd "M-n") #'forward-paragraph)
>>     (define-key Info-mode-map (kbd "M-n") #'backward-paragraph)))
>>
>
> To Dani (and others): Note that the # prefix is not necessary in Emacs Lisp
> (it is ignored).  It is used by some Lisp dialects, such as Common Lisp to
> denote a function name.

Understood. Thanks.


-- 
Dani Moncayo



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2011-09-02 20:02 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-02  9:14 Binding M-n in info mode Dani Moncayo
2011-09-02  9:25 ` Eli Zaretskii
2011-09-02  9:31   ` Dani Moncayo
2011-09-02 10:14 ` Deniz Dogan
2011-09-02 11:14 ` Thien-Thi Nguyen
2011-09-02 12:17   ` Dani Moncayo
2011-09-02 16:07     ` Vijay Lakshminarayanan
2011-09-02 16:17       ` Deniz Dogan
2011-09-02 20:02         ` Dani Moncayo
2011-09-02 19:59       ` Dani Moncayo

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.