Coder Social home page Coder Social logo

Comments (6)

redguardtoo avatar redguardtoo commented on June 1, 2024

syntax error in your code. Delete your ignore pattern setup. Do as my step by step guide at least once.

from counsel-etags.

nils-schween avatar nils-schween commented on June 1, 2024

Thank you for your fast answer and I am sorry. I had copied the setup and did not recognize the difference to your readme.md.

I did as you said, I commented out the ignore pattern and I ran your step-by-step example. It works for the fn() function and the printf() function. But if a add another function to it, it will not be stored in the TAGS file. No matter how long I wait, or how often I save the hello.c file.

from counsel-etags.

redguardtoo avatar redguardtoo commented on June 1, 2024

I tested latest version. It's working.

Try start from this setup.

(setq counsel-etags-update-interval 10)
(add-hook 'prog-mode-hook
  (lambda ()
    (add-hook 'after-save-hook
              'counsel-etags-virtual-update-tags 'append 'local)))

Just use it, don't try to optimize further.

from counsel-etags.

nils-schween avatar nils-schween commented on June 1, 2024

Hi @redguardtoo,
I did as you said and reduced my counsel-etags' setup to the proposed minimun. It still did not work. I decided to track down the error and it took me a while, but I figured out, that it is related to use of use-package. To demonstrate this, I post a preliminary first and working setup:

(use-package counsel-etags
  :ensure t
  :bind (("M-." . counsel-etags-find-tag-at-point)
            ("M-t" . counsel-etags-grep-symbol-at-point)
            ("M-s" . counsel-etags-find-tag))
  :init
  (add-hook 'prog-mode-hook
  	    (lambda ()
  	      (add-hook 'after-save-hook
  			'counsel-etags-virtual-update-tags 'append 'local)))
  :config
  ;; Ignore files above 800kb
  ;; (setq counsel-etags-max-file-size 800)
  ;; Don't ask before rereading the TAGS files if they have changed
  (setq tags-revert-without-query t)
  ;; Don't warn when TAGS files are large
  (setq large-file-warning-threshold nil)
  ;; How many seconds to wait before rerunning tags for auto-update
  (setq counsel-etags-update-interval 10)
  
  ;; ignored files and directories
  (add-to-list 'counsel-etags-ignore-directories "build")
  (add-to-list 'counsel-etags-ignore-directories ".vscode")
  (add-to-list 'counsel-etags-ignore-filenames ".clang-format")
  )

use-package makes a difference between code executed before a package is loaded ( everything after the :init keyword) and code which is executed after a package is loaded ( everything after the :config keyword). If the add-hook function with argument prog-mode-hook is executed after the package counsel-etags is loaded, it does not work as intended. Thus, the add-hook function has to transferred into the :init part of the use-package configuration.

I looked through the documentation of use-package and found an even more elegant way to execute the hook:

(use-package counsel-etags
  :ensure t
  :hook (prog-mode . (lambda ()
  		       (add-hook 'after-save-hook
  				 'counsel-etags-virtual-update-tags 'append 'local)))
  :bind (("M-." . counsel-etags-find-tag-at-point)
         ("M-t" . counsel-etags-grep-symbol-at-point)
         ("M-s" . counsel-etags-find-tag))
  :config
  ;; Ignore files above 800kb
  ;; (setq counsel-etags-max-file-size 800)

  ;; Don't ask before rereading the TAGS files if they have changed
  (setq tags-revert-without-query t)
  ;; Don't warn when TAGS files are large
  (setq large-file-warning-threshold nil)
  ;; How many seconds to wait before rerunning tags for auto-update
  (setq counsel-etags-update-interval 10)
  ;; Ignore build directories for tagging
  (add-to-list 'counsel-etags-ignore-directories "build")
  (add-to-list 'counsel-etags-ignore-directories ".vscode")
  (add-to-list 'counsel-etags-ignore-filenames ".clang-format")

  )

I don't know how the keyword :hook is implemented, but since it was done by jwiegley, it's probably the way to go.

@redguardtoo could you imagine to copy the last code snippet into your readme.md ? It would be perfect for everyone who uses use-package to find it under the heading "Installation".

One more thing: It would be create to mention, that a TAGS file has to be created manually in the root folder and that the automatic update process starts after the first call of counsel-etags-find-tag.

Thank you very much for your help!

from counsel-etags.

redguardtoo avatar redguardtoo commented on June 1, 2024

Sure. Actually, you first setup is better. It ensures the add-hook code is executed only once when prog-mode is loaded.

from counsel-etags.

nils-schween avatar nils-schween commented on June 1, 2024

@redguardtoo: thanks a lot! I close the issue.

from counsel-etags.

Related Issues (20)

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.