Created
August 22, 2012 17:59
-
-
Save nmurthy/3427972 to your computer and use it in GitHub Desktop.
jump to dirs in ido
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; add this shiz to your .emacs to enable jumping to different directories while ido-finding with C-t | |
(add-hook 'ido-setup-hook 'ido-my-keys) | |
(defun ido-completing-read-horiz (prompt choices &optional _predicate require-match | |
initial-input hist def _inherit-input-method) | |
"do ido-completing-read, but horizontally" | |
(let ((old-decorations ido-decorations) | |
(res "")) | |
(setq ido-decorations '( "{" "}" " | " " | ..." "[" "]" " [No match]" " [Matched]" " [Not readable]" " [Too big]" " [Confirm]")) | |
(setq res (ido-completing-read prompt choices _predicate require-match initial-input hist def _inherit-input-method)) | |
(setq ido-decorations old-decorations) | |
(identity res))) | |
(defun my-ido-search-directories () | |
"Search directory list to jump to one quickly" | |
(interactive) | |
(let* ((enable-recursive-minibuffers t) | |
(dirlist (remove-if (lambda (x) (string= "" x)) (split-string ido-current-directory "/"))) | |
(chosen (ido-completing-read-horiz (concat "Choose dir (" (mapconcat 'identity dirlist ",") "): ") dirlist)) | |
(chosen-dir-start-idx (string-match chosen ido-current-directory)) | |
(chosen-dir-end-idx (match-end 0)) | |
(chosen-dir (substring ido-current-directory 0 chosen-dir-end-idx))) | |
(when chosen-dir | |
(ido-set-current-directory chosen-dir) | |
(setq ido-exit 'refresh) | |
(exit-minibuffer)))) | |
(defun ido-my-keys () | |
"Add my keybindings for ido." | |
(define-key ido-completion-map "\C-t" 'my-ido-search-directories)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment