Created
November 1, 2012 07:25
-
-
Save i03nomura1y/3992316 to your computer and use it in GitHub Desktop.
elisp : check vi swap file
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
;; if .file.swp exists : | |
;; set buffer-read-only and ask to user | |
(defun check-vi-swp-file () | |
(let* ((fullpath (file-truename (buffer-file-name))) | |
(dirpath (file-name-directory fullpath) ) | |
(fname (file-name-nondirectory fullpath) ) | |
(swppath (concat dirpath "." fname ".swp") )) | |
(if (file-exists-p swppath) | |
(progn | |
(setq buffer-read-only 't) ; set Read-Only. | |
(if (y-or-n-p "vi swap file exists; really edit the buffer? ") | |
(setq buffer-read-only 'nil) ; set Writable. | |
))))) | |
;; (add-hook 'find-file-hooks 'check-vi-swp-file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment