counsel-etags icon indicating copy to clipboard operation
counsel-etags copied to clipboard

counsel-etags did not auto update TAG file.

Open jason--liu opened this issue 4 years ago • 11 comments

This is my counsel-etags config. counsel-etags have updated to latest.

  (add-to-list 'load-path "~/.spacemacs.d/site-lisp/etags/")
  (require 'counsel-etags)
  (define-key evil-normal-state-map (kbd ", g d") 'counsel-etags-find-tag-at-point)
  (define-key evil-normal-state-map (kbd ", g t") 'counsel-etags-grep)
  (define-key evil-visual-state-map (kbd ", g t") 'counsel-etags-grep)
  ;; 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 180)
  (eval-after-load 'counsel-etags
    '(progn
       ;; counsel-etags-ignore-directories does NOT support wildcast
       (add-to-list 'counsel-etags-ignore-directories "build")
       (add-to-list 'counsel-etags-ignore-directories "build_clang")
       ;; counsel-etags-ignore-filenames supports wildcast
       (add-to-list 'counsel-etags-ignore-filenames "TAGS")
       (add-to-list 'counsel-etags-ignore-filenames "*.json")))
  ;; Setup auto-update
  (add-hook 'prog-mode-hook
            (lambda ()
              (add-hook 'after-save-hook
                        'counsel-etags-virtual-update-tags 'append 'local)))
  (add-hook 'after-save-hook 'counsel-etags-virtual-update-tags)

When I update a C file and autosaved, use ,g d to navigate, it still jump to origin position, did not jump to the new position; But after I force updated the TAG file, it can navigate normally. Please see below gif : Peek 2020-09-02 20-47

As the gif shows, the memblock_reserved_size function was originally at line 1544, then I added some blank lines before the function and saved it. Use , g d, it still jumped to 1544, however the function is at line 1550 now.

jason--liu avatar Sep 02 '20 12:09 jason--liu

I tested the latest version. It's working.

Below code is enough,

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

Change counsel-etags-update-interval to a smaller number.

redguardtoo avatar Sep 02 '20 16:09 redguardtoo

Hi @redguardtoo I have updated my ini config

  (add-to-list 'load-path "~/.spacemacs.d/site-lisp/etags/")
  (require 'counsel-etags)
  (define-key evil-normal-state-map (kbd ", g d") 'counsel-etags-find-tag-at-point)
  (define-key evil-normal-state-map (kbd ", g t") 'counsel-etags-grep)
  (define-key evil-visual-state-map (kbd ", g t") 'counsel-etags-grep)
  ;; 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 1)
  (eval-after-load 'counsel-etags
    '(progn
       ;; counsel-etags-ignore-directories does NOT support wildcast
       (add-to-list 'counsel-etags-ignore-directories "build")
       (add-to-list 'counsel-etags-ignore-directories "build_clang")
       ;; counsel-etags-ignore-filenames supports wildcast
       (add-to-list 'counsel-etags-ignore-filenames "TAGS")
       (add-to-list 'counsel-etags-ignore-filenames "*.json")))
  ;; Setup auto-update
  (add-hook 'prog-mode-hook
            (lambda ()
              (add-hook 'after-save-hook
                        'counsel-etags-virtual-update-tags 'append 'local)))
  ;; (add-hook 'after-save-hook 'counsel-etags-virtual-update-tags)

and set counsel-etags-update-interval to 1 sec. But still it is not update automaticlly. Is there any log can help to find the problem ?

jason--liu avatar Sep 03 '20 13:09 jason--liu

(setq counsel-etags-debug t). Make sure you have ctags installed and create tags file at least once in project root.

redguardtoo avatar Sep 03 '20 13:09 redguardtoo

Hi @redguardtoo Yes, I have installed ctags

ctags --version
Universal Ctags 0.0.0(b7439756), Copyright (C) 2015 Universal Ctags Team
Universal Ctags is derived from Exuberant Ctags.
Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert
  Compiled: Aug 12 2020, 16:01:04
  URL: https://ctags.io/
  Optional compiled features: +wildcards, +regex, +iconv, +option-directory, +packcc

and TAGS was scaned and created at the first time. After I set (setq counsel-etags-debug t) and change a file and save it, after the interval time I did not see any counsel-etags log in Message buffer.

jason--liu avatar Sep 03 '20 13:09 jason--liu

Have you tested with a minimum project? See readme

redguardtoo avatar Sep 03 '20 15:09 redguardtoo

@redguardtoo I have just tested the toy project in readme, unfortunately, it did not auto update TAG.

jason--liu avatar Sep 04 '20 02:09 jason--liu

Tomorrow install the latest counsel-etags and turn of debug flag. I need see the debug output.

I also need see the value of after-save-hook.

redguardtoo avatar Sep 04 '20 11:09 redguardtoo

Hi, @redguardtoo I have updated the latest counsel-etags. please see the log image

image

As the pic shows, the fn func was original at line 7.After I change the file, the func should be line 10. But it still jump to Line 7

Please ignore the error log, that' ycmd log(it could be conflict with counsel-etags)?

jason--liu avatar Sep 05 '20 03:09 jason--liu

There is no message in update tags in .... So tags file is not re-generated.

Insert (setq counsel-etags-update-interval 3) into init.el and try to reproduce the issue.

redguardtoo avatar Sep 06 '20 13:09 redguardtoo

@redguardtoo After I Insert (setq counsel-etags-update-interval 3) (before was 1 sec) and wrote the file and saved it After a while, there were no more logs..(even the counsel-etags-virtual-update-tag log)

image

and it still jump to line 7, which should be line 10.

BTW emacs version

➜  proj1 emacs --version
GNU Emacs 26.3
Copyright (C) 2019 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of GNU Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.

OS Ubuntu18.04 LTS

jason--liu avatar Sep 07 '20 03:09 jason--liu

Try my emacs.d.

redguardtoo avatar Sep 07 '20 14:09 redguardtoo