From 1b43ea50f07ef7e4f96abf648c1c189a5278ad21 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 26 Feb 2019 13:21:16 -0500 Subject: [PATCH] Revise SPC f keybinds - SPC f . -> counsel-file-jump or find-file - SPC f > -> doom/browse-in-other-projects - SPC f / -> projectile-find-file - SPC f ? -> doom/find-file-in-other-project - Moved doom/sudo-find-file to SPC f S This change was made to accommodate the new doom/browse-in-other-projects and doom/find-file-in-other-project commands, which make it easy to jump to files in other known projects. --- core/autoload/projects.el | 22 ++++++++++++++++++++++ modules/config/default/+evil-bindings.el | 7 ++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/core/autoload/projects.el b/core/autoload/projects.el index bc1c911b0..9d5e76848 100644 --- a/core/autoload/projects.el +++ b/core/autoload/projects.el @@ -33,6 +33,28 @@ they are absolute." (dolist (fn projectile-project-root-files-functions) (remhash (format "%s-%s" fn default-directory) projectile-project-root-cache))) +;;;###autoload +(defun doom/find-file-in-other-project (project-root) + "Preforms `projectile-find-file' in a known project of your choosing." + (interactive + (list + (completing-read "Find file in project: " (projectile-relevant-known-projects) + nil nil nil nil (doom-project-root)))) + (unless (file-directory-p project-root) + (error "Project directory '%s' doesn't exist" project-root)) + (doom-project-find-file project-root)) + +;;;###autoload +(defun doom/browse-in-other-project (project-root) + "Preforms `find-file' in a known project of your choosing." + (interactive + (list + (completing-read "Browse in project: " (projectile-relevant-known-projects) + nil nil nil nil (doom-project-root)))) + (unless (file-directory-p project-root) + (error "Project directory '%s' doesn't exist" project-root)) + (doom-project-browse project-root)) + ;; ;; Library diff --git a/modules/config/default/+evil-bindings.el b/modules/config/default/+evil-bindings.el index ab3de041b..35b3f8afe 100644 --- a/modules/config/default/+evil-bindings.el +++ b/modules/config/default/+evil-bindings.el @@ -609,10 +609,10 @@ :desc "List errors" "x" #'flycheck-list-errors) (:prefix ("f" . "file") - :desc "Find file" "." #'find-file + :desc "Find file from here" "." (if (fboundp 'counsel-file-jump) #'counsel-file-jump #'find-file) + :desc "Find file in other project" ">" #'doom/browse-in-other-project :desc "Find file in project" "/" #'projectile-find-file - :desc "Sudo find file" ">" #'doom/sudo-find-file - :desc "Find file from here" "?" #'counsel-file-jump + :desc "Find file in other project" "?" #'doom/find-file-in-other-project :desc "Browse emacs.d" "E" #'+default/browse-emacsd :desc "Browse private config" "P" #'+default/browse-config :desc "Recent project files" "R" #'projectile-recentf @@ -624,6 +624,7 @@ :desc "Find file in private config" "p" #'+default/find-in-config :desc "Recent files" "r" #'recentf-open-files :desc "Save file" "s" #'save-buffer + :desc "Sudo find file" "S" #'doom/sudo-find-file :desc "Yank filename" "y" #'+default/yank-buffer-filename) (:prefix ("g" . "git")