Thoughts on Perl and Emacs, technology and writing

Redefining “Important” Keys

I came across this old post recently and I’m always a little curious about people redefining their keys so extensively. So what did they lose? They changed C-oC-nC-sC-wC-f and M-s. Well, C-o is open-line – no big deal. C-n and C-f are both movement keys. I guess you could use cursor keys fairly easily (although for me both of those are burned into muscle memory).

C-s is isearch-forward which I, and probably almost all other emacs users, use all the time. However, in this configuration it has just moved to C-f which fits in with Windows terminology (find instead of search). M-s is a prefix key for a bunch of things. The only one I actually use is occur which I call using M-x anyway.

C-w (kill region) is really the only loss. And I’d prefer to have a longer combo to exit emacs just in case I hit it by mistake. Often enough I have scratch-pad work stored in fileless buffers (e.g. *temp*) which emacs would not warn me about if I tried to exit.

Overall this is a pretty radical overhaul of the keys and it doesn’t really break anything. They didn’t make the classic mistake of redefining C-x, but instead used cua-mode. Maybe it is worth considering moving keys around to fit my workflow better. What does eveyone else think?

Share this:

Like this:

Related

7 Responses

First, it’s your Emacs. Rejigger it the way you want to suit your flow and commonly used functions. They’re your wrists you’re saving.

On the other hand, you’re eventually going to end up with some bizarre behaviour because a package writer has assumed the standard keys for functions they write. Look at how org-mode redefines functions then gives them the traditional keybindings (or variations thereof).

And then there’s the confusion that’s generated on those occasions you have to use emacs -Q . Muscle memory can be a frightening thing sometimes.

I’m getting bolder with redefining keys (just mapped C-q from ‘quoted-insert to ‘mark-word). Like cameron says, it’s your Emacs (to which you can add: Emacs is not an editor, it’s an editor-building framework, yada yada…). It does make sense to preserve compatibility with other peoples’ Emacs-built editors, and the basic movement keys in Emacs are not bad, really (for a modeless editor), but keeping them is a trade off I don’t always want to make. I’m just going to say, I’m not ever going to do any work with a vanilla Emacs. I’m going to put my .emacs (and associated elisp packages) on a USB necklace, or in the cloud somewhere, then so be it. As of now, I need them.

Having said that… Though I’m a Windows user, I learn Emacs from Solaris and making Emacs work like a Windows app as far as keys go is not desirable to me (but YMMV). I even use CUA-mode, but not for the cut/copy/paste bindings, but just for its special Rectangular mode. I give your mentioned bindings a thumbs down. At least they don’t look like they conflict with the behavior of GNU Bash bindkey (oh wait, Alt-F is redefined, grrr).

… except I cannot live in Emacs without redefining C-z to M-x undo. 😉 What do you mean, it’s Control-/ and others? I cannot learn that! 😉

@cameron – yeah, I know what you mean about muscle memory. But I think I’ve got a seperate bit that can just about cope with vi and emacs -Q 🙂 Maybe I just use them enough. And I don’t think I’ve had a problem with a conflict yet. Actually, I put a lot of my extensions on f2 something…

@commonman – neat idea with carrying emacs config around on a USB-key, although I think my workplace has disabled USB access which is a bit of a pain. As you said, possibly better to drop the appropriate files somewhere on the internet instead.

@piyo – I briefly used cua-mode but I’m familiar with emacs cut and paste now. And I don’t think I would use the listed keys, but I’m certainly more open to radical modifications now, having read that post. I think I came across the emacsblog article but (as usual) haven’t got around to making use of the tip yet.

The two-character keys consisting of `C-c’ followed by a letter are reserved for user customizations. Lisp programs are not supposed to define these keys, so the bindings you make for them will be available in all major modes and will never get in the way of anything.

At least two modes I use violate this rule: tcl-mode and verilog-mode. I’m always annoyed when my C-c C-i doesn’t indent a region, but calls up tcl-help-on-word.

So most of my personal keybindings are C-c XXX. Except it’s very useful to (global-set-key “\C-x\C-u” `advertised-undo).

Although you [fortunately] were not talking about my stuff, I think a lot of the code I write violates the C-c + letter rule as I haven’t yet tidied it up for other folk’s consumption – its too easy to do.