Ergus / gtags-mode

Gnu Global integration for emacs as simple as possible with TRAMP support.
14 stars 7 forks source link

Switching between a non gtags project into a gtags project results in an error message (wrong-type-argument stringp nil) #5

Closed Liorst4 closed 3 months ago

Liorst4 commented 5 months ago

Steps to reproduce:

After the error occurs, switching to the *Messages* buffer reveals a "GTAGS not found" error message. I believe the issue comes from calling the global executable not in the project directory.

When calling project-switch-project and choosing the f option it calls project-find-file-in https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/progmodes/project.el?h=emacs-29.1#n1731 https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/progmodes/project.el?h=emacs-29.1#n1084

This calls to the override of project-files, which executes global --path-style=through --path https://github.com/Ergus/gtags-mode/blob/681f210eeedb11234ceea206509185051ea0a5c0/gtags-mode.el#L314C15-L326

If I'm correct, setting default-directory with a let to (project-root) before executing could fix the issue.

Ergus commented 3 months ago

Hi @Liorst4:

Very thanks for the detailed report. Certainly this command was something I have never tried before. But following your steps I could reproduce the issue and got this backtrace:

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  (project--read-file-cpd-relative "Find file" nil nil file-name-history #("/" 0 1 (face font-lock-comment-delimiter-face c-in-sws t c-is-sws t fontified t)))
  (project--read-file-name (:gtagsroot "/home/ergus/algorithms" :cache nil) "Find file" nil nil file-name-history #("/" 0 1 (face font-lock-comment-delimiter-face c-in-sws t c-is-sws t fontified t)))
  (project-find-file-in #("/" 0 1 (face font-lock-comment-delimiter-face c-in-sws t c-is-sws t fontified t)) ("/home/ergus/algorithms") (:gtagsroot "/home/ergus/algorithms/algorithms" :cache nil) nil)
  (project-find-file nil)
  (funcall-interactively project-find-file nil)
  (project-switch-project "~/algorithms/")
  (funcall-interactively project-switch-project "~/algorithms/")
  (call-interactively project-switch-project record nil)
  (command-execute project-switch-project record)
  (execute-extended-command nil "project-switch-project" nil)
  (funcall-interactively execute-extended-command nil "project-switch-project" nil)
  (call-interactively execute-extended-command nil nil)
  (command-execute execute-extended-command)

I will attempt to fix it when I have some time.

Ergus commented 3 months ago

Please test it now, thanks

Liorst4 commented 3 months ago

Please test it now, thanks

Updated to version 1.1 from the gnu elpa, works perfectly, thanks :)