greghendershott / racket-mode

Emacs major and minor modes for Racket: edit, REPL, check-syntax, debug, profile, and more.

Home Page:https://www.racket-mode.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

XREF can not find references inside Scribblings

xgqt opened this issue · comments

Description

When running xref-find-references references are found in many files but not in .scrbl files.
On the other hand, when calling xref-find-definitions on a function name (in defproc) inside a .scrbl file the definition is correctly pointed to the source.

Showcase

image

Debug info

((alist-get 'racket-mode package-alist))
((emacs-version "28.2")
 (system-type gnu/linux)
 (x-gtk-use-system-tooltips t)
 (major-mode xref--xref-buffer-mode)
 (racket--el-source-dir "/usr/share/emacs/site-lisp/racket-mode/")
 (racket--rkt-source-dir "/usr/share/emacs/etc/racket-mode/racket/")
 (racket-program "racket")
 (racket-command-timeout 10)
 (racket-path-from-emacs-to-racket-function UNDEFINED)
 (racket-path-from-racket-to-emacs-function UNDEFINED)
 (racket-browse-url-function racket-browse-url-using-temporary-file)
 (racket-documentation-search-location "https://docs.racket-lang.org/search/index.html?q=%s")
 (racket-xp-after-change-refresh-delay 1)
 (racket-xp-mode-lighter
  (:eval
   (racket--xp-mode-lighter)))
 (racket-xp-highlight-unused-regexp "^[^_]")
 (racket-repl-buffer-name-function nil)
 (racket-submodules-to-run
  ((test)
   (main)))
 (racket-memory-limit 2048)
 (racket-error-context medium)
 (racket-repl-history-directory "~/.config/emacs/racket-mode/")
 (racket-history-filter-regexp "\\`\\s *\\'")
 (racket-images-inline t)
 (racket-imagemagick-props nil)
 (racket-images-keep-last 100)
 (racket-images-system-viewer "display")
 (racket-pretty-print t)
 (racket-use-repl-submit-predicate nil)
 (racket-pretty-print t)
 (racket-indent-curly-as-sequence t)
 (racket-indent-sequence-depth 0)
 (racket-pretty-lambda nil)
 (racket-smart-open-bracket-enable nil)
 (racket-module-forms "\\s(\\(?:module[*+]?\\|library\\)")
 (racket-logger-config
  ((cm-accomplice . warning)
   (GC . info)
   (module-prefetch . warning)
   (optimizer . info)
   (racket/contract . error)
   (racket-mode-debugger . info)
   (sequence-specialization . info)
   (* . warning)))
 (racket-show-functions
  (racket-show-echo-area)))
(enabled-minor-modes
 (all-the-icons-ivy-rich-mode)
 (amx-mode)
 (auto-composition-mode)
 (auto-compression-mode)
 (auto-encryption-mode)
 (auto-fill-mode)
 (auto-save-mode)
 (better-splits-mode)
 (blink-cursor-mode)
 (buffer-read-only)
 (column-number-mode)
 (company-mode)
 (display-time-mode)
 (editorconfig-mode)
 (electric-indent-mode)
 (electric-pair-mode)
 (emojify-mode)
 (file-name-shadow-mode)
 (font-lock-mode)
 (global-auto-revert-mode)
 (global-company-mode)
 (global-eldoc-mode)
 (global-emojify-mode)
 (global-font-lock-mode)
 (global-hl-line-mode)
 (global-undo-tree-mode)
 (hi-lock-mode)
 (ivy-mode)
 (ivy-rich-mode)
 (line-number-mode)
 (menu-bar-mode)
 (mouse-wheel-mode)
 (override-global-mode)
 (projectile-mode)
 (semantic-minor-modes-format)
 (shell-dirtrack-mode)
 (show-paren-mode)
 (size-indication-mode)
 (tooltip-mode)
 (transient-mark-mode)
 (undo-tree-mode)
 (which-key-mode))
(disabled-minor-modes
 (abbrev-mode)
 (all-the-icons-dired-mode)
 (amx-debug-mode)
 (archive-subfile-mode)
 (auto-fill-function)
 (auto-revert-mode)
 (auto-revert-tail-mode)
 (auto-save-visited-mode)
 (buffer-face-mode)
 (button-mode)
 (cl-old-struct-compat-mode)
 (company-search-mode)
 (compilation-minor-mode)
 (compilation-shell-minor-mode)
 (completion-in-region-mode)
 (context-menu-mode)
 (counsel-mode)
 (dash-fontify-mode)
 (defining-kbd-macro)
 (delete-selection-mode)
 (diff-auto-refine-mode)
 (diff-hl-dir-mode)
 (diff-hl-dired-mode)
 (diff-hl-inline-popup-transient-mode)
 (diff-hl-mode)
 (diff-hl-show-hunk-mouse-mode)
 (diff-minor-mode)
 (dired-hide-details-mode)
 (dired-isearch-filenames-mode)
 (display-fill-column-indicator-mode)
 (display-line-numbers-mode)
 (ebuild-repo-mode)
 (eldoc-mode)
 (electric-layout-mode)
 (electric-quote-mode)
 (emojify-debug-mode)
 (emojify-mode-line-mode)
 (flycheck-mode)
 (flyspell-mode)
 (geiser-autodoc-mode)
 (geiser-smart-tab-mode)
 (global-dash-fontify-mode)
 (global-diff-hl-mode)
 (global-diff-hl-show-hunk-mouse-mode)
 (global-display-fill-column-indicator-mode)
 (global-display-line-numbers-mode)
 (global-emojify-mode-line-mode)
 (global-flycheck-mode)
 (global-goto-address-mode)
 (global-hi-lock-mode)
 (global-prettify-symbols-mode)
 (global-semantic-highlight-edits-mode)
 (global-semantic-highlight-func-mode)
 (global-semantic-show-parser-state-mode)
 (global-semantic-show-unmatched-syntax-mode)
 (global-semantic-stickyfunc-mode)
 (global-subword-mode)
 (global-superword-mode)
 (global-visual-line-mode)
 (global-whitespace-mode)
 (global-whitespace-newline-mode)
 (goto-address-mode)
 (goto-address-prog-mode)
 (highlight-indentation-current-column-mode)
 (highlight-indentation-mode)
 (hl-line-mode)
 (horizontal-scroll-bar-mode)
 (hs-minor-mode)
 (ibuffer-auto-mode)
 (idle-highlight-visible-mode)
 (indent-tabs-mode)
 (isearch-mode)
 (ispell-minor-mode)
 (ivy-rich-project-root-cache-mode)
 (jit-lock-debug-mode)
 (lock-file-mode)
 (next-error-follow-minor-mode)
 (org-cdlatex-mode)
 (org-list-checkbox-radio-mode)
 (org-src-mode)
 (org-table-follow-field-mode)
 (org-table-header-line-mode)
 (orgtbl-mode)
 (outline-minor-mode)
 (overwrite-mode)
 (paragraph-indent-minor-mode)
 (prettify-symbols-mode)
 (racket-smart-open-bracket-mode)
 (racket-xp-mode)
 (rainbow-delimiters-mode)
 (recentf-mode)
 (semantic-highlight-edits-mode)
 (semantic-highlight-func-mode)
 (semantic-mode)
 (semantic-show-parser-state-mode)
 (semantic-show-unmatched-syntax-mode)
 (semantic-stickyfunc-mode)
 (server-mode)
 (sh-electric-here-document-mode)
 (subword-mode)
 (superword-mode)
 (tab-bar-history-mode)
 (tab-bar-mode)
 (tar-subfile-mode)
 (temp-buffer-resize-mode)
 (text-scale-mode)
 (tool-bar-mode)
 (transient-resume-mode)
 (undo-tree-visualizer-selection-mode)
 (unify-8859-on-decoding-mode)
 (unify-8859-on-encoding-mode)
 (url-handler-mode)
 (use-hard-newlines)
 (vc-parent-buffer)
 (view-mode)
 (visible-mode)
 (visual-line-mode)
 (whitespace-mode)
 (whitespace-newline-mode)
 (window-divider-mode)
 (xref-etags-mode)
 (yas-global-mode)
 (yas-minor-mode))

I played around this a little and found out that only renaming .scrbl to .rkt finds the references correctly.

Now that I think of it I recall racket-mode was not very focused on supporting scribble.
Is there a way to also find refs in files not ending with .rkt?

This is a quick reply, nothing tested, but:

IIRC the default implementation of xref-find-references uses the value of auto-mode-alist.

So I think it will work as you want if you add to your config something like (add-to-list 'auto-mode-alist '("\\.scrbl\\'" . racket-mode)).

[Note this means that visiting .scrbl files will use racket-mode, too. Maybe you don't want that because you prefer scribble-mode, and already have an item in auto-mode-alist configured for that. If so, it might still work if you append to the list: (add-to-list 'auto-mode-alist '("\\.scrbl\\'" . racket-mode) t). My guess/hope is that visiting will use the first entry (for scribble-mode) but that xref-find-references will look at all of them... maybe?]

Does any of that help?

IIRC the default implementation of xref-find-references uses the value of auto-mode-alist.
So I think it will work as you want if you add to your config something like (add-to-list 'auto-mode-alist '("\.scrbl\'" . racket-mode)).

You are correct!
I had a binding to a custom function, so changing it to ("\\.scrbl\\'" . racket-mode) fixed this issue.