Last active
December 21, 2015 16:29
-
-
Save tam17aki/6334064 to your computer and use it in GitHub Desktop.
Find a recent file and a directory using Ido.File names and directory names are searched with basename and dirname, respectively.
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
(require 'recentf) | |
(defun recentf-ido-find-files-and-dirs (arg) | |
"Find a recent file and a directory using Ido." | |
(interactive "P") | |
(let* ((show-full-path-p (cond (arg t) (t nil))) | |
(file-assoc-list ;表示する候補名とフルパス | |
(mapcar (lambda (x) | |
(cond ((equal (substring x (- (length x) 1) (length x)) "/") ;末尾がスラッシュ | |
(cons (file-name-directory x) x)) | |
(t | |
(cond (show-full-path-p | |
(cons x x)) | |
(t | |
(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 or directory: " | |
filename-list nil t))) | |
(when filename | |
(find-file (cdr (assoc filename file-assoc-list)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment