all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Fabian Ezequiel Gallina <galli.87@gmail.com>
To: Noah Lavine <noah549@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: Key Mapping Proposal
Date: Sat, 16 Jan 2010 04:57:38 -0300	[thread overview]
Message-ID: <9de1a5ef1001152357u45eb42d8g7d48fee1b885e910@mail.gmail.com> (raw)
In-Reply-To: <16d22e431001151603i5d2fab77u4f3054bb7e708323@mail.gmail.com>

2010/1/15 Noah Lavine <noah549@gmail.com>:
> Dear emacs-devel,
>
> I'd like to suggest a change to the way modes bind keys, to make it
> easier for users to customize keys.
>
> Right now, as far as I can tell, each mode defines some functions and
> then binds the appropriate keys to them. There are certain keys that
> have conventional meanings, so "C-f" means forward even if you're in
> picture-mode, and so on, and modes all try to respect this. The
> problem comes if you want to change the meaning of not just one key
> sequence, but the convention. Some people might like to use C-f, C-d,
> C-s, and C-e to move forward, down, back and up, because they're right
> next to each other. In order to achieve this now, you would need to
> rebind those keys in each mode that you use. It seems like there
> should be a better way.
>
> My suggestion is this: have one location which stores the user's
> keybinding for the "forward" key, whatever "forward" means for a
> particular mode. Any given mode would then use this to bind their
> particular "forward" function to whatever key the user wanted. Do the
> same for other keys with conventional meaning, and then modify the
> major modes to use these in their keybindings.
>
> One issue that might occur is if the user's bindings for a
> conventional key conflict with a binding unique to one particular
> major mode. You'd want a system for bouncing the other bindings around
> to prevent this, perhaps by keeping a list of unbound keys and then
> assigning the functions that need bindings to those keys one by one.
> This would give up the ability to give mnemonic key bindings to
> functions, but the issue would only occur if the user was customizing
> their keys, in which case it seems like the user's preferences should
> take priority.
>
> I'm happy to contribute work to this, but I wanted to ask emacs-devel
> first to see if you were interested in this, and if so, what you
> thought the right approach was.
>
> Thank you
> Noah Lavine
>

I agree it is a good idea, my guess is that this could be achieved if
modes use `substitute-key-definition' to define analog commands for
standard commands (forward-char, backward-char, etc) like this:

(defvar my-mode-map
  (let ((my-mode-map (make-sparse-keymap)))
    (define-key my-mode-map "\C-ch" 'my-do-something)
    (substitute-key-definition 'forward-char 'my-forward-char
my-mode-map (current-global-map))))

This way if I rebind C-f (forward-char) to M-f globally this should
make M-f to call my-forward-char when i'm using my-mode.

(global-set-key (kbd "M-f") 'forward-char)

So my guess is that it is just a matter of fixing that on every mode
not using `substitute-key-definition' for standard commands.



Regards,
-- 
Fabián E. Gallina
http://www.from-the-cloud.com




  reply	other threads:[~2010-01-16  7:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-16  0:03 Key Mapping Proposal Noah Lavine
2010-01-16  7:57 ` Fabian Ezequiel Gallina [this message]
2010-01-16  8:17 ` Stephen J. Turnbull
2010-01-16 18:41   ` Noah Lavine
2010-01-17  5:49     ` Stephen J. Turnbull
2010-01-16  8:25 ` Teemu Likonen
2010-01-16 14:22 ` Eric M. Ludlam
2010-01-16 19:28 ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9de1a5ef1001152357u45eb42d8g7d48fee1b885e910@mail.gmail.com \
    --to=galli.87@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=noah549@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.