emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/vlf f83a212 213/310: Temporarily disable font-lock duri


From: Stefan Monnier
Subject: [elpa] externals/vlf f83a212 213/310: Temporarily disable font-lock during multiple batch operations.
Date: Sat, 28 Nov 2020 00:33:18 -0500 (EST)

branch: externals/vlf
commit f83a212c52a9736bca43c17091fed6c0fc23d1ce
Author: Andrey Kotlarski <m00naticus@gmail.com>
Commit: Andrey Kotlarski <m00naticus@gmail.com>

    Temporarily disable font-lock during multiple batch operations.
---
 vlf-ediff.el  | 10 ++++++++++
 vlf-search.el | 13 ++++++++++++-
 vlf-write.el  |  5 ++++-
 3 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/vlf-ediff.el b/vlf-ediff.el
index 829ce98..232c918 100644
--- a/vlf-ediff.el
+++ b/vlf-ediff.el
@@ -158,19 +158,23 @@ logical chunks in case there is no difference at the 
current ones."
   (let ((end-A (= vlf-start-pos vlf-end-pos))
         (chunk-A (cons vlf-start-pos vlf-end-pos))
         (point-max-A (point-max))
+        (font-lock-A font-lock-mode)
         (min-file-size vlf-file-size)
         (forward-p (eq next-func 'vlf-next-chunk)))
+    (font-lock-mode 0)
     (set-buffer buffer-B)
     (setq buffer-B (current-buffer)
           min-file-size (min min-file-size vlf-file-size))
     (let ((end-B (= vlf-start-pos vlf-end-pos))
           (chunk-B (cons vlf-start-pos vlf-end-pos))
+          (font-lock-B font-lock-mode)
           (done nil)
           (reporter (make-progress-reporter
                      "Searching for difference..."
                      (if forward-p vlf-start-pos
                        (- min-file-size vlf-end-pos))
                      min-file-size)))
+      (font-lock-mode 0)
       (unwind-protect
           (progn
             (while (and (or (not end-A) (not end-B))
@@ -217,6 +221,12 @@ logical chunks in case there is no difference at the 
current ones."
                       (and (not end-A) (not end-B)))
                   (vlf-ediff-refine buffer-A buffer-B)))
             (setq done t))
+        (when font-lock-A
+          (set-buffer buffer-A)
+          (font-lock-mode 1))
+        (when font-lock-B
+          (set-buffer buffer-B)
+          (font-lock-mode 1))
         (unless done
           (set-buffer buffer-A)
           (set-buffer-modified-p nil)
diff --git a/vlf-search.el b/vlf-search.el
index 32ec2bd..422fbda 100644
--- a/vlf-search.el
+++ b/vlf-search.el
@@ -40,12 +40,14 @@ BATCH-STEP is amount of overlap between successive chunks."
          (match-start-pos (+ vlf-start-pos (position-bytes (point))))
          (match-end-pos match-start-pos)
          (to-find count)
+         (font-lock font-lock-mode)
          (reporter (make-progress-reporter
                     (concat "Searching for " regexp "...")
                     (if backward
                         (- vlf-file-size vlf-end-pos)
                       vlf-start-pos)
                     vlf-file-size)))
+    (font-lock-mode 0)
     (vlf-with-undo-disabled
      (unwind-protect
          (catch 'end-of-file
@@ -108,6 +110,7 @@ BATCH-STEP is amount of overlap between successive chunks."
                                                   vlf-end-pos)))))
            (progress-reporter-done reporter))
        (set-buffer-modified-p nil)
+       (if font-lock (font-lock-mode 1))
        (if backward
            (vlf-goto-match match-chunk-start match-chunk-end
                            match-end-pos match-start-pos
@@ -179,11 +182,17 @@ Search is performed chunk by chunk in `vlf-batch-size' 
memory."
   (let ((start-pos vlf-start-pos)
         (end-pos vlf-end-pos)
         (pos (point))
+        (font-lock font-lock-mode)
         (success nil))
+    (font-lock-mode 0)
     (unwind-protect
         (if (< 0 n)
             (let ((start 0)
                   (end (min vlf-batch-size vlf-file-size))
+                  (reporter (make-progress-reporter
+                             (concat "Searching for line "
+                                     (number-to-string n) "...")
+                             0 vlf-file-size))
                   (inhibit-read-only t))
               (setq n (1- n))
               (vlf-with-undo-disabled
@@ -230,9 +239,11 @@ Search is performed chunk by chunk in `vlf-batch-size' 
memory."
                (vlf-move-to-chunk-2 start end)
                (goto-char (point-max))
                (setq success (vlf-re-search "[\n\C-m]" n t 0))))))
+      (if font-lock (font-lock-mode 1))
       (unless success
         (vlf-move-to-chunk-2 start-pos end-pos)
-        (goto-char pos)))))
+        (goto-char pos)
+        (message "Unable to find line")))))
 
 (provide 'vlf-search)
 
diff --git a/vlf-write.el b/vlf-write.el
index 7e9d069..ffb948a 100644
--- a/vlf-write.el
+++ b/vlf-write.el
@@ -52,10 +52,13 @@ Save anyway? "))
                                 region-length)))
            (if (zerop size-change)
                (write-region nil nil buffer-file-name vlf-start-pos t)
-             (let ((pos (point)))
+             (let ((pos (point))
+                   (font-lock font-lock-mode))
+               (font-lock-mode 0)
                (if (< 0 size-change)
                    (vlf-file-shift-back size-change)
                  (vlf-file-shift-forward (- size-change)))
+               (if font-lock (font-lock-mode 1))
                (vlf-move-to-chunk-2 vlf-start-pos
                                     (if (< (- vlf-end-pos vlf-start-pos)
                                            vlf-batch-size)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]