raullaasner / fortran-tags

Emacs plugin for source code indexing of modern Fortran
GNU General Public License v3.0
18 stars 2 forks source link

fortran-find-tag yields (wrong-type-argument stringp nil) #11

Closed M0M097 closed 1 year ago

M0M097 commented 1 year ago

I installed fortran-tags and sucessfully generated FORTAGS file (attached with an .txt extension) with fortran-tags.py -g test.f90. Content of test.f90 is

program test
    implicit none
    integer :: i

    i = 4
    print *, i

end program test

if I now place my curser over the i in print *, i I get the following error:

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  string-to-number(nil)
  (goto-line (string-to-number line))
  goto-new-position("LC_ALL=C:" nil nil)
  (let ((words (split-string match))) (goto-new-position (nth 0 words) (nth 4 words) (nth 5 words)) (throw 'found nil))
  (if (not (string= "" match)) (let ((words (split-string match))) (goto-new-position (nth 0 words) (nth 4 words) (nth 5 words)) (throw 'found nil)))
  (while (> i 0) (setq scope ":") (setq j (1- i)) (while (> j 0) (setq scope (concat ":" (nth j scopes) scope)) (setq j (1- j))) (setq match (fortran-tags-shell-command (concat "LC_ALL=C fgrep -m 1 \" " WORD " " scope " \" " fortran-tags-path))) (if (not (string= "" match)) (let ((words (split-string match))) (goto-new-position (nth 0 words) (nth 4 words) (nth 5 words)) (throw 'found nil))) (setq i (1- i)))
  (progn (setq i (1- (length scopes))) (while (> i 0) (setq scope ":") (setq j (1- i)) (while (> j 0) (setq scope (concat ":" (nth j scopes) scope)) (setq j (1- j))) (setq match (fortran-tags-shell-command (concat "LC_ALL=C fgrep -m 1 \" " WORD " " scope " \" " fortran-tags-path))) (if (not (string= "" match)) (let ((words (split-string match))) (goto-new-position (nth 0 words) (nth 4 words) (nth 5 words)) (throw 'found nil))) (setq i (1- i))))
  (if (not force-global) (progn (setq i (1- (length scopes))) (while (> i 0) (setq scope ":") (setq j (1- i)) (while (> j 0) (setq scope (concat ":" (nth j scopes) scope)) (setq j (1- j))) (setq match (fortran-tags-shell-command (concat "LC_ALL=C fgrep -m 1 \" " WORD " " scope " \" " fortran-tags-path))) (if (not (string= "" match)) (let ((words (split-string match))) (goto-new-position (nth 0 words) (nth 4 words) (nth 5 words)) (throw 'found nil))) (setq i (1- i)))))
  (catch 'found (if (not force-global) (progn (setq i (1- (length scopes))) (while (> i 0) (setq scope ":") (setq j (1- i)) (while (> j 0) (setq scope (concat ":" (nth j scopes) scope)) (setq j (1- j))) (setq match (fortran-tags-shell-command (concat "LC_ALL=C fgrep -m 1 \" " WORD " " scope " \" " fortran-tags-path))) (if (not (string= "" match)) (let ((words ...)) (goto-new-position (nth 0 words) (nth 4 words) (nth 5 words)) (throw 'found nil))) (setq i (1- i))))) (setq match (split-string (fortran-tags-shell-command (concat "LC_ALL=C fgrep \" 0 " WORD " :\" " fortran-tags-path)) "\n")) (if (not (string= "" (nth 0 match))) (progn (let ((--dolist-tail-- (delete "" match)) line) (while --dolist-tail-- (setq line (car --dolist-tail--)) (let ((words ...)) (setq alt-positions (append alt-positions ...))) (setq --dolist-tail-- (cdr --dolist-tail--)))) (setq alt-positions-counter 0) (fortran-goto-next) (message (concat (number-to-string (length alt-positions)) " found")) (throw 'found nil))) (message "Definition not found"))
  (let ((WORD (fortran-word-at-point t)) scope scopes match i j) (setq alt-positions (list)) (fortran-find-scope) (if (string= cur-scope "\n") (setq cur-scope ":fortags_program_scope:")) (setq scopes (split-string cur-scope ":")) (catch 'found (if (not force-global) (progn (setq i (1- (length scopes))) (while (> i 0) (setq scope ":") (setq j (1- i)) (while (> j 0) (setq scope (concat ":" ... scope)) (setq j (1- j))) (setq match (fortran-tags-shell-command (concat "LC_ALL=C fgrep -m 1 \" " WORD " " scope " \" " fortran-tags-path))) (if (not (string= "" match)) (let (...) (goto-new-position ... ... ...) (throw ... nil))) (setq i (1- i))))) (setq match (split-string (fortran-tags-shell-command (concat "LC_ALL=C fgrep \" 0 " WORD " :\" " fortran-tags-path)) "\n")) (if (not (string= "" (nth 0 match))) (progn (let ((--dolist-tail-- (delete "" match)) line) (while --dolist-tail-- (setq line (car --dolist-tail--)) (let (...) (setq alt-positions ...)) (setq --dolist-tail-- (cdr --dolist-tail--)))) (setq alt-positions-counter 0) (fortran-goto-next) (message (concat (number-to-string (length alt-positions)) " found")) (throw 'found nil))) (message "Definition not found")))
  fortran-find-tag()
  funcall-interactively(fortran-find-tag)
  call-interactively(fortran-find-tag record nil)
  command-execute(fortran-find-tag record)
  execute-extended-command(nil "fortran-find-tag" nil)
  funcall-interactively(execute-extended-command nil "fortran-find-tag" nil)
  call-interactively(execute-extended-command nil nil)
  command-execute(execute-extended-command)

Afterwards I find myself in a Buffer called LC_ALL=C: This happens for every statement in all fortran projects. Emacs version is GNU Emacs 27.2 and I use doom emacs.

FORTAGS.txt

raullaasner commented 1 year ago

Thanks for the notice! I just tested it and indeed it was broken for all Fortran statements. The reason seemed to be that calling fgrep from fortran-tags.el produced more output than before (there is now a warning a about fgrep being obsolescent and how I should use grep -F instead). Anyway, I implemented a fix and for me at least it works fine now. See the latest commit and let me know if you still run into errors.

M0M097 commented 1 year ago

I still have the same issue, but I think I found what is causing it: the SHELL variable set to a non-posix shell. I'm a (t)csh user, and as long as SHELL is set to tcsh I get this error, if I set SHELL to bash I don't get the error even if I execute emacs from a terminal running tcsh

raullaasner commented 1 year ago

Okay, glad to know you found a solution! Indeed, currently only bash is supported.