Created
December 1, 2013 08:15
-
-
Save keimina/7729789 to your computer and use it in GitHub Desktop.
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
(eval-after-load 'dired | |
'(progn | |
(define-key dired-mode-map (kbd "c") 'my-dired-create-file) | |
(defun create-new-file (file-list) | |
(defun exsitp-untitled-x (file-list cnt) | |
(while (and (car file-list) (not (string= (car file-list) (concat "untitled" (number-to-string cnt) ".txt")))) | |
(setq file-list (cdr file-list))) | |
(car file-list)) | |
(defun exsitp-untitled (file-list) | |
(while (and (car file-list) (not (string= (car file-list) "untitled.txt"))) | |
(setq file-list (cdr file-list))) | |
(car file-list)) | |
(if (not (exsitp-untitled file-list)) | |
"untitled.txt" | |
(let ((cnt 2)) | |
(while (exsitp-untitled-x file-list cnt) | |
(setq cnt (1+ cnt))) | |
(concat "untitled" (number-to-string cnt) ".txt") | |
) | |
) | |
) | |
(defun my-dired-create-file (file) | |
(interactive | |
(list (read-file-name "Create file: " (concat (dired-current-directory) (create-new-file (directory-files (dired-current-directory)))))) | |
) | |
(write-region "" nil (expand-file-name file) t) | |
(dired-add-file file) | |
(revert-buffer) | |
(dired-goto-file (expand-file-name file)) | |
) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment