Disclaimer

The content of this blog is my personal opinion only. Although I am an employee - currently of Imagination Technologies's MIPS group, in the past of other companies such as Intellectual Ventures, Intel, AMD, Motorola, and Gould - I reveal this only so that the reader may account for any possible bias I may have towards my employer's products. The statements I make here in no way represent my employer's position, nor am I authorized to speak on behalf of my employer. In fact, this posting may not even represent my personal opinion, since occasionally I play devil's advocate.

See http://docs.google.com/View?id=dcxddbtr_23cg5thdfj for photo credits.

Friday, January 01, 2016

Using CUA ^C/^X/^V as well as command-C/X/V on Mac

I have been using my MacBook as my primary computer for a year now - and I still have trouble typing command-C/X/V for copy/cut/paste, rather than the Windows like control-C/X/V.

More precisely, perhaps, the CUA, Common User Access, key bindings, that date back to Xerox PARC (and earlier, I think). http://en.wikipedia.org/wiki/IBM_Common_User_Access

Oddly enough, I had managed to make the transition in my first few weeks or so, perhaps a month, on the Mac - up until I got a proper emacs working on my Mac. Now, I do NOT use ^C/^X/^V key bindings on Emacs.  But for some reason using Emacs pushed any new key bindings out of my cache, and I found that I started experiencing control/command confusion on Mac apps more often. Perhaps this happened because emacs uses SO MANY control key bindings - and I decided not to use any of the several ways of having emacs treat Mac command key as equivalent of control in standard emacs key bindings. (TBD: notes on this: briefly, doesn't always work).   So control is in the front of my mind when using emacs, even on a Mac.   Or perhaps this confusion became more prominent because when I am using emacs I work faster - so the errors waste a greater fraction of my time.

Sometime over Xmas this became really frustrating, so I set out to fix it.

Now, I do not want to globally swap command and control.  I want to use standard Mac key bindings as much as possible.  Also, globally swapping command and control messes up other apps, such as Windows RDP.   No, instead all I want to do is to take the keys that are problematic - typing ^C instead of command+C, etc., in my web browser - and remap only those keys.  While leaving the standard command+C/X/V bindings unaffected.

Ideally, do this in only the apps where I am constantly making these errors - mainly, cutting and pasting between my web browser and emacs.   Or do it globally, but ideally without affecting the existing emacs keybindings - i.e. have ^C behave like command+C in my web browser, and in most other places, but not in emacs or any place where the standard Mac bindings do not apply.

Here's a post along these lines:

http://apple.stackexchange.com/questions/66970/remap-ctrlc-ctrlv-and-ctrl-x-only

Here's a great webpage about Apple Cocoa key bindings:

http://www.hcs.harvard.edu/~jrus/site/cocoa-text.html

Surprisingly, Apple's Cocoa key binding mechanism is almost as powerful as EMACS'.  It permits nearly any key to be rebound, it allows emacs-style multiple key sequences to be bound, and it allows multiple bindings to the same command.

Surprising or not, most Apple key binding tools do not provide anywhere near this control.  Why not?  I conjecture that this is a carry-over from NeXT, from the old days when Men were Men, and Power Users wanted real keyboard control.  But that it has fallen into disuse with the rise of mass market non-power-user computing, and "usability" gurus who deprecate functionality.

Also, while the remapping facility is powerful, it only applies to Cocoa apps.  It is not ubiquitous.  Apple has a long history of "software model tunnel vision", reflected in security bugs such as the "We assume that everyone is using Objective C,and cannot forge message names".

Anyway, here's what I ended up doing: placing the following in ~/Library/KeyBindings/DefaultKeyBinding.dict

{
    "^a"        = "selectAll:";                     /* C-a  Select all */
    "^x"        = "cut:";                           /* C-x   Cut */
    "^c"        = "copy:";                          /* C-c          Copy */
    "^v"        = "paste:";                         /* C-v          Paste */
    "^z"        = "undo:";                          /* C-z          Undo */
    "^y"        = "redo:";                          /* C-y          Redo */ 
}
Now, this provides the mappings in all Cocoa apps. No ability to say "do this only in Chrome".  But it seems good enough for now.

No comments: