Skip to content

Instantly share code, notes, and snippets.

@tangrammer
Forked from kristianhellquist/custom.el
Last active July 25, 2017 08:30
Show Gist options
  • Save tangrammer/ca3e00007d560b6721818bfe385b5b98 to your computer and use it in GitHub Desktop.
Save tangrammer/ca3e00007d560b6721818bfe385b5b98 to your computer and use it in GitHub Desktop.
Emacs, copy current file and line number to clipboard
(defun copy-current-line-position-to-clipboard ()
"Copy current line in file to clipboard as '</path/to/file>:<line-number>'"
(interactive)
(let ((path-with-line-number
(concat (buffer-file-name) "::" (number-to-string (line-number-at-pos)))))
(when path-with-line-number
(with-temp-buffer
(insert path-with-line-number)
(clipboard-kill-region (point-min) (point-max)))
(message (concat path-with-line-number " copied to clipboard")))))
@tangrammer
Copy link
Author

Adapted to my emacs os version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment