❦ 19 août 2014 21:44 -0400, Barry Warsaw <ba...@debian.org> : > * Switching branches makes my editor unhappy. > > Why is this a PITA? Because Emacs will notice that a file you're visiting in > a buffer is changed and will prompt you reload it. I guess because > checkout-patched deletes the debian directory and update-patches restores it, > it makes Emacs unhappy. I suppose you also have to be careful not to write a > buffer to the debian/ directory when in the patched-<pkg> branch.
I am using this snippet: #+begin_src elisp (defun vbe:revert-buffer-keep-history (&rest -) "Revert buffer but keep undo history" (clear-visited-file-modtime) (widen) (let ((inhibit-read-only t) (current-point (point))) (delete-region (point-min) (point-max)) (insert-file-contents (buffer-file-name)) (not-modified) (goto-char current-point) (set-visited-file-modtime))) (setq revert-buffer-function 'vbe:revert-buffer-keep-history) (global-auto-revert-mode 1) ; Auto revert (when no pending changes) #+end_src This makes auto revert automatic but don't lose the previous content by keeping the undo history. It also keeps your current position in the file. -- Write and test a big program in small pieces. - The Elements of Programming Style (Kernighan & Plauger)
signature.asc
Description: PGP signature