>> vc-find-revision-no-save also calls set-auto-mode. So, I don't know if >> the following patch is correct, but together with your patch it does >> solve the original issue. >> >> diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el >> index f64b6c0631..c50ba132e7 100644 >> --- a/lisp/vc/vc.el >> +++ b/lisp/vc/vc.el >> @@ -2098,7 +2098,7 @@ vc-find-revision-no-save >> ;; For non-interactive, skip any questions >> (let ((enable-local-variables :safe) ;; to find `mode:' >> (buffer-file-name file)) >> - (ignore-errors (set-auto-mode))) >> + (ignore-errors (delay-mode-hooks (set-auto-mode)))) >> (normal-mode)) >> (set-buffer-modified-p nil) >> (setq buffer-read-only t)) > > How 'bout we first consolidate the two cases into one by introducing > a new function `set-auto-mode-for-filename` that both > vc-find-revision-no-save and diff-mode can use? Actually vc-find-revision-no-save when called as a command (e.g. by the key 'f' from log-view) still should run hooks because the buffer it creates is not internal. Only its call from diff-syntax-fontify-hunk should not run hooks: