I want to bind this function to M-w
, so that it copies the region if one is selected, otherwise it copies the whole line silently, without having any other side-effects like moving the cursor to some other places.
I saw some examples, but they all do some additional stuff that I don't like, like moving the cursor to the next line.
I'm not an expert in Elisp, but some functions I saw might be buggy, because their bodies contain "\n"
, to refer to "newline", which is obviously wrong, because not all systems use this convention.
"\n"
internally, no matter how the newline is encoded when it's stored in a file. – Gilles 'SO- stop being evil' Jun 27 '20 at 13:49