Comments (6)
syntax error in your code. Delete your ignore pattern setup. Do as my step by step guide at least once.
from counsel-etags.
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.
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.
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.
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.
@redguardtoo: thanks a lot! I close the issue.
from counsel-etags.
Related Issues (20)
- counsel-etags-grep cant' follow parameters? HOT 6
- Issue with creating a TAGS file when in Tramp mode HOT 2
- counsel-etags did not auto update TAG file. HOT 11
- need CI and tdd HOT 1
- How to color candidate/selection when 'counsel-etags-grep' like swiper does? HOT 8
- could add function name in when looking up tags
- how to do case insensitive grep? HOT 4
- When calling "counsel-etags-find-tag-at-point", rg report separator is error HOT 6
- Unable to use counsel-etags-grep under the windows version of emacs (spacemacs) HOT 3
- Ctags Will Scan Code When Jump Next Tag HOT 12
- How to go back to previous position after I executed counsel-etags-find-tag-at-point ? HOT 2
- 如何指定tag的输出路径 HOT 4
- about ctags cache HOT 4
- counsel-etags-find-tag-at-point-other-window
- How can I append external tags? HOT 4
- Please don't provide a feature in my-byte-compile HOT 2
- "No tag is found." although TAGS file contains this tag HOT 6
- Counsel-etags-grep can only find results in some files HOT 6
- 当tag搜索不到想要的内容时回退到使用ripgrep HOT 4
- 调用 counsel-etags-grep 时可以忽略tag文件 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from counsel-etags.