Refactor/optimize completion/ido module
Ensure initialization only occurs once when ido is first used. Special steps are needed because ido is automatically loaded at startup by Emacs.
This commit is contained in:
parent
3d893ea53e
commit
83590d65ba
1 changed files with 25 additions and 31 deletions
|
@ -1,7 +1,6 @@
|
|||
;;; completion/ido/config.el -*- lexical-binding: t; -*-
|
||||
|
||||
(def-package! ido
|
||||
:config
|
||||
(defun +ido|init ()
|
||||
(setq ido-ignore-buffers
|
||||
'("\\` " "^\\*ESS\\*" "^\\*Messages\\*" "^\\*Help\\*" "^\\*Buffer"
|
||||
"^\\*.*Completions\\*$" "^\\*Ediff" "^\\*tramp" "^\\*cvs-"
|
||||
|
@ -16,29 +15,18 @@
|
|||
ido-enable-last-directory-history t
|
||||
ido-save-directory-list-file (concat doom-cache-dir "ido.last"))
|
||||
|
||||
(push "\\`.DS_Store$" ido-ignore-files)
|
||||
(push "Icon\\?$" ido-ignore-files)
|
||||
(unless (member "\\`.DS_Store$" ido-ignore-files)
|
||||
(push "\\`.DS_Store$" ido-ignore-files)
|
||||
(push "Icon\\?$" ido-ignore-files))
|
||||
|
||||
(ido-mode 1)
|
||||
(ido-everywhere 1)
|
||||
(require 'ido-completing-read+)
|
||||
(ido-ubiquitous-mode 1)
|
||||
|
||||
(defun +ido|init ()
|
||||
(require 'ido-vertical-mode)
|
||||
(ido-vertical-mode 1)
|
||||
|
||||
(require 'flx-ido)
|
||||
(flx-ido-mode +1)
|
||||
|
||||
(require 'crm-custom)
|
||||
(crm-custom-mode +1)
|
||||
|
||||
(map! :map (ido-common-completion-map ido-completion-map ido-file-completion-map)
|
||||
"C-n" #'ido-next-match
|
||||
"C-p" #'ido-prev-match
|
||||
"C-w" #'ido-delete-backward-word-updir))
|
||||
(add-hook 'ido-setup-hook #'+ido|init)
|
||||
(define-key! (ido-common-completion-map ido-completion-map ido-file-completion-map)
|
||||
"\C-n" #'ido-next-match
|
||||
"\C-p" #'ido-prev-match
|
||||
"\C-w" #'ido-delete-backward-word-updir
|
||||
;; Go to $HOME with ~
|
||||
"~" (λ! (if (looking-back "/" (point-min))
|
||||
(insert "~/")
|
||||
(call-interactively #'self-insert-command))))
|
||||
|
||||
(defun +ido*sort-mtime ()
|
||||
"Sort ido filelist by mtime instead of alphabetically."
|
||||
|
@ -55,10 +43,16 @@
|
|||
(advice-add #'ido-sort-mtime :override #'+ido*sort-mtime)
|
||||
(add-hook! (ido-make-file-list ido-make-dir-list) #'+ido*sort-mtime)
|
||||
|
||||
(defun +ido|setup-home-keybind ()
|
||||
"Go to $HOME with ~"
|
||||
(define-key ido-file-completion-map (kbd "~")
|
||||
(λ! (if (looking-back "/" (point-min))
|
||||
(insert "~/")
|
||||
(call-interactively #'self-insert-command)))))
|
||||
(add-hook 'ido-setup-hook #'+ido|setup-home-keybind))
|
||||
;;
|
||||
(ido-mode 1)
|
||||
(ido-everywhere 1)
|
||||
(ido-ubiquitous-mode 1)
|
||||
(ido-vertical-mode 1)
|
||||
(flx-ido-mode +1)
|
||||
(crm-custom-mode +1)
|
||||
|
||||
;;
|
||||
(remove-hook 'ido-setup-hook #'+ido|init))
|
||||
|
||||
;;
|
||||
(add-hook 'ido-setup-hook #'+ido|init)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue