Skip to content

Instantly share code, notes, and snippets.

@yaotti
Created December 22, 2008 14:37
Show Gist options
  • Save yaotti/39003 to your computer and use it in GitHub Desktop.
Save yaotti/39003 to your computer and use it in GitHub Desktop.
;; reopen
;; http://www.bookshelf.jp/soft/meadow_24.html#SEC254
(defun reopen-file ()
(interactive)
(let ((file-name (buffer-file-name))
(old-supersession-threat
(symbol-function 'ask-user-about-supersession-threat))
(point (point)))
(when file-name
(fset 'ask-user-about-supersession-threat (lambda (fn)))
(unwind-protect
(progn
(erase-buffer)
(insert-file file-name)
(set-visited-file-modtime)
(goto-char point))
(fset 'ask-user-about-supersession-threat
old-supersession-threat)))))
(define-key ctl-x-map "\C-r" 'reopen-file)
;; for VCS like GIT
;; git reset --hard ^HEADとかしたときに
(defun reopen-all-files ()
(interactive)
(dolist (buf (buffer-list))
(with-current-buffer buf
(reopen-file)
)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment