redguardtoo / counsel-etags

Fast, energy-saving, and powerful code navigation solution
174 stars 15 forks source link

Win10: Setting-tags `counsel-etags-program' to "ctags -e -R" creates empty TAGS file #58

Closed srustamo closed 4 years ago

srustamo commented 4 years ago

Win10; GNU Emacs 26.3 (build 1, x86_64-w64-mingw32) of 2019-08-29 ctags: https://chocolatey.org/packages/ctags

counsel-etags-program is set to ctags -e -L.

In win console, running "ctags -e -L" (as suggested for counsel-etags-program value in readme) produces empty tags file. ctags -e -R produces readable by Emacs TAGS file.

Running any counsel-etags tag update command on a project dir without any TAGS file, produces empty TAGS file.

The console command ctags -e -R produces readable by Emacs TAGS file, and all counsel-etags commands work.

Any idea how to fix this?

Edit: Also, running ctags-update in Emacs produces a readable TAGS file, all other things above being equal.

redguardtoo commented 4 years ago

counsel-etags-program should be ctags or full path of ctags executable without any option.

Another options is to place your full command line into counsel-etags-update-tags-backend. Then you take full control of how tags file is generated. Or existing options in counsel-etags is ignored.

srustamo commented 4 years ago

counsel-etags-program should be ctags or full path of ctags executable without any option.

Setting counsel-etags-tags-program to ctags still produces an empty TAGS file. Setting it to a full path c:\\\\ProgramData\\\\chocolatey\\\\bin\\\\ctags.exe also produces an empty TAGS file.

Another options is to place your full command line into counsel-etags-update-tags-backend. Then you take full control of how tags file is generated. Or existing options in counsel-etags is ignored.

Looks like counsel-etags-update-tags-backend expects a function .

Debugger entered--Lisp error: (void-function c:\\\\ProgramData\\\\chocolatey\\\\bin\\\\ctags\.exe)
  c:\\\\ProgramData\\\\chocolatey\\\\bin\\\\ctags\.exe("c:/Users/srstan/GitHub/oauth2-ruby-reference/")
  counsel-etags-scan-dir("c:/Users/srstan/GitHub/oauth2-ruby-reference/")
  counsel-etags-tags-file-must-exist()
  counsel-etags-find-tag-at-point()
  funcall-interactively(counsel-etags-find-tag-at-point)
  call-interactively(counsel-etags-find-tag-at-point record nil)
  command-execute(counsel-etags-find-tag-at-point record)
  counsel-M-x-action("counsel-etags-find-tag-at-point")
  ivy-call()
  ivy-read("M-x " ("toggle-debug-on-error" "counsel-etags-list-tag" "ctags-update" "counsel-etags-recent-tag" "counsel-etags-scan-code" "emacs-version" "dumb-jump-go" "ag-project-at-point" "inf-ruby" "customize-group" "package-list-packages" "swiper-thing-at-point" "customize-face" "git-gutter:next-hunk" "counsel-etags-list-tag-in-current-file" "robe-mode" "ag-project" "org-toodledo-reset" "dired" "menu-bar-mode" "org-toodledo-initialize" "counsel-evil-goto-global-marker" "pwd" "org-version" "org-overview" "git-gutter" "set-variable" "deer" "counsel-ag" "company-robe" "magit-status" "tool-bar-mode" "dumb-jump-mode" "whitespace-mode" "inf-ruby-console-auto" "counsel-etags-update-tags-force" "ag" "imenu" "ranger" "eval-buffer" "company-mode" "golden-ratio" "server-start" "org-tags-view" "git-gutter-mode" "org-export-dispatch" "inf-ruby-console-default" "all-the-icons-install-fonts" "counsel-etags-toggle-auto-update-tags" "compile" ...) :predicate #f(compiled-function (x) #<bytecode 0x23a6829>) :require-match t :history counsel-M-x-history :action counsel-M-x-action :keymap (keymap (67108908 . counsel--info-lookup-symbol) (67108910 . counsel-find-symbol)) :initial-input nil :caller counsel-M-x)
  counsel-M-x()
  funcall-interactively(counsel-M-x)
  call-interactively(counsel-M-x nil nil)
  command-execute(counsel-M-x)
redguardtoo commented 4 years ago

Add directory of ctags to environment variable PATH . See https://www.techjunkie.com/environment-variables-windows-10/

srustamo commented 4 years ago

It is already in the PATH.

PS C:\Users\srstan> $env:PATH
C:\tools\ruby27\bin;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\ProgramData\chocolatey\bin;%USERPROFILE%\AppData\Local\Microsoft\WindowsApps;;C:\Users\srstan\AppData\Local\hyper\app-3.0.2\resources\bin
PS C:\Users\srstan>
srustamo commented 4 years ago

(getenv "PATH") evaluates to:

"C:\\tools\\ruby27\\bin;C:\\Program Files (x86)\\Intel\\iCLS Client\\;C:\\Program Files\\Intel\\iCLS Client\\;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Windows\\System32\\OpenSSH\\;C:\\Program Files\\Git\\cmd;C:\\ProgramData\\chocolatey\\bin;%USERPROFILE%\\AppData\\Local\\Microsoft\\WindowsApps;;C:\\Users\\srstan\\AppData\\Local\\hyper\\app-3.0.2\\resources\\bin"
srustamo commented 4 years ago

I mentioned earlier that (ctags-update) function works correctly. ctags-update-command var evaluates to:

ctags-update-command is a variable defined in ‘ctags-update.el’.
Its value is "ctags"

  This variable may be risky if used as a file-local variable.

Documentation:
it only support ‘exuberant-ctags’
take care it is not the ctags in ‘emacs-VERSION/bin/’
you should download ‘exuberant-ctags’ and make sure
the ctags is under $PATH before ‘emacs-VERSION/bin/’

You can customize this variable.

[back]
srustamo commented 4 years ago

it is part of the ctags-update package.

c:/Users/srstan/AppData/Roaming/rush-emacs/elpa/ctags-update-20190609.613/ctags-update.el
redguardtoo commented 4 years ago

Maybe there is some conflicts in ctags-update. counsel-etags will generate TAGS if it does not exist. But before generation, it will ask you to input the root directory.

Please use counsel-etags-find-tag-at-point or counsel-etags-scan-code for the first time.

You can let counsel-etags to update TAGS automatically if TAGS already exists, see https://github.com/redguardtoo/counsel-etags#auto-update-tags-file

redguardtoo commented 4 years ago

BTW, what's the value of (executable-find (counsel-etags-guess-program "find"))?

redguardtoo commented 4 years ago

see 6a70166 avoid windows bundled find (Chen Bin)

srustamo commented 4 years ago

BTW, what's the value of (executable-find (counsel-etags-guess-program "find"))?

"c:/Windows/system32/find.exe"

redguardtoo commented 4 years ago

Check my latest code. should be fixed now.

srustamo commented 4 years ago

Thanks.