Skip to content

Instantly share code, notes, and snippets.

@blue0513
Last active March 14, 2019 12:28
Show Gist options
  • Save blue0513/2775a527c9963368d7b3ed7a45203073 to your computer and use it in GitHub Desktop.
Save blue0513/2775a527c9963368d7b3ed7a45203073 to your computer and use it in GitHub Desktop.
copy the region or thing-at-point
(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