11

I can use emacs commands everywhere on macOS, which is good. But why? For example, in forms in Safari, I can use ctl-a, ctl-k, etc... I can use them in Note.app, too.

My guess is they are actually Unix commands and emacs borrowed them?

0

3 Answers 3

10

I can use emacs commands everywhere on macOS, which is good. But why?

Normally, asking “Why Apple does this, that, or the other thing” would be considered off topic, however, this one actually has an answer based in history.

The short answer to this is because the Emacs keybindings support is implemented in the Cocoa Text System.

My guess is they are actually Unix commands and emacs borrowed them?

They are not, however, Unix commands, because already pointed out in another answer, they are not found in the Unix specification. Also, they are not “universal” and cannot be used everywhere. They can only be used where the application(s) make use of the Cocoa Text System. For example, they cannot be used in Microsoft Word.

So, what does Cocoa have to do with anything? Well, Cocoa is derived from OpenStep which was a project developed by NeXT and Sun Microsystems to provide a NeXTSTEP like environment to non-NeXTSTEP operating systems. NeXT produced an OpenStep variation for its own Mach-based Unix.

Now remember, the macOS Unix kernel is Mach-based.

So, how did Apple get its hands on Mach and OpenStep? Well, on February 7, 1997 Apple acquired NeXT (along with Steve Jobs). The derivative products from that purchase was, you guessed it, macOS based on the Mach kernel, OpenStep, and all the other goodies NeXT had in their portfolio.

So, why did Apple bring over all those keybindings as they developed Cocoa? It only made sense for Apple bring over an environment developers (lots and lots of them from the Unix-verse) were already familiar with. Cocoa, derived from OpenStep, implemented the Emacs functionality already built into OpenStep.

2
  • What is onestep? Do you mean openstep?
    – mmmmmm
    Commented Dec 29, 2019 at 22:29
  • @user151019 - Thanks. Somehow I got OneStep on the brain. All fixed.
    – Allan
    Commented Dec 29, 2019 at 22:34
1

Your guess is not really correct, no. These "commands" (or keyboard shortcuts) are not Unix-commands. The Unix specification does not say anything about system wide text editing short cuts or similar, so you cannot really say that it is borrowed from there.

I doubt that the answer from @ankii is correct either. It doesn't make sense that "for consistent design" you would have two different short cuts for each of many operations (such as for example Ctrl-A you mentioned having the probably more Mac-ish shortcut Cmd-LeftArrow).

Another thought could be that emacs actually borrowed these short cuts from macOS. This is not the case either. Emacs originated in 1976, while the first Macintosh System Software release is from 1984.

The most logical explanation would be that some or many macOS system programmers from an early time were users of editors with command short cuts similar to emacs (which would include emacs itself), or that a large enough subset of initial customers were such users - so they added on these extra short cuts for everyone to feel at home.

In fact some of these short cuts date back quite a lot. As far as I know, they originate with the "computer terminals" that were the way many large computer systems were accessed in the 1970s. In rough terms, terminals are the evolutionary step after "line printers" as the main interface, and before "bitmap displays" (computer monitors).

For example the popular VT100 series of virtual terminals (circa 1978) came with similar short cuts. For example similar to Control-K in macOS, Escape-K deleted to the end of line. Note that in those days, the ESC-key was not located on the keyboard where it is today.

11
  • hcs.harvard.edu/~jrus/Site/cocoa-text.html, as outdated as it partially is, has more about the similarity of macOS key bindings and Emacs.
    – nohillside
    Commented Dec 27, 2019 at 22:47
  • 1
    Emacs was the preferred editor for most early Apple engineers as opposed to vi hence the convention being established In cocoa SDK shortcuts. Both these editors predate Apple. Using the common libraries and having them rich and consistent is the defining characteristics of macOS imo.
    – bmike
    Commented Dec 27, 2019 at 22:48
  • I don't know if you could really say that they predate Apple - I would say they are contemporaries. Apple was founded in April 1976, whereas vi was first a thing later that year. Similarly the first editor called EMACS is from late 1976. As I already wrote in my answer, they definitely predate the Macintosh OS.
    – jksoegaard
    Commented Dec 27, 2019 at 22:59
  • I meant " consistent design" to imply consumer satisfaction and ease of use. This is possible on both Apple and Emacs' end. " ... it should not redefine the key to do something else as it would potentially confuse users." wiki
    – anki
    Commented Dec 28, 2019 at 6:14
  • 1
    Also the emacs bindings solved a problem for "which key sequences to use in a non-model editing environment" early enough to become a semi-standard. I believe for browsers it came from Netscape which for the Unix version was coded by jwz who is an expert Emacs programmer (his work became XEmacs) Commented Dec 29, 2019 at 12:42
0

One can see most of the shortcuts on macOS at https://support.apple.com/en-us/HT201236 and https://en.wikipedia.org/wiki/Table_of_keyboard_shortcuts

As for why you can use them in emacs, it could be for consistent design, like the four or five tabs in so many iOS apps.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .