Skip to content

Commit

Permalink
Fix C-w in ido-read-directory-name
Browse files Browse the repository at this point in the history
  • Loading branch information
magnars committed Jul 18, 2013
1 parent 5934da0 commit f34be46
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
38 changes: 21 additions & 17 deletions setup-ido.el
Expand Up @@ -12,7 +12,6 @@

;; Try out flx-ido for better flex matching between words
(require 'flx-ido)
(ido-everywhere 1)
(flx-ido-mode 1)
;; disable ido faces to see flx highlights.
(setq ido-use-faces nil)
Expand All @@ -27,23 +26,28 @@
(define-key ido-completion-map (kbd "C-p") 'ido-prev-match)
(define-key ido-completion-map (kbd "<up>") 'ido-prev-match))

(add-hook
'ido-setup-hook
(lambda ()
;; Go straight home
(define-key ido-file-completion-map
(kbd "~")
(lambda ()
(interactive)
(cond
((looking-back "~/") (insert "projects/"))
((looking-back "/") (insert "~/"))
(:else (call-interactively 'self-insert-command)))))
(require 'dash)

;; Use C-w to go back up a dir to better match normal usage of C-w
;; - insert current file name with C-x C-w instead.
(define-key ido-file-completion-map (kbd "C-w") 'ido-delete-backward-updir)
(define-key ido-file-completion-map (kbd "C-x C-w") 'ido-copy-current-file-name)))
(defun my/setup-ido ()
;; Go straight home
(define-key ido-file-completion-map
(kbd "~")
(lambda ()
(interactive)
(cond
((looking-back "~/") (insert "projects/"))
((looking-back "/") (insert "~/"))
(:else (call-interactively 'self-insert-command)))))

;; Use C-w to go back up a dir to better match normal usage of C-w
;; - insert current file name with C-x C-w instead.
(define-key ido-file-completion-map (kbd "C-w") 'ido-delete-backward-updir)
(define-key ido-file-completion-map (kbd "C-x C-w") 'ido-copy-current-file-name)

(define-key ido-file-dir-completion-map (kbd "C-w") 'ido-delete-backward-updir)
(define-key ido-file-dir-completion-map (kbd "C-x C-w") 'ido-copy-current-file-name))

(add-hook 'ido-setup-hook 'my/setup-ido)

;; Always rescan buffer for imenu
(set-default 'imenu-auto-rescan t)
Expand Down
8 changes: 4 additions & 4 deletions setup-rgrep.el
Expand Up @@ -13,8 +13,8 @@
(error "grep.el: No `grep-find-template' available"))
(t (let* ((regexp (grep-read-regexp))
(files (grep-read-files regexp))
(dir (read-directory-name "Base directory: "
nil default-directory t))
(dir (ido-read-directory-name "Base directory: "
nil default-directory t))
(confirm (equal current-prefix-arg '(4))))
(list regexp files dir confirm))))))
(window-configuration-to-register ?$)
Expand Down Expand Up @@ -43,8 +43,8 @@
(let* ((regexp (grep-read-regexp))
(files (grep-read-files regexp))
(files (if (string= "* .*" files) "*" files))
(dir (read-directory-name "Base directory: "
nil default-directory t))
(dir (ido-read-directory-name "Base directory: "
nil default-directory t))
(confirm (equal current-prefix-arg '(4))))
(list regexp files dir confirm)))
(let ((command (format "cd %s && git --no-pager grep %s %s -e %S -- '%s' "
Expand Down

0 comments on commit f34be46

Please sign in to comment.