
jwz: Apple recently broke Ctrl-Y - michaelty
http://www.jwz.org/blog/2011/12/apple-recently-broke-ctrl-y/
======
prawn
"Update: Holy shit! I am told that this bug was fixed FIVE HOURS after I
posted this -- Webkit bug 73888 [1] and the patch [2]. Thanks, Alexey!"

    
    
      1. https://bugs.webkit.org/show_bug.cgi?id=73888
      2. https://bug-73888-attachments.webkit.org/attachment.cgi?id=117988

------
natesm
HOKAY. So you can totally do this:

> I'm guessing there's no easy way to replace the definition of the
> deleteToEndOfParagraph: action with something else...

with DYLD_INSERT_LIBRARIES and method_exchangeImplementations (and maybe
launchd to apply that DYLD_INSERT_LIBRARIES to everything?).

What you have to do is:

Implement a category message that does what you want
(my_deleteToEndOfParagraph:).

Write a function that uses method_exchangeImplementations to replace
deleteToEndOfParagraph: with my_deleteToEndOfParagraph:.
deleteToEndOfParagraph: probably depends on class (NSTextView, NSTextField,
WebView, etc.)

Create a shared library that uses your function as an initialization routine.

Inject that shared library into every app on the system.

As you can see this is _very easy_. Har har har.

~~~
krakensden
And people complain about Linux wasting your time.

~~~
dextorious
Are you for real?

As if the normal use case is that of a user wanting to change some text
editing bindings back to Emacs-like behavior...

------
feralchimp
Great comments thread on that post, including this gem after WebKit is
fingered as the wrongdoer:

"Two different libraries to implement text-field editing -- because, you know,
that's somewhere you might want to diverge and innovate."

LOL.

~~~
jvdh
Makes a whole lot of sense to me. Text input in a browser should be handled a
lot more carefully than text input to "regular" system applications.

~~~
waitwhat
Why? What is so special about the browser? (or is my sarcasm detector failing
again?)

~~~
dexen
Unlike most desktop apps, browsers interface user directly with the internet,
and it is dangerous out there.

For example, theres' case of stealing text from copy/paste buffer
<http://news.ycombinator.com/item?id=3314004>

~~~
dfxm12
More and more desktop apps are interfacing the users with the Internet though,
especially when you extrapolate Apple's model with their app store.

It is just as dangerous "in here" too...

------
Uhhrrr
I'm always agog when an organization changes something beloved like key
bindings. Qui bono? Someone who uses them is in the same boat as everyone
else, muscle memory-wise. And someone who doesn't shouldn't care. And in
either case, there should be enough people with facial hair (or female
equivalent) who will block it because toying with user expectations is bad.

~~~
telemachos
This is a tangent, but you want 'cui bono'[1]. 'Qui' is the nominative; the
phrase is a double dative. (Not trying to be a jerk, but I figured you might
want to know.)

[1]: <http://en.wikipedia.org/wiki/Cui_bono>

~~~
docgnome
My thanks for this tangential line of thought. I didn't know what was being
referred to.

------
phren0logy
File a bug. This seems like the kind of thing that Apple would actually fix.

<https://bugreport.apple.com/>

~~~
drivingmenuts
Or not.

OS X should be agnostic about the software running on it. If you fix it for
Emacs, then it should also be fixed for vi users and nano users, etc. some of
which are mutually exclusive.

~~~
macrael
The point is that all generic text fields on OSX have supported Emacs
keybindings since forever, not vi or nano keybindings.

~~~
throw_away
though, this thread just makes me want vi bindings in os x text areas. I would
settle for shell bindings that can change the cursor shape.

------
dylangs1030
To clarify this a bit for non-Emacs users (as I saw a comment), the tl;dr
version is that jwz wants Mac to maintain the Emacs key bindings that
essentially amount to a specialized set of copy, cut and paste functions in
text editing.

This is not because Apple particularly sponsors Emacs, but because
historically, Mac key bindings and Emacs key bindings were the same for those
functions. So it's the same (roughly) as finding that Command-A, Command-C and
Command-V no longer work the way they used to.

~~~
Someone
Clarification of this for those interested in history: The original Mac did
not have control keys; I guess NextStep had some Emacs bindings. When Mac OS
and NextStep gave birth to Mac OS X, it was possible to keep both sets, as
there could not be clashes. I am not sure those Emacs bindings 'officially'
exist, though (the human interface guidelines mention the use of the control
key for accessibility, but not for text editing)

------
vault_
You can set per-user shortcuts for this.
<http://www.hcs.harvard.edu/~jrus/site/cocoa-text.html>

I'm unsure if it works in 10.7 though.

~~~
jacobolus
It always brings a smile to see my 2006 page linked. :)

As ever, feedback is welcome.

~~~
afiler
I've used your documentation before, and it's amazingly useful. It's let me
solve keyboard mapping issues in the least hacky way possible, especially when
combined with KeyRemap4MacBook.

------
mdanger
As a non-emacs user: can someone explain what jwz is talking about here?

~~~
spacemanaki
Did you follow his little demo? Let me see if I can explain it. "Killing" in
Emacs-jargon is similar to cutting (ctrl/cmd X). Holding control and pressing
"k" (C-k) deletes the text starting at the cursor (point) up until the end of
the line, and puts that text in a buffer. It can be pasted (yanked) with C-y.
In Emacs, killing multiple times _without_ any other movement between kills
appends each bit of text to the buffer. If you move between kills the buffer
is wiped out, and subsequent kills put the killed text into a clean buffer.

I think he basically wants the kill buffer to be wiped out when you move
between kills. His demo shows that in OSX text fields this is no longer the
case, and at least on my machine running 10.6.something this is true. Emacs of
course still behaves the way he wants.

~~~
dylangs1030
That was actually a great explanation - to clarify a bit, yes, jwz doesn't
have any issue with Emacs. But Mac used to use the same key bindings typical
of Emacs, so jwz is miffed because for people comfortable in that environment,
it's a pain to not be able to use the same shortcut for what amounts to copy,
paste and cut.

------
mhartl
I use ^K all the time, but somehow I didn't remember ^Y from my dalliance with
Emacs a decade ago. And now that I know I want it, I can't have it. Crap.

------
js2
Hmm, I can reproduce this in Safari, but not in TextEdit, nor TextMate, under
10.7.2.

~~~
kickingvegas
As mentioned in the link's comment thread, ^Y is broken for Webkit. I just
tried this in Mail.app and it worked fine.

~~~
bdash
Amusingly enough, Mail’s compose window uses WebKit for the content area.
According to <http://webkit.org/b/73888> the issue is specific to the WebKit2
layer that is currently used only by Safari.

------
xenophanes
you can change the keybindings to do multiple things, not just pick a single
preset command like deleteToEndOfParagraph. not sure how much help that is
though, since what he wants is kind of adding "truncate buffer" (or at least
"setLastCommandFlag") to ALL other commands, rather than actually changing
ctrl-k itself. this is not a problem with the deleteToEndOfParagraph
implementation though, and i don't see how hacking that could help, since he
wants something to happen after hitting arrows keys, typing, etc...

------
sambeau
Just to be clear, these are standard Shell keybindings that Emacs also
uses—not 'Emacs keybindings'.

~~~
drv
Emacs had them first; shells copied them.

------
brudgers
While I can understand the issue the change creates for the author, a nexus
between the emacs interface and Apple's overall user experience philosophy
would appear to be somewhat hard to find.

~~~
kabdib
I nearly got a guy on the MPW Shell team fired -- I was egging him on to add
keyboard macros to MPW (the Macintosh Programmer's Workshop), and he
eventually did. They were powerful enough to emulate at least a top-level
mostly Emacs environment.

Oh, the fur flew. Post-facto, managers piled on and tried to make the feature
more Mac-like. It was fine as it stood. It was amusing to watch.

Also, developers loved it.

~~~
WalterGR
Why would that be (nearly) a firing offense?

~~~
jrockway
Because it makes the story more interesting.

Also, Apple is one strange company. A friend who worked there as a contractor
told me that there were two Perl teams there, working in different buildings.
He organized a lunch so that the two teams could meet each other. After
someone higher up found out, that was the end of his contract. Apparently
there is so much secrecy that even teams working on bullshit HR apps (or the
equivalent) can't even have lunch together.

Apple is a cult. Follow the rules or you go to hell.

