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

Identifiers with @ in racket-xp-mode

soegaard opened this issue · comments

I just noticed, that when I am in racket-xp-mode and uses option-. to jump to the definition
of the identifier pt@d it jumps to the definition of pt instead.

This might be in order to make option-. work in with Scribble and files that use at-mode|
if so, just stick to the current behaviour.

Package

metadata
(#s(package-desc racket-mode
                 (20240130 2013)
                 "Racket editing, REPL, and more"
                 ((emacs
                   (25 1)))
                 nil nil "/Users/soegaard/.emacs.d/elpa/racket-mode-20240130.2013"
                 ((:url . "https://www.racket-mode.com/")
                  (:maintainer "Greg Hendershott")
                  (:maintainers
                   ("Greg Hendershott"))
                  (:authors
                   ("Greg Hendershott" . "racket-mode-author@greghendershott.com"))
                  (:commit . "d3ab936af10909874443cadb2e6c952faf2f536f"))
                 nil))
package-archives
(("gnu" . "https://elpa.gnu.org/packages/")
 ("melpa" . "https://melpa.org/packages/"))
racket--el-source-dir
"/Users/soegaard/.emacs.d/elpa/racket-mode-20240130.2013/"
racket--rkt-source-dir
"/Users/soegaard/.emacs.d/elpa/racket-mode-20240130.2013/racket/"

System values

emacs-version
"27.2"
major-mode
racket-mode
system-type
darwin
display-graphic-p
t

Buffer values

after-change-functions
(jit-lock-after-change t racket--xp-after-change-hook)
before-change-functions
(t syntax-ppss-flush-cache)
completion-at-point-functions
(racket-xp-complete-at-point)
eldoc-documentation-function
nil
font-lock-defaults
((racket-font-lock-keywords-level-0 racket-font-lock-keywords-level-1 racket-font-lock-keywords-level-2 racket-font-lock-keywords-level-3)
 nil nil nil nil
 (font-lock-mark-block-function . mark-defun)
 (parse-sexp-lookup-properties . t)
 (font-lock-multiline . t)
 (font-lock-syntactic-face-function . racket-font-lock-syntactic-face-function)
 (font-lock-extend-region-functions font-lock-extend-region-wholelines font-lock-extend-region-multiline))
pre-command-hook
(delete-selection-pre-hook)
post-command-hook
(jit-lock--antiblink-post-command t)
post-self-insert-hook
(electric-indent-post-self-insert-function blink-paren-post-self-insert-function)
xref-backend-functions
(racket-xp-xref-backend-function racket-mode-xref-backend-function t)

Racket Mode values

racket--cmd-open-p
t
racket-after-run-hook
nil
racket-back-end-configurations
((:directory "/" :racket-program nil :remote-source-dir nil :restart-watch-directories nil :windows nil))
racket-before-run-hook
(racket-ansi-color-context-reset)
racket-browse-url-function
racket-browse-url-using-temporary-file
racket-command-timeout
10
racket-documentation-search-location
"https://docs.racket-lang.org/search/index.html?q=%s"
racket-error-context
medium
racket-expand-hiding
standard
racket-hash-lang-mode-hook
nil
racket-hash-lang-module-language-hook
nil
racket-hash-lang-token-face-alist
((constant . font-lock-constant-face)
 (error . error)
 (other . font-lock-doc-face)
 (keyword . font-lock-keyword-face)
 (hash-colon-keyword . racket-keyword-argument-face)
 (at . font-lock-doc-face))
racket-history-filter-regexp
"\\`\\s *\\'"
racket-imagemagick-props
nil
racket-images-inline
t
racket-images-keep-last
100
racket-images-system-viewer
"open"
racket-indent-curly-as-sequence
t
racket-indent-sequence-depth
0
racket-logger-config
((cm-accomplice . warning)
 (GC . info)
 (module-prefetch . warning)
 (optimizer . info)
 (racket/contract . error)
 (racket-mode-debugger . info)
 (sequence-specialization . info)
 (* . fatal))
