Skip to content

Instantly share code, notes, and snippets.

@stakemori
Created September 10, 2015 13:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stakemori/ccf0e4cfae2fcfafbf0a to your computer and use it in GitHub Desktop.
Save stakemori/ccf0e4cfae2fcfafbf0a to your computer and use it in GitHub Desktop.
#20440 reproducible code
(require 'cl-lib)
(defun my/test-revert-buffer ()
(let ((file (make-temp-file "test-revert-buffer" nil ".py"))
(file-content1 "# -*- coding: utf-8 -*-
'''
Foo.
'''
")
(file-content2 "# -*- coding: utf-8 -*-
class Foo(object):
pass
"))
(write-region file-content1 nil file nil 'silent)
(find-file file)
;; The content of the current buffer is equal to file-content1.
(write-region file-content2 nil file nil 'silent)
(revert-buffer nil t)
;; Now the content of the current buffer should be equal to file-content2.
(cl-assert (string= (buffer-string) file-content2))))
(defun my/add-to-after-change-functions ()
(add-hook 'after-change-functions (lambda (x y z) (buffer-string)) nil t))
(add-hook 'python-mode-hook #'my/add-to-after-change-functions)
(my/test-revert-buffer)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment