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

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

Re: Is it possible to make M-C-p and M-C-n global aliases for M-down and


From: Stefan Monnier
Subject: Re: Is it possible to make M-C-p and M-C-n global aliases for M-down and M-up?
Date: Fri, 26 Feb 2021 12:49:58 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

> (define-key minibuffer-local-map [C-p] 'previous-history-element)
> (define-key minibuffer-local-map [C-n] 'next-history-element)

The C-n and C-p keys normally don't generate events `C-p` and `C-n`
(which are symbols) but `?\C-p` and `?\C-n` instead (which are
characters).  So use

    (define-key minibuffer-local-map [?\C-p] 'previous-history-element)
    (define-key minibuffer-local-map [?\C-n] 'next-history-element)

or

    (define-key minibuffer-local-map (kbd "C-p") 'previous-history-element)
    (define-key minibuffer-local-map (kbd "C-n") 'next-history-element)

since `kbd` is reasonably good at hiding those ugly internal details.

or

    (define-key minibuffer-local-map [(control p)] 'previous-history-element)
    (define-key minibuffer-local-map [(control n)] 'next-history-element)

Since XEmacs also tried to hide those details and Emacs does support
XEmacs's syntax here.


        Stefan




reply via email to

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