Coder Social home page Coder Social logo

Comments (3)

Ergus avatar Ergus commented on August 16, 2024
(cl-defun global-tags--get-dbpath (&optional (dir default-directory))
  "Filepath for database from DIR."
  (pcase (gethash dir global-tags--dbpath-cache)
    ('empty nil)
    ('nil
     (puthash dir 'empty global-tags--dbpath-cache)
     (when-let* 
       === BLA ===
       (when (file-exists-p dbpath)
	 (puthash dir dbpath global-tags--dbpath-cache))))
    (code code)))

from emacs-counsel-gtags.

FelipeLema avatar FelipeLema commented on August 16, 2024

I'm actually using somewhat the first solution you propose, using cache, at work. I hadn't updated that code, although it's stable now. I'm actually inheriting wrapping global-tags-try-project-root with a function that first checks cached roots before calling any global-tags function. This is a great feature of the extensible design of project.el and xref.el

what I'm doing is using a persist-defvar with a list of already-used "project roots per gtags". Since I don't tend to delete source code at work, I've never had to worry about that list including deleted code. I don't know if it's the same for anyone else, but I guess that a Emacs-session-local var should be enough for everyone.

Should we have a timeout for cached project roots? How much? 24h? Refreshing the cache list can be done in the background using async, so that's not a problem.

from emacs-counsel-gtags.

Ergus avatar Ergus commented on August 16, 2024

I'm actually using somewhat the first solution you propose, using cache, at work. I hadn't updated that code, although it's stable now. I'm actually inheriting wrapping global-tags-try-project-root with a function that first checks cached roots before calling any global-tags function. This is a great feature of the extensible design of project.el and xref.el

The second solution is actually better because project-find-functions may have more than one function to try, and it is useful to avoid repeating the search with global-tags--get-dbpath when it failed in this session once.

I actually reported an emacs bug bug#49264 to see if they add some caching features to project.el because the vc backend is also very slow.

what I'm doing is using a persist-defvar with a list of already-used "project roots per gtags". Since I don't tend to delete source code at work, I've never had to worry about that list including deleted code. I don't know if it's the same for anyone else, but I guess that a Emacs-session-local var should be enough for everyone.

Should we have a timeout for cached project roots? How much? 24h? Refreshing the cache list can be done in the background using async, so that's not a problem.

That may be a custom... so 0 means disable cache, a number the time in whatever unit you want and nil disable auto erasing.

from emacs-counsel-gtags.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.