From 96391d13f96d3b7f9c4d31b6e6372a29f992886e Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 7 Jul 2020 11:16:14 -0700 Subject: [PATCH] Fix emacs hook to not clobber match data Without this, trying to do a search-and-replace operation with emacs on a file withing a directory that had some nogit-managed files would error out after the first replacement with an error: Match data clobbered by buffer modification hook --- README | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/README b/README index 98aee15..bae558f 100644 --- a/README +++ b/README @@ -74,14 +74,16 @@ save it: ; and recurse. (defun nogit-sync-if-configured () (interactive) - (if (and - (buffer-file-name) - (file-exists-p (format "%s/../.nogit" (buffer-file-name))) - (not (boundp 'in-nogit-sync)) - ) - (let ((in-nogit-sync t)) - (message (substring (shell-command-to-string "nogit sync") 0 -1)) - (revert-buffer nil t) + (save-match-data + (if (and + (buffer-file-name) + (file-exists-p (format "%s/../.nogit" (buffer-file-name))) + (not (boundp 'in-nogit-sync)) + ) + (let ((in-nogit-sync t)) + (message (substring (shell-command-to-string "nogit sync") 0 -1)) + (revert-buffer nil t) + ) ) ) ) -- 2.43.0