Created
February 1, 2019 17:46
-
-
Save junjizhi/5f00a0d7d0f4d271e00ba2c4dba74a88 to your computer and use it in GitHub Desktop.
Emacs: copy word without selection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun jz/copy-word | |
(&optional | |
arg | |
) | |
"Copy words at point into kill-ring. | |
Adapted from https://www.emacswiki.org/emacs/CopyWithoutSelection#toc4 | |
The original implementation doesn't work if the cursor is at the beginning of current word. It copies one word back instead. | |
With this tweak, this function works in that case, but won't work if the current cursor is at the end of current word. | |
But it's good enough for my use case because I use ace jump a lot so my cursor usually lands at the first char of the word. | |
" | |
(interactive "P") | |
(copy-thing 'forward-word 'backward-word arg) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment