Skip to content

Instantly share code, notes, and snippets.

@Compro-Prasad
Forked from pavloo/current-position.el
Created August 20, 2018 14:00
Show Gist options
  • Save Compro-Prasad/c066908b547c835b23aad9e6c97a3ee2 to your computer and use it in GitHub Desktop.
Save Compro-Prasad/c066908b547c835b23aad9e6c97a3ee2 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