diff --git a/.emacs.d/init.el b/.emacs.d/init.el index f418d19..38c6f9b 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -236,12 +236,43 @@ ("C-r" . swiper) ("C-c C-r" . ivy-resume) :map swiper-map ("C-r" . ivy-previous-line-or-history) - :map ivy-minibuffer-map ("C-'" . ivy-avy)) + :map ivy-minibuffer-map ("C-'" . ivy-avy) + :map counsel-find-file-map ("C-M-i" . counsel-find-file-edit-path)) :init (bind-key "C-S-s" 'isearch-forward) (bind-key "C-S-r" 'isearch-backward) :config - (ivy-mode 1)) + (ivy-mode 1) + (defun ivy-backward-delete-char () + "Forward to `backward-delete-char'. + Do less dumb things with directories + On error (read-only), call `ivy-on-del-error-function'." + (interactive) + (if (and ivy--directory (= (minibuffer-prompt-end) (point))) + (progn + (let ((old-dir (file-name-nondirectory + (directory-file-name + (expand-file-name + ivy--directory))))) + (ivy--cd (file-name-directory + (directory-file-name + (expand-file-name + ivy--directory)))) + (insert old-dir)) + (ivy--exhibit)) + (condition-case nil + (backward-delete-char 1) + (error + (when ivy-on-del-error-function + (funcall ivy-on-del-error-function)))))) + + (defun counsel-find-file-edit-path () + "Edit the current path in ivy find-file" + (interactive) + (let ((old-path + (substring (concat (expand-file-name ivy--directory) ivy-text) 1 -1))) + (ivy--cd "/") + (insert old-path)))) (use-package ivy-hydra :ensure)