racket-memory-limit
2048
racket-mode-hook
(racket-unicode-input-method-enable
 (lambda nil
   (define-key racket-mode-map
     (kbd "M-")
     #'backward-sexp)
   (define-key racket-mode-map
     (kbd "M-")
     #'forward-sexp)
   (define-key racket-mode-map
     (kbd "s-r")
     #'my-racket-run-from-editor)
   (define-key racket-mode-map
     (kbd "s-e")
     #'racket-run-and-switch-to-repl)
   (define-key racket-mode-map
     (kbd "s-d")
     #'my-racket-switch-from-editor-to-repl)
   (define-key racket-mode-map
     (kbd "s-i")
     #'my-racket-indent-whole-buffer)
   (define-key racket-mode-map
     (kbd "s-")
     #'move-beginning-of-line)
   (define-key racket-mode-map
     (kbd "s-")
     #'move-end-of-line)
   (define-key racket-mode-map
     (kbd "s-")
     #'scroll-up-command)
   (show-paren-mode)))
racket-module-forms
"\\s(\\(?:module[*+]?\\|library\\)"
racket-pretty-lambda
nil
racket-pretty-print
t
racket-program
"/Applications/Racket v8.12/bin/racket"
racket-repl-buffer-name-function
nil
racket-repl-command-file
"/Users/soegaard/.emacs.d/racket-mode/repl.rkt"
racket-repl-history-directory
"~/.emacs.d/racket-mode/"
racket-repl-mode-hook
(racket-unicode-input-method-enable
 (lambda nil
   (define-key racket-repl-mode-map
     (kbd "s-e")
     #'my-racket-switch-from-repl-to-editor)
   (define-key racket-repl-mode-map
     (kbd "s-d")
     #'delete-other-windows)))
racket-sexp-comment-fade
0.5
racket-shell-or-terminal-function
racket-shell
racket-show-functions
(racket-show-pseudo-tooltip)
racket-smart-open-bracket-enable
nil
racket-submodules-to-run
((test)
 (main))
racket-use-repl-submit-predicate
nil
racket-xp-add-binding-faces
nil
racket-xp-after-change-refresh-delay
1
racket-xp-highlight-unused-regexp
"^[^_]"
racket-xp-mode-lighter
(:eval
 (racket--xp-mode-lighter))

Minor modes

enabled
((auto-composition-mode)
 (auto-compression-mode)
 (auto-encryption-mode)
 (column-number-mode)
 (delete-selection-mode)
 (electric-indent-mode)
 (file-name-shadow-mode)
 (font-lock-mode)
 (global-eldoc-mode)
 (global-font-lock-mode)
 (menu-bar-mode)
 (mouse-wheel-mode)
 (racket-xp-mode)
 (semantic-minor-modes-format)
 (shell-dirtrack-mode)
 (show-paren-mode)
 (transient-mark-mode))
Disabled minor modes
disabled
((abbrev-mode)
 (auto-fill-function)
 (auto-fill-mode)
 (auto-save-mode)
 (auto-save-visited-mode)
 (blink-cursor-mode)
 (buffer-face-mode)
 (buffer-read-only)
 (cl-old-struct-compat-mode)
 (compilation-minor-mode)
 (compilation-shell-minor-mode)
 (completion-in-region-mode)
 (defining-kbd-macro)
 (diff-auto-refine-mode)
 (diff-minor-mode)
 (dired-hide-details-mode)
 (eldoc-mode)
 (electric-layout-mode)
 (electric-pair-mode)
 (electric-quote-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-visual-line-mode)
 (horizontal-scroll-bar-mode)
 (hs-minor-mode)
 (isearch-mode)
 (jit-lock-debug-mode)
 (line-number-mode)
 (next-error-follow-minor-mode)
 (overwrite-mode)
 (paragraph-indent-minor-mode)
 (prettify-symbols-mode)
 (racket-hash-lang-repl-mode)
 (racket-smart-open-bracket-mode)
 (semantic-highlight-edits-mode)
 (semantic-highlight-func-mode)
 (semantic-mode)
 (semantic-show-parser-state-mode)
 (semantic-show-unmatched-syntax-mode)
 (semantic-stickyfunc-mode)
 (sh-electric-here-document-mode)
 (size-indication-mode)
 (tab-bar-history-mode)
 (tab-bar-mode)
 (temp-buffer-resize-mode)
 (text-scale-mode)
 (tool-bar-mode)
 (tooltip-mode)
 (unify-8859-on-decoding-mode)
 (unify-8859-on-encoding-mode)
 (url-handler-mode)
 (use-hard-newlines)
 (view-mode)
 (visible-mode)
 (visual-line-mode)
 (window-divider-mode)
 (xref-etags-mode))

Thanks for the report! Alas, I can't seem to reproduce this, yet.

Given issue-699.rkt:

#lang racket/base
(define pt 12)
(define pt@x 13)
pt
pt@x
(require "issue-699-2.rkt")
pt@y

and issue-699-2.rkt:

#lang racket/base
(define pt@y 14)
(provide pt@y)

In issue-699.rkt:

  1. When I put point at the start of the use of pt@x on line 5, and do M-., it goes to the definition of pt@x on line 3. (This works because there's a racket-xp-use text property pointing there.)

  2. When I put point at the start of the use of pt@y on line 7, and do M-., it goes to the definition of pt@y on line 2 of the other file, issue-699-2.rkt. (This works because there's a racket-xp-visit text property pointing there.)

Both seem correct, and unlike what you report.

  • What results do you get with my example?
  • Do you have some other small example where you see the problem?

p.s. I don't love how the coloring of pt@x is different for pt and @x, and will look at that, but I think that's a distinct thing.

Hi,

I am embarrassed to admit I can't reproduce the behaviour either.

Your example works as expected.

And so does my attempts to reproduce the error.

Both

#lang racket
(require metapict)
pt@d

and

#lang at-exp racket
(require metapict)
pt@d

work.

Let's close this issue - if I see it again, I'll reopen it.

Trying to think of ways this could go wrong (maybe you encountered):

If you do C-u M-., the C-u prefix meaning "prompt me for the symbol", it will propose a default that is just pt -- not pt@x. But you can still type pt@x, and it will find it (although this pass is potentially less reliable).

Although maybe not a huge defect, I think I see how I could improve that.

I played with your example:

#lang racket/base
(define pt 12)
(define pt@x 13)
pt
pt@x
(require "issue-699-2.rkt")
pt@y

First, I run the file.

If I now use cmd-. on pt@y I am sent to as expected to "issue-699-2.rkt".

Now, if I insert a space, to change pt@y to pt @y and then use cmd-. on pt,
then I am still sent to "issue-699-2.rkt" and not to the definition of pt.

So, I think, that what happened originally. I made a change and used cmd-. without running the file first.

Ah that scenario makes sense.

Note that you wouldn't need to racket-run the file again, just give racket-xp-mode time to re-annotate it.

However in this example, since @y is likely an error, racket-xp-mode will show the error. Upon an error it retains many properties, with the justification they might be handy when you edit to fix an error -- even if some might be misleading, as in this case. So it's a trade-off.

FWIW I did find a simple change for the other scenario I thought of -- where if you C-u M-. it prompts with the wrong default. Although not a huge defect, it's safe and simple to improve this, I think. So I'll probably close this issue by merging that commit (even if a bit OT from your original report).