From 46bea60ad3b1137a9597a7badaad8e9d574bdbdd Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 15 Nov 2019 14:26:09 -0500 Subject: [PATCH] Add :Read ex command & 'SPC i p' keybind This can be used to extract paths from evil-ex style paths. e.g. the following inserts the stdout into the current buffer (assuming we're in ~/some/project/filename.c): :R!echo %:P ~/some/project :R!echo %:t filename.c :R!echo %:e c :R!echo %:r filename :R!echo ~/another/project/%:t:r.h ~/another/project/filename.h :R % contents of current file http://vimdoc.sourceforge.net/htmldoc/cmdline.html#filename-modifiers has a full list of vim filename modifiers. Doom doesn't support all of them, but it does support most of them. --- modules/config/default/+evil-bindings.el | 5 +++-- modules/editor/evil/+commands.el | 1 + modules/editor/evil/autoload/ex.el | 6 ++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/config/default/+evil-bindings.el b/modules/config/default/+evil-bindings.el index e63d2ce0c..069b4427d 100644 --- a/modules/config/default/+evil-bindings.el +++ b/modules/config/default/+evil-bindings.el @@ -468,10 +468,11 @@ ;;; i --- insert (:prefix-map ("i" . "insert") - :desc "From clipboard" "y" #'+default/yank-pop + :desc "Evil ex path" "p" (λ! (evil-ex "R!echo ")) :desc "From evil register" "r" #'evil-ex-registers :desc "Snippet" "s" #'yas-insert-snippet - :desc "Unicode" "u" #'unicode-chars-list-chars) + :desc "Unicode" "u" #'unicode-chars-list-chars + :desc "From clipboard" "y" #'+default/yank-pop) ;;; n --- notes (:prefix-map ("n" . "notes") diff --git a/modules/editor/evil/+commands.el b/modules/editor/evil/+commands.el index 8859ebac9..c1a61fc52 100644 --- a/modules/editor/evil/+commands.el +++ b/modules/editor/evil/+commands.el @@ -4,6 +4,7 @@ ;;; Custom commands ;; Editing (evil-ex-define-cmd "@" #'+evil:macro-on-all-lines) ; TODO Test me +(evil-ex-define-cmd "R[ead]" #'+evil:read) (evil-ex-define-cmd "al[ign]" #'+evil:align) (evil-ex-define-cmd "ral[ign]" #'+evil:align-right) (evil-ex-define-cmd "enhtml" #'+web:encode-html-entities) diff --git a/modules/editor/evil/autoload/ex.el b/modules/editor/evil/autoload/ex.el index 159af43a2..6ad458106 100644 --- a/modules/editor/evil/autoload/ex.el +++ b/modules/editor/evil/autoload/ex.el @@ -182,3 +182,9 @@ non-nil, a search is preformed against Doom's manual (wiht `doom/help-search')." (evil-ex-completed-binding (match-string 1 query)))) ((message "Searching for %S, this may take a while..." query) (apropos query t)))))) + +;;;###autoload (autoload '+evil:read "editor/evil/autoload/ex" nil t) +(evil-define-command +evil:read (count file) + "Alternative version of `evil-read' that replaces filename modifiers in FILE." + (interactive "P") + (evil-read count (evil-ex-replace-special-filenames file)))