- .emacs 파일에 다음과 같이 함수를 정의한다.
(defun delete-this-buffer-and-file ()
"Removes file connected to current buffer and kills buffer."
(interactive)
(let ((filename (buffer-file-name))
(buffer (current-buffer))
(name (buffer-name)))
(if (not (and filename (file-exists-p filename)))
(error "Buffer '%s' is not visiting a file!" name)
(when (yes-or-no-p "Are you sure you want to remove this file? ")
(delete-file filename)
(kill-buffer buffer)
(message "File '%s' successfully removed" filename)))))
- 위 함수에 키를 바인딩한다.(C-c k)
(global-set-key (kbd "C-c k") 'delete-this-buffer-and-file)
<테스트 환경>
OS : Windows 7
Emacs 버전 : Emacs 24.3 윈도우