From 4cbefdeecaba0f88734b9a888199842421941038 Mon Sep 17 00:00:00 2001 From: Andrey Kotlarski Date: Sun, 14 Apr 2013 00:54:16 +0300 Subject: [PATCH] Optimize chunk save buffers for multiple insert/erase operations. --- vlfi.el | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/vlfi.el b/vlfi.el index 581d50e..4848e17 100644 --- a/vlfi.el +++ b/vlfi.el @@ -474,11 +474,18 @@ Save anyway? "))) (vlfi-mode) t)) +(defun vlfi-prepare-write-buffer () + "Optimize buffer for a lot of insert/erasure." + (setq delay-mode-hooks t) + (fundamental-mode) + (buffer-disable-undo)) + (defun vlfi-file-shift-back (size-change) "Shift file contents SIZE-CHANGE bytes back." (let ((coding-system buffer-file-coding-system)) (write-region nil nil buffer-file-name vlfi-start-pos t) (setq buffer-file-coding-system nil) + (vlfi-prepare-write-buffer) (let ((read-start-pos vlfi-end-pos) (reporter (make-progress-reporter "Adjusting file content" vlfi-end-pos @@ -516,8 +523,10 @@ Done by saving content up front and then writing previous batch." (coding-system buffer-file-coding-system)) (let ((file buffer-file-name)) (set-buffer temp-buffer) - (setq buffer-file-name file)) + (setq buffer-file-name file) + (vlfi-prepare-write-buffer)) (set-buffer vlfi-buffer) + (vlfi-prepare-write-buffer) (let ((read-buffer temp-buffer) (write-buffer vlfi-buffer) (size (+ vlfi-batch-size size-change))