From 067a29214d9d4e1fc4b4d29fc596ad4cefe7e492 Mon Sep 17 00:00:00 2001 From: Tom Dalziel Date: Sun, 3 Apr 2022 15:59:29 +0100 Subject: Add evil-update (write when buffer is modified) --- evil-commands.el | 9 +++++++++ evil-maps.el | 1 + 2 files changed, 10 insertions(+) diff --git a/evil-commands.el b/evil-commands.el index a0dfca6..b3f90b7 100644 --- a/evil-commands.el +++ b/evil-commands.el @@ -3165,6 +3165,15 @@ otherwise they are skipped. " (and (not buffer-read-only) (buffer-file-name)))))) +(evil-define-command evil-update () + "Same as `evil-write', but only write when the buffer has been modified." + :motion nil + :move-point nil + :type line + :repeat nil + (when (buffer-modified-p) + (call-interactively #'evil-write))) + (evil-define-command evil-save (filename &optional bang) "Save the current buffer to FILENAME. Changes the file name of the current buffer to FILENAME. If no diff --git a/evil-maps.el b/evil-maps.el index 971cf7a..e3f2651 100644 --- a/evil-maps.el +++ b/evil-maps.el @@ -472,6 +472,7 @@ included in `evil-insert-state-bindings' by default." (evil-ex-define-cmd "e[dit]" 'evil-edit) (evil-ex-define-cmd "w[rite]" 'evil-write) +(evil-ex-define-cmd "up[date]" 'evil-update) (evil-ex-define-cmd "wa[ll]" 'evil-write-all) (evil-ex-define-cmd "sav[eas]" 'evil-save) (evil-ex-define-cmd "r[ead]" 'evil-read) -- cgit v1.0