Index: ada-mode/ada-gnat-xref.el ================================================================== --- ada-mode/ada-gnat-xref.el +++ ada-mode/ada-gnat-xref.el @@ -74,19 +74,22 @@ (defun ada-gnat-xref-other (identifier file line col) "For `ada-xref-other-function', using `gnat find', which is Ada-specific." (setq col (ada-gnat-xref-adj-col identifier col)) (let* ((file-non-dir (file-name-nondirectory file)) - (arg (format "%s:%s:%d:%d" identifier file-non-dir line col)) - (switches (concat - "-a" - (when (ada-prj-get 'gpr_ext) (concat "--ext=" (ada-prj-get 'gpr_ext))))) - (dirs (when (ada-prj-get 'obj_dir) - (concat "-aO" (mapconcat 'identity (ada-prj-get 'obj_dir) ":")))) + (cmd (format "%sgnatfind" (or (ada-prj-get 'target) ""))) + (arg (list + "-a" + (when (ada-prj-get 'gpr_ext) (concat "--ext=" (ada-prj-get 'gpr_ext))) + (when (ada-prj-get 'gpr_file) + (concat "-p" (file-name-nondirectory (ada-prj-get 'gpr_file)))) + (when (ada-prj-get 'obj_dir) + (concat "-aO" (mapconcat 'identity (ada-prj-get 'obj_dir) ":"))) + (format "%s:%s:%d:%d" identifier file-non-dir line col))) (result nil)) (with-current-buffer (gnat-run-buffer) - (gnat-run-gnat "find" (list switches dirs arg)) + (gnat-run cmd arg) (goto-char (point-min)) (forward-line 2); skip ADA_PROJECT_PATH, 'gnat find' ;; gnat find returns two items; the starting point, and the 'other' point @@ -119,21 +122,24 @@ result)) (defun ada-gnat-xref-parents (identifier file line col) "For `ada-xref-parents-function', using `gnat find', which is Ada-specific." - (let* ((arg (format "%s:%s:%d:%d" identifier file line (ada-gnat-xref-adj-col identifier col))) - (switches (list - "-a" - "-d" - (when (ada-prj-get 'gpr_ext) (concat "--ext=" (ada-prj-get 'gpr_ext))) - )) - (dirs (when (ada-prj-get 'obj_dir) - (concat "-aO" (mapconcat 'identity (ada-prj-get 'obj_dir) ":")))) + (let* ((cmd (format "%sgnatfind" (or (ada-prj-get 'target) ""))) + (arg (list + "-a" + "-d" + (when (ada-prj-get 'gpr_ext) (concat "--ext=" (ada-prj-get 'gpr_ext))) + (when (ada-prj-get 'gpr_file) + (concat "-p" (file-name-nondirectory (ada-prj-get 'gpr_file)))) + (when (ada-prj-get 'obj_dir) + (concat "-aO" (mapconcat 'identity (ada-prj-get 'obj_dir) ":"))) + (format "%s:%s:%d:%d" + identifier file line (ada-gnat-xref-adj-col identifier col)))) (result nil)) (with-current-buffer (gnat-run-buffer) - (gnat-run-gnat "find" (append switches (list dirs arg))) + (gnat-run cmd arg) (goto-char (point-min)) (forward-line 2); skip GPR_PROJECT_PATH, 'gnat find' ;; gnat find returns two items; the starting point, and the 'other' point @@ -171,35 +177,35 @@ "For `ada-xref-all-function'." ;; we use `compilation-start' to run gnat, not `gnat-run', so it ;; is asynchronous, and automatically runs the compilation error ;; filter. - (let* ((dirs (when (ada-prj-get 'obj_dir) - (concat "-aO" (mapconcat 'identity (ada-prj-get 'obj_dir) ":")))) - (project-file (when (ada-prj-get 'gpr_file) - (concat " -P" (file-name-nondirectory (ada-prj-get 'gpr_file))))) - (cmd (format "%sgnat find -a -r %s %s %s:%s:%d:%d %s %s" - (or (ada-prj-get 'target) "") - (if ada-xref-full-path "-f" "") - dirs identifier file line (ada-gnat-xref-adj-col identifier col) - project-file (if local-only file "")))) + (let* ((cmd-args (list + (format "%sgnatfind" (or (ada-prj-get 'target) "")) + "-a" + "-r" + (when ada-xref-full-path "-f") + (when (ada-prj-get 'gpr_file) + (concat "-p" (file-name-nondirectory (ada-prj-get 'gpr_file)))) + (when (ada-prj-get 'obj_dir) + (concat "-aO" (mapconcat 'identity (ada-prj-get 'obj_dir) ":"))) + (format "%s:%s:%d:%d" + identifier file line (ada-gnat-xref-adj-col identifier col)) + (when local-only file)))) (with-current-buffer (gnat-run-buffer); for default-directory - (let ((compilation-buffer-name "*compilation-gnatfind*") - (compilation-error "reference") + (let ((compilation-buffer-name "*gnatfind*") + (compilation-error "reference") ;; gnat find uses standard gnu format for output, so don't ;; need to set compilation-error-regexp-alist ) ;; compilation-environment is buffer-local; don't set in 'let' (setq compilation-environment (ada-prj-get 'proc_env)) - (when (ada-prj-get 'gpr_file) - (setq cmd (concat cmd " -P" (file-name-nondirectory (ada-prj-get 'gpr_file))))) - - (compilation-start cmd - 'compilation-mode - (lambda (_name) compilation-buffer-name)) + (compilation-start (mapconcat (lambda (a) (or a "")) cmd-args " ") + 'compilation-mode + (lambda (_name) compilation-buffer-name)) )))) ;;;;; setup (defun ada-gnat-xref-select-prj ()