Created
December 8, 2009 20:59
-
-
Save mwilliams/251994 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| ;;; DELETE CURRENT FILE | |
| ;;; Bound to C-k | |
| (defun ido-delete-file-at-head () | |
| "Delete the file at the head of `ido-matches'. | |
| If cursor is not at the end of the user input, delete to end of input." | |
| (interactive) | |
| (if (not (eobp)) | |
| (delete-region (point) (line-end-position)) | |
| (let ((enable-recursive-minibuffers t) | |
| (file (ido-name (car ido-matches)))) | |
| (if file | |
| (setq file (concat ido-current-directory file))) | |
| (when (and file | |
| (file-exists-p file) | |
| (not (file-directory-p file)) | |
| (file-writable-p ido-current-directory) | |
| (yes-or-no-p (concat "Delete " file "? "))) | |
| (delete-file file) | |
| ;; Check if file still exists. | |
| (if (file-exists-p file) | |
| ;; file could not be deleted | |
| (setq ido-rescan t) | |
| ;; else file was killed so remove name from list. | |
| (setq ido-cur-list (delq (car ido-matches) ido-cur-list))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment