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

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

[elpa] 07/14: Fix #65: Clear ggtags-project-root based on default-direct


From: Leo Liu
Subject: [elpa] 07/14: Fix #65: Clear ggtags-project-root based on default-directory
Date: Sun, 22 Jun 2014 09:41:41 +0000

leoliu pushed a commit to branch master
in repository elpa.

commit e16006067babac5d88b778f5da4399dc60710abd
Author: Leo Liu <address@hidden>
Date:   Sat Jun 14 15:08:18 2014 +0800

    Fix #65: Clear ggtags-project-root based on default-directory
---
 ggtags.el |   14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/ggtags.el b/ggtags.el
index a17c5b3..18f47e3 100644
--- a/ggtags.el
+++ b/ggtags.el
@@ -474,21 +474,18 @@ Value is new modtime if updated."
     (size (let ((project (or project (ggtags-find-project))))
             (and project (> (ggtags-project-tag-size project) size))))))
 
+(defvar-local ggtags-last-default-directory nil)
 (defvar-local ggtags-project-root 'unset
   "Internal variable for project root directory.")
 
-(defun ggtags-clear-project-root ()
-  (kill-local-variable 'ggtags-project-root))
-
 ;;;###autoload
 (defun ggtags-find-project ()
   ;; See https://github.com/leoliu/ggtags/issues/42
   ;;
-  ;; It is unsafe to cache `ggtags-project-root' in non-file buffers.
-  ;; But we keep the cache for a command's duration so that multiple
-  ;; calls of `ggtags-find-project' has no performance impact.
-  (unless buffer-file-name
-    (add-hook 'pre-command-hook #'ggtags-clear-project-root nil t))
+  ;; It is unsafe to cache `ggtags-project-root' in non-file buffers
+  ;; whose `default-directory' can often change.
+  (unless (equal ggtags-last-default-directory default-directory)
+    (kill-local-variable 'ggtags-project-root))
   (let ((project (gethash ggtags-project-root ggtags-projects)))
     (if (ggtags-project-p project)
         (if (ggtags-project-expired-p project)
@@ -496,6 +493,7 @@ Value is new modtime if updated."
               (remhash ggtags-project-root ggtags-projects)
               (ggtags-find-project))
           project)
+      (setq ggtags-last-default-directory default-directory)
       (setq ggtags-project-root
             (or (ignore-errors-unless-debug
                   (file-name-as-directory



reply via email to

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