emacs-diffs
[Top][All Lists]
Advanced

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

scratch/etags-regen 2350411 5/5: Speed up tags file update


From: Dmitry Gutov
Subject: scratch/etags-regen 2350411 5/5: Speed up tags file update
Date: Sat, 12 Dec 2020 01:22:57 -0500 (EST)

branch: scratch/etags-regen
commit 2350411d4128e96e0eca10bb82e1a14bdb1d454e
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>

    Speed up tags file update
---
 lisp/progmodes/etags.el | 38 +++++++++++++++++++++++---------------
 1 file changed, 23 insertions(+), 15 deletions(-)

diff --git a/lisp/progmodes/etags.el b/lisp/progmodes/etags.el
index 926820d..a12dae1 100644
--- a/lisp/progmodes/etags.el
+++ b/lisp/progmodes/etags.el
@@ -2228,24 +2228,32 @@ file name, add `tag-partial-file-name-match-p' to the 
list value.")
                              (if (eobp)
                                  (point)
                                (- (point) 2)))
-              (write-region (point-min) (point-max) buffer-file-name nil 
'silent)))
+              (write-region (point-min) (point-max) buffer-file-name nil 
'silent)
+              (set-visited-file-modtime)))
           (setq should-scan t))))
       (when should-scan
-        (call-process
-         etags--command
-         nil
-         '("*etags-project-tags-errors*" t)
-         nil
-         file-name
-         "--append"
-         "-o"
-         etags--project-tags-file)
-        ;; TODO: When the project is big (tags file in 10s of megabytes),
-        ;; revert-buffer is predictably slow.  One way to avoid
-        ;; this is to only keep TAGS in a buffer, but not on disk.
-        (revert-buffer t t)
-        (tags-table-mode)
+        (goto-char (point-max))
+        (let ((inhibit-read-only t)
+              (current-end (point)))
+          (call-process
+           etags--command
+           nil
+           '(t "*etags-project-tags-errors*")
+           nil
+           file-name
+           "--append"
+           "-o"
+           "-")
+          ;; XXX: When the project is big (tags file in 10s of megabytes),
+          ;; this is much faster than revert-buffer.  Or even using
+          ;; write-region without APPEND.
+          ;; We could also keep TAGS strictly as a buffer, with no
+          ;; backing on disk.
+          (write-region current-end (point-max) etags--project-tags-file t))
+        (set-visited-file-modtime)
         ;; FIXME: Is there a better way to do this?
+        ;; Completion table is the only remaining place where the
+        ;; update is not incremental.
         (setq-default tags-completion-table nil)
         ))))
 



reply via email to

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