From 9f75a65398b4a4e1edc06e8acb4834398e9e5f11 Mon Sep 17 00:00:00 2001 From: Ivan Yonchovski Date: Thu, 16 Apr 2020 14:45:46 +0300 Subject: [PATCH] [defaults] Add function+shortcut for copy buffer name --- CHANGELOG.develop | 1 + layers/+spacemacs/spacemacs-defaults/funcs.el | 6 ++++++ layers/+spacemacs/spacemacs-defaults/keybindings.el | 3 ++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.develop b/CHANGELOG.develop index 4229c7ed3..d5e225ecc 100644 --- a/CHANGELOG.develop +++ b/CHANGELOG.develop @@ -862,6 +862,7 @@ Other: root with line number - ~SPC f y Y~ to show and copy current file path relative to the project root + - ~SPC f y b~ to show and copy buffer name. (thanks to Codruț Constantin Gușoi) - New ~SPC f e e~ to open spacemacs.env file (thanks to Sylvain Benner) - New ~SPC f e E~ to reload environment variable from env file diff --git a/layers/+spacemacs/spacemacs-defaults/funcs.el b/layers/+spacemacs/spacemacs-defaults/funcs.el index 3124229e9..054e7a2d7 100644 --- a/layers/+spacemacs/spacemacs-defaults/funcs.el +++ b/layers/+spacemacs/spacemacs-defaults/funcs.el @@ -690,6 +690,12 @@ ones created by `magit' and `dired'." (message "%s" file-name)) (message "WARNING: Current buffer is not attached to a file!"))) +(defun spacemacs/copy-buffer-name () + "Copy and show the name of the current buffer." + (interactive) + (kill-new (buffer-name)) + (message "%s" (buffer-name))) + (defun spacemacs/copy-file-name-base () "Copy and show the file name without its final extension of the current buffer." diff --git a/layers/+spacemacs/spacemacs-defaults/keybindings.el b/layers/+spacemacs/spacemacs-defaults/keybindings.el index eff11e212..f8fcad63f 100644 --- a/layers/+spacemacs/spacemacs-defaults/keybindings.el +++ b/layers/+spacemacs/spacemacs-defaults/keybindings.el @@ -373,7 +373,8 @@ ("l" spacemacs/copy-file-path-with-line "File path with line number") ("n" spacemacs/copy-file-name "File name") ("N" spacemacs/copy-file-name-base "File name without extension") - ("y" spacemacs/copy-file-path "File path"))))) + ("y" spacemacs/copy-file-path "File path") + ("b" spacemacs/copy-buffer-name "Buffer name"))))) ;; frame ---------------------------------------------------------------------- (spacemacs/set-leader-keys "Ff" 'spacemacs/find-file-other-frame