diff options
| author | Frank LENORMAND <lenormf@gmail.com> | 2016-07-20 20:45:50 +0300 |
|---|---|---|
| committer | Frank LENORMAND <lenormf@gmail.com> | 2016-07-23 10:03:21 +0300 |
| commit | 8a4596bea9d85c86d03efa129c41530faa2a34a7 (patch) | |
| tree | 8cd6a789c734e8507042fb5126cf692dd3ae789c /src/buffer_manager.cc | |
| parent | 88a9607552fd3c614e6d70a271b663323306a8db (diff) | |
Implement a `readonly` mode
This commit introduces the `readonly` variable as well as the `-ro`
command line option which prevent buffers from being overwritten on
disk when the `write` command is used without arguments. Some buffers
can selectively be put in readonly mode by setting the `readonly`
variable on the `buffer` scope, the `global` mode will affect all
buffers (even those who will be open subsequently), using the `window`
scope will have no effect.
Closes #685
Diffstat (limited to 'src/buffer_manager.cc')
| -rw-r--r-- | src/buffer_manager.cc | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/buffer_manager.cc b/src/buffer_manager.cc index e743bff0..688e864a 100644 --- a/src/buffer_manager.cc +++ b/src/buffer_manager.cc @@ -78,7 +78,8 @@ void BufferManager::backup_modified_buffers() { for (auto& buf : m_buffers) { - if ((buf->flags() & Buffer::Flags::File) and buf->is_modified()) + if ((buf->flags() & Buffer::Flags::File) and buf->is_modified() + and !(buf->flags() & Buffer::Flags::ReadOnly)) write_buffer_to_backup_file(*buf); } } |
