Skip to content

Instantly share code, notes, and snippets.

@junjizhi
Created February 1, 2019 17:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save junjizhi/5f00a0d7d0f4d271e00ba2c4dba74a88 to your computer and use it in GitHub Desktop.
Save junjizhi/5f00a0d7d0f4d271e00ba2c4dba74a88 to your computer and use it in GitHub Desktop.
Emacs: copy word without selection
(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