M-x revert-buffer will do exactly what you want. It will still ask for confirmation.
Another option (my favorite) is the below function:
;; Source: http://www.emacswiki.org/emacs-en/download/misc-cmds.el
(defun revert-buffer-no-confirm ()
"Revert buffer without confirmation."
(revert-buffer :ignore-auto :noconfirm))
There is also auto-revert-mode which does it automatically and gives you feedback.
From the doc string:
auto-revert-mode is an interactive autoloaded compiled Lisp function
(auto-revert-mode &optional ARG)
Toggle reverting buffer when the file changes (Auto Revert mode).
With a prefix argument ARG, enable Auto Revert mode if ARG ...
Another option, which I use, is find-alternate-file bound to C-x C-v. This opens a file reusing your current buffer.
By default, it points to the file you're currently on, so you can just type C-x C-v RET to reload your file. It won't prompt unless your buffer has unsaved data.
Some non-text modes like image-mode (used for rendering pictures, pdfs, svgs......
A minor mode is not enabled/disabled by setting a variable. The minor mode variable should be used to check the "mode enabled" status, not to set the mode state. If its value is t, the minor mode is on, else the mode is off.
See the below snippets to see how to control any minor mode. Replace MINOR-MODE-NAME with the actual minor mode name you are dealing ...
Customize option auto-revert-verbose to nil. C-h v tells you this:
auto-revert-verbose is a variable defined in autorevert.el.
Its value is t
When nil, Auto-Revert Mode does not generate any messages.
When non-nil, a message is generated whenever a file is reverted.
You can customize this variable.
It's kind of a shame that the doc of auto-...
If you use magit you can create a stash with the z z command from the magit-status buffer. You can also pop a stash using the A command.
If you use these commands, affected files will be automatically reverted (changes are loaded).
Check out the magit documentation for more info on how to use magit effectively.
Emacs calls this reverting.
You can revert the current file with M-x revert-buffer. This prompts for confirmation whether the file has been modified or not, except for files that match patterns listed in the variable revert-without-query (see the manual for details). Another occasional annoyance of revert-buffer is that it resets the file mode to the ...
Here is my slightly improved version of the snippet in the question. Reviewing my VC history, I confirm that the below snippet started out as the snippet posted by the OP. So I do pay attribute to that.
Here's the code that has been stable for me:
(defun modi/revert-all-file-buffers ()
"Refresh all open buffers from their respective files.&...
revert-buffer is there. But I like to have some feedback.
I have the following in my .emacs.
(global-set-key (kbd "C-c r") (lambda ()
(revert-buffer t t t)
(message "buffer is reverted")))
Not sure what you're asking. But FWIW, I use this, and I bind it to <f5>:
(defun revert-buffer-no-confirm ()
"Revert buffer without confirmation."
(interactive) (revert-buffer t t))
Note that you probably do not want to redefine or advise revert-buffer. You probably want to change the behavior only for interactive calls (there are plenty of Lisp ...
In case someone else runs into this, I had enabled TeX-auto-save, which saves settings to an auto/ directory and loads them when a file is revisited.
Set auto-revert-remote-files to nil. This disables auto reverting for all files with Tramp syntax.
If you want to disable auto reverting of remote files in a mounted directory, or in a sync directory, add that directory name to auto-revert-notify-exclude-dir-regexp.
(defun revert-all-no-confirm ()
"Revert all file buffers, without confirmation.
Buffers visiting files that no longer exist are ignored.
Files that are not readable (including do not exist) are ignored.
Other errors while reverting a buffer are reported only as messages."
(dolist (buf (buffer-list))
For spacemacs users: SPC b R (spacemacs/safe-revert-buffer).
For skipping confirmation, other answers already cover that, though I agree with others that it's probably not a good idea to bind that to a key.
Magit manages file reversions for you automatically, thus solving your core problem. You also benefit from its other features.
Here are the docs for the tweaking the settings you're interested in:
If you stick with Magit, also be sure to enable all 3 global WIP modes (Work In Progress) to avoid losing work.
You can thus perform version-control actions ...
If I understand correctly, "revert" means to reload the file in the file system into the emacs buffer
This is correct.
(There are other details which you can read about in the documentation, including what "revert" means to non-file-visiting buffers; but broadly speaking your understanding is accurate.)
so the buffer will be updated with the latest ...
As Dan pointed out, by default you need to manually revert dired buffers (e.g., by typing g) in order to update the directory listing view.
If you want this to happen automatically, then you can turn on auto-revert mode. For example,
(add-hook 'dired-mode-hook #'(turn-on-auto-revert-mode))
But see the Emacs manual, node Auto Reverting Dired for some ...
You can see what command a key sequence is bound to by using 'M-x describe-key' (normally bound to 'C-h k').
Switching to a dired buffer and running C-h k gives an extensive help text. The start is:
g runs the command revert-buffer (found in dired-mode-map), which is ...
It seems that this problem is caused by a bug of emacs-jedi.
To avoid it,
Upgrade emacs-jedi to the latest version (newer than 736300f).
Set jedi:install-imenu to nil (the default value is nil).
Something is wrong with jedi:after-change-handler.
But I do not fully understand why the problem occurs.
It is related to asynchronous programming and is hard to ...
You could use C-hv global-auto-revert-ignore-buffer with C-hv find-file-hook
(defun my-inhibit-remote-auto-revert ()
"Used in `find-file-hook'."
(when (file-remote-p buffer-file-name)
(setq global-auto-revert-ignore-buffer t)))
(add-hook 'find-file-hook #'my-inhibit-remote-auto-revert)
Variable text-scale-mode-amount holds the number of text-scale-mode steps. (Variable text-scale-mode-step holds the amount to scale for each step.)
Save text-scale-mode-amount, then later pass it to text-scale-increase.
I accepted Kausal's answer since it was closest to what I wanted, but I grabbed part of Drew's solution, too. I wrapped revert-buffer in with-demoted-errors and dropped the :preserve-modes parameter so that my syntax checker would re-parse all of my open files. I also let it kill modified files as well as unmodified, since I often get in trouble by ...
grepping for "really edit the buffer" in emacs source I found function ask-user-about-supersession-threat in file userlock.el.
It seems straightforward to add a d choice for calling ediff-current-file. I haven't tested this extensively, though (edits marked with ;;- comments).
(defun ask-user-about-supersession-threat (fn)
"Ask a user who is about to ...
you could use a local variable in your org files this way:
# Local Variables:
# eval: (auto-revert-mode)
Just append those lines at the end of each generated file. It'll work next time you open them. That should take care of those passive files.
The revert-buffer function takes a few parameters which I think make the reload faster. I've got this bound to a keyboard shortcut for reloading the current buffer, it feels as fast as when you first open the file:
(defun reload-file-preserve-point ()
(when (or (not (buffer-modified-p))
(y-or-n-p "Reverting will discard changes....
When there is an error in the syntax highlighting code, it is silently ignored by the font-lock package. When this happens, the buffer can be left in an unhighlighted state.
You can use the package font-lock-studio to investigate what happens, and catch errors in the font-lock code. It is a debugger that lets you step each part of the font-lock rules and if ...
To see the mandatory and optional arguments to functions such as run-with-timer and revert-buffer, type C-h f (aka M-x describe-function).
How about something like this?
(run-with-timer 0 (* 60 60)
(mapc (lambda (buffer)