Last active
March 14, 2019 12:28
-
-
Save blue0513/2775a527c9963368d7b3ed7a45203073 to your computer and use it in GitHub Desktop.
copy the region or thing-at-point
This file contains 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 my-smart-copy () | |
"If the region is selected, copy the region. If not, copy thing-at-point." | |
(interactive) | |
(cond | |
((region-active-p) | |
(progn | |
(copy-region-as-kill (region-beginning) (region-end)) | |
(message "region copied!"))) | |
((thing-at-point 'symbol) | |
(progn | |
(kill-new (thing-at-point 'symbol)) | |
(message "copied!: %s" (thing-at-point 'symbol)))) | |
(t | |
(message "No symbol or region selected")))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment