doomemacs/core/defuns/defuns-ido.el

61 lines
1.8 KiB
EmacsLisp
Raw Normal View History

2015-06-15 09:05:52 +02:00
;;; defuns-ido.el
;;;###autoload
2016-05-20 22:37:30 -04:00
(defun doom*ido-sort-mtime ()
2015-06-15 09:05:52 +02:00
"Sort ido filelist by mtime instead of alphabetically."
(setq ido-temp-list
(sort ido-temp-list
(lambda (a b)
(ignore-errors
(time-less-p
(sixth (file-attributes (concat ido-current-directory b)))
(sixth (file-attributes (concat ido-current-directory a))))))))
2015-06-15 09:05:52 +02:00
(ido-to-end ;; move . files to end (again)
(delq nil (mapcar
(lambda (x) (and (char-equal (string-to-char x) ?.) x))
ido-temp-list))))
;;;###autoload
2016-05-20 22:37:30 -04:00
(defun doom|ido-setup-home-keybind ()
2015-06-15 09:05:52 +02:00
"Go to $HOME with ~"
(define-key ido-file-completion-map (kbd "~")
2015-12-11 22:43:31 -05:00
(λ! (if (looking-back "/")
(insert "~/")
(call-interactively 'self-insert-command)))))
2015-06-15 09:05:52 +02:00
;;;###autoload
2016-05-20 22:37:30 -04:00
(defun doom/ido-find-file (&optional dir)
2015-06-15 09:05:52 +02:00
(interactive)
(let ((default-directory (or dir default-directory)))
(ido-find-file)))
;;;###autoload
2016-05-20 22:37:30 -04:00
(defun doom/ido-find-file-other-window (&optional dir)
2015-06-15 09:05:52 +02:00
(interactive)
(let ((default-directory (or dir default-directory)))
(ido-find-file-other-window)))
;;;###autoload
2016-05-20 22:37:30 -04:00
(defun doom/ido-find-project-file ()
2015-06-15 09:05:52 +02:00
(interactive)
2016-05-20 22:37:30 -04:00
(let ((default-directory (doom/project-root)))
2015-06-15 09:05:52 +02:00
(ido-find-file)))
;;;###autoload
2016-05-20 22:37:30 -04:00
(defun doom/ido-recentf ()
2015-06-15 09:05:52 +02:00
"Use `ido-completing-read' to \\[find-file] a recent file"
(interactive)
(if (find-file (ido-completing-read "Find recent file: " recentf-list))
(message "Opening file...")
(message "Aborting")))
2016-05-20 22:37:30 -04:00
;;;###autoload (autoload 'doom:ido-find-file-in-emacsd "defuns-ido" nil t)
(evil-define-command doom:ido-find-file-in-emacsd (&optional bang) :repeat nil
2015-06-15 09:05:52 +02:00
(interactive "<!>")
(if bang
2016-05-20 22:37:30 -04:00
(ido-find-file-in-dir doom-modules-dir)
(ido-find-file-in-dir doom-emacs-dir)))
2015-06-15 09:05:52 +02:00
(provide 'defuns-ido)
;;; defuns-ido.el ends here