Index: ada-mode/ada-gnat-xref.el ================================================================== --- ada-mode/ada-gnat-xref.el +++ ada-mode/ada-gnat-xref.el @@ -137,19 +137,27 @@ (nth 2 result) nil ;; other-window ) )) -(defun ada-gnat-xref-all (identifier file line col) +(defcustom ada-gnat-xref-full-path nil + "If t, cross-references show the full path to source files; if +nil, only the file name." + :type 'boolean + :safe #'booleanp + :group 'ada) + +(defun ada-gnat-xref-all (identifier file line col local-only) "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* ((cmd (format "%sgnat find -a -r %s:%s:%d:%d" - (or (ada-prj-get 'target) "") - identifier file line col))) + (let* ((cmd (format "%sgnat find -a -r %s %s:%s:%d:%d %s" + (or (ada-prj-get 'target) "") + (if ada-gnat-xref-full-path "-f" "") + identifier file line col (if local-only file "")))) (with-current-buffer (gnat-run-buffer); for default-directory (let ((compilation-environment (ada-prj-get 'proc_env)) (compilation-error "reference") ;; gnat find uses standard gnu format for output, so don't @@ -158,11 +166,11 @@ (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) (concat name "-gnatfind"))) + (lambda (name) (concat "*" name "-gnatfind*"))) )))) ;;;;; setup (defun ada-gnat-xref-select-prj () Index: ada-mode/ada-mode.el ================================================================== --- ada-mode/ada-mode.el +++ ada-mode/ada-mode.el @@ -350,10 +350,11 @@ (define-key map "\C-c\C-d" 'ada-goto-declaration) (define-key map "\C-c\M-d" 'ada-show-declaration-parents) (define-key map "\C-c\C-e" 'ada-expand) (define-key map "\C-c\C-f" 'ada-show-parse-error) (define-key map "\C-c\C-i" 'ada-indent-statement) + (define-key map "\C-c\C-l" 'ada-show-local-references) (define-key map "\C-c\C-m" 'ada-build-set-make) (define-key map "\C-c\C-n" 'ada-next-statement-keyword) (define-key map "\C-c\M-n" 'ada-next-placeholder) (define-key map "\C-c\C-o" 'ada-find-other-file) (define-key map "\C-c\M-o" 'ada-find-other-file-noset) @@ -2303,10 +2304,12 @@ Called with four arguments: - an Ada identifier or operator_symbol - filename containing the identifier - line number containing the identifier - column of the start of the identifier +- local-only, a boolean specifying whether or not to restrict + the searches to the current file Displays a buffer in compilation-mode giving locations where the identifier is declared or referenced.") (defun ada-show-references () "Show all references of identifier at point." @@ -2318,11 +2321,28 @@ (funcall ada-xref-all-function (ada-identifier-at-point) (file-name-nondirectory (buffer-file-name)) (line-number-at-pos) - (1+ (current-column))) + (1+ (current-column)) + nil) + ) + +(defun ada-show-local-references () + "Show local references of identifier at point." + (interactive) + (ada-check-current-project (buffer-file-name)) + + (when (null ada-xref-all-function) + (error "no cross reference information available")) + + (funcall ada-xref-all-function + (ada-identifier-at-point) + (file-name-nondirectory (buffer-file-name)) + (line-number-at-pos) + (1+ (current-column)) + t) ) (defvar ada-xref-overriding-function nil ;; determined by ada-xref-tool, set by *-select-prj "Function that displays cross reference information for overriding subprograms.