aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Dalziel <tom_dl@hotmail.com>2022-04-03 15:59:29 +0100
committerTom Dalziel <33435574+tomdl89@users.noreply.github.com>2022-04-03 21:55:12 +0200
commit067a29214d9d4e1fc4b4d29fc596ad4cefe7e492 (patch)
treee6c60b930ca05b48795e1605d08631f117f4fa72
parent3e41a823334abbba9cf16e482855699054d9dfe0 (diff)
Add evil-update (write when buffer is modified)
-rw-r--r--evil-commands.el9
-rw-r--r--evil-maps.el1
2 files changed, 10 insertions, 0 deletions
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)