Skip to content

Instantly share code, notes, and snippets.

@pavloo
Created August 20, 2018 13:31
Show Gist options
  • Save pavloo/a494fdb49c24f58f88e0e5a44bccd259 to your computer and use it in GitHub Desktop.
Save pavloo/a494fdb49c24f58f88e0e5a44bccd259 to your computer and use it in GitHub Desktop.
(defun copy-current-line-position-to-clipboard (p)
"Copy current line in file to clipboard as '</path/to/file>:<line-number>'"
(interactive "sAbsolute path y/n?: ")
(let ((path-with-line-number) (file-name (buffer-file-name)))
(when (and (not (string= p "y")) (projectile-project-root))
(setq file-name (file-relative-name buffer-file-name (projectile-project-root)))
)
(setq path-with-line-number (concat file-name ":" (number-to-string (line-number-at-pos))))
(x-select-text path-with-line-number)
(message (concat path-with-line-number " copied to clipboard"))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment