From 8b7eea63977edb28882ea8e321ff4e7b3e600e3c Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Tue, 23 Jun 2015 17:38:16 -0400 Subject: [PATCH] functions for copying filenames into kill ring. --- dotfiles/emacs.d/init.el | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/dotfiles/emacs.d/init.el b/dotfiles/emacs.d/init.el index 8b056394..0cd83315 100644 --- a/dotfiles/emacs.d/init.el +++ b/dotfiles/emacs.d/init.el @@ -249,6 +249,24 @@ buffer is not visiting a file." (defun make-frame-if-none-exists-and-focus () (make-frame-visible (select-frame (make-frame-if-none-exists)))) +(defun copy-buffer-file-name () + (interactive) + (add-string-to-kill-ring (file-name-nondirectory (buffer-file-name)))) + +(defun copy-buffer-file-path () + (interactive) + (add-string-to-kill-ring (file-relative-name (buffer-file-name) (projectile-project-root)))) + +(defun add-string-to-kill-ring (string) + (with-temp-buffer + (insert string) + (kill-ring-save (point-max) (point-min)))) + +(defun os-copy-string (string) + (with-temp-buffer + (insert string) + (os-copy (beginning-of-buffer) (end-of-buffer)))) + (defun os-copy (&optional b e) (interactive "r") (shell-command-on-region b e "source ~/.zshrc; cat | smart_copy"))