forked from magnars/.emacs.d
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsetup-ido.el
74 lines (66 loc) · 2.38 KB
/
setup-ido.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
;; Interactively Do Things
(require 'ido)
(ido-mode t)
(setq ido-enable-prefix nil
ido-enable-flex-matching t
ido-create-new-buffer 'always
ido-use-filename-at-point nil
ido-max-prospects 10)
;; Always rescan buffer for imenu
(set-default 'imenu-auto-rescan t)
(add-to-list 'ido-ignore-directories ".svn")
(add-to-list 'ido-ignore-directories ".git")
(add-to-list 'ido-ignore-directories "target")
(add-to-list 'ido-ignore-directories "node_modules")
(defun recentf-open-files-compl ()
(interactive)
(let* ((tocpl (mapcar (lambda (x) (cons (file-name-nondirectory x) x))
recentf-list))
(fname (completing-read "File name: " tocpl nil nil)))
(when fname
(find-file (cdr (assoc-string fname tocpl))))))
(defun recentf-ido-find-file ()
"Find a recent file using Ido."
(interactive)
(let* ((file-assoc-list
(mapcar (lambda (x)
(cons (file-name-nondirectory x)
x))
recentf-list))
(filename-list
(remove-duplicates (mapcar #'car file-assoc-list)
:test #'string=))
(filename (ido-completing-read "Choose recent file: "
filename-list
nil
t)))
(when filename
(find-file (cdr (assoc filename
file-assoc-list))))))
;;; ~ goes to homedir - don't like.
(when nil
(add-hook 'ido-setup-hook
(lambda ()
;; Go straight home
(define-key ido-file-completion-map
(kbd "~")
(lambda ()
(interactive)
(if (looking-back "/")
(insert "~/")
(call-interactively 'self-insert-command)))))))
;; Use ido everywhere - causes problems for my f6 iswitchb
(when (< (emacs-version-major) 27)
(require 'ido-ubiquitous)
;;(ido-ubiquitous-mode 0)
;; Fix ido-ubiquitous for newer packages
(defmacro ido-ubiquitous-use-new-completing-read (cmd package)
`(eval-after-load ,package
'(defadvice ,cmd (around ido-ubiquitous-new activate)
(let ((ido-ubiquitous-enable-compatibility nil))
ad-do-it))))
)
;;(ido-ubiquitous-use-new-completing-read webjump 'webjump)
;;(ido-ubiquitous-use-new-completing-read yas/expand 'yasnippet)
;;(ido-ubiquitous-use-new-completing-read yas/visit-snippet-file 'yasnippet)
(provide 'setup-ido)