Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with parsing parens in single line expressions. #735

Closed
atodoron opened this issue Dec 24, 2024 · 2 comments
Closed

Issues with parsing parens in single line expressions. #735

atodoron opened this issue Dec 24, 2024 · 2 comments
Labels
bug fix-via-hash-lang-mode Bugs that probably can only be fixed via racket-hash-lang-mode

Comments

@atodoron
Copy link

Please copy all of the following lines and paste them into your bug report
at https://github.com/greghendershott/racket-mode/issues/.

Package

metadata
(#s(package-desc racket-mode
		 (20241207 1746)
		 "Racket editing, REPL, and more."
		 ((emacs
		   (25 1)))
		 nil nil "/home/xxx/.emacs.d/elpa/racket-mode-20241207.1746"
		 ((:authors
		   ("Greg Hendershott" . "racket-mode-author@greghendershott.com"))
		  (:revdesc . "ee67d2d4f78a")
		  (:commit . "ee67d2d4f78a6edfe43ad781830d8cc65fb03982")
		  (:url . "https://github.com/greghendershott/racket-mode"))
		 nil))
package-archives
(("gnu" . "https://elpa.gnu.org/packages/")
 ("nongnu" . "https://elpa.nongnu.org/nongnu/")
 ("melpa" . "https://melpa.org/packages/"))
racket--el-source-dir
"/home/xxx/.emacs.d/elpa/racket-mode-20241207.1746/"
racket--rkt-source-dir
"/home/xxx/.emacs.d/elpa/racket-mode-20241207.1746/racket/"

System values

emacs-version
"29.3"
major-mode
racket-mode
system-type
gnu/linux
x-gtk-use-system-tooltips
t
display-graphic-p
t

Buffer values

after-change-functions
(jit-lock-after-change t)
before-change-functions
(t syntax-ppss-flush-cache)
completion-at-point-functions
(racket-complete-at-point)
eldoc-documentation-function
eldoc-documentation-default
eldoc-documentation-strategy
eldoc-documentation-default
eldoc-documentation-functions
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
(tooltip-hide)
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-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
browse-url-default-browser
racket-command-timeout
10
racket-doc-index-directory
"~/.emacs.d/racket-mode/"
racket-doc-index-predicate-function
always
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-do-not-use-svg
nil
racket-images-inline
t
racket-images-keep-last
100
racket-images-system-viewer
"display"
racket-indent-curly-as-sequence
t
racket-indent-sequence-depth
0
racket-input-prefix
"\\"
racket-input-translations
(("All" "∀")
 ("Union" "U")
 ("Intersection" "∩")
 ("test-->>E" "test-->>∃")
 ("vdash" "⊢")
 ("gg" "≫")
 ("succ" "≻")
 ("times" "×")
 ("Uparrow" "⇑")
 ("Downarrow" "⇓")
 ("Leftarrow" "⇐")
 ("Rightarrow" "⇒")
 ("leftarrow" "←")
 ("rightarrow" "→")
 ("nwarrow" "↖")
 ("nearrow" "↗")
 ("uparrow" "↑")
 ("downarrow" "↓")
 ("searrow" "↘")
 ("swarrow" "↙")
 ("leftrightarrow" "↔")
 ("updownarrow" "⇕")
 ("aleph" "א")
 ("emptyset" "∅")
 ("nabla" "∇")
 ("surd" "√")
 ("negation" "¬")
 ("infinity" "∞")
 ("prod" "∏")
 ("coprod" "∐")
 ("integrate" "∫")
 ("oint" "∮")
 ("vee" "∨")
 ("wedge" "∧")
 ("follows" "∘")
 ("setin" "∈")
 ("ni" "∋")
 ("notin" "∉")
 ("sqsubset" "⊏")
 ("sqsupset" "⊐")
 ("sqsubseteq" "⊑")
 ("sqsupseteq" "⊒")
 ("subset" "⊂")
 ("superset" "⊃")
 ("subseteq" "⊆")
 ("supseteq" "⊇")
 ("approx" "≈")
 ("cong" "≌")
 ("neq" "≠")
 ("sqcap" "⊓")
 ("sqcup" "⊔")
 ("models" "⊧")
 ("alpha" "α")
 ("Alpha" "Α")
 ("beta" "β")
 ("Beta" "Β")
 ("gamma" "γ")
 ("Gamma" "Γ")
 ("delta" "δ")
 ("Delta" "Δ")
 ("epsilon" "ε")
 ("Epsilon" "Ε")
 ("zeta" "ζ")
 ("Zeta" "Ζ")
 ("eta" "η")
 ("Eta" "Η")
 ("theta" "θ")
 ("Theta" "Θ")
 ("iota" "ι")
 ("Iota" "Ι")
 ("kappa" "κ")
 ("Kappa" "Κ")
 ("lambda" "λ")
 ("Lambda" "Λ")
 ("lamda" "λ")
 ("Lamda" "Λ")
 ("mu" "μ")
 ("Mu" "Μ")
 ("nu" "ν")
 ("Nu" "Ν")
 ("xi" "ξ")
 ("Xi" "Ξ")
 ("omicron" "ο")
 ("Omicron" "Ο")
 ("pi" "π")
 ("Pi" "Π")
 ("rho" "ρ")
 ("Rho" "Ρ")
 ("sigma" "σ")
 ("Sigma" "Σ")
 ("tau" "τ")
 ("Tau" "Τ")
 ("upsilon" "υ")
 ("Upsilon" "Υ")
 ("phi" "φ")
 ("Phi" "Φ")
 ("chi" "χ")
 ("Chi" "Χ")
 ("psi" "ψ")
 ("Psi" "Ψ")
 ("omega" "ω")
 ("Omega" "Ω")
 ("digamma" "ϝ")
 ("Digamma" "Ϝ")
 ("san" "ϻ")
 ("San" "Ϻ")
 ("qoppa" "ϙ")
 ("Qoppa" "Ϙ")
 ("sampi" "ϡ")
 ("Sampi" "Ϡ")
 ("stigma" "ϛ")
 ("Stigma" "Ϛ")
 ("heta" "ͱ")
 ("Heta" "Ͱ")
 ("sho" "ϸ")
 ("Sho" "Ϸ")
 ("|A|" "𝔸")
 ("|B|" "𝔹")
 ("|C|" "ℂ")
 ("|D|" "𝔻")
 ("|E|" "𝔼")
 ("|F|" "𝔽")
 ("|G|" "𝔾")
 ("|H|" "ℍ")
 ("|I|" "𝕀")
 ("|J|" "𝕁")
 ("|K|" "𝕂")
 ("|L|" "𝕃")
 ("|M|" "𝕄")
 ("|N|" "ℕ")
 ("|O|" "𝕆")
 ("|P|" "ℙ")
 ("|Q|" "ℚ")
 ("|R|" "ℝ")
 ("|S|" "𝕊")
 ("|T|" "𝕋")
 ("|U|" "𝕌")
 ("|V|" "𝕍")
 ("|W|" "𝕎")
 ("|X|" "𝕏")
 ("|Y|" "𝕐")
 ("|Z|" "ℤ")
 ("|gamma|" "ℽ")
 ("|Gamma|" "ℾ")
 ("|pi|" "ℼ")
 ("|Pi|" "ℿ")
 ("forall" "∀")
 ("exists" "∃")
 ("_0" "₀")
 ("_1" "₁")
 ("_2" "₂")
 ("_3" "₃")
 ("_4" "₄")
 ("_5" "₅")
 ("_6" "₆")
 ("_7" "₇")
 ("_8" "₈")
 ("_9" "₉")
 ("^0" "⁰")
 ("^1" "¹")
 ("^2" "²")
 ("^3" "³")
 ("^4" "⁴")
 ("^5" "⁵")
 ("^6" "⁶")
 ("^7" "⁷")
 ("^8" "⁸")
 ("^9" "⁹"))
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
nil
racket-module-forms
"\\s(\\(?:module[*+]?\\|library\\)"
racket-pretty-lambda
nil
racket-pretty-print
t
racket-program
"racket"
racket-repl-buffer-name-function
nil
racket-repl-command-file
"/home/xxx/.emacs.d/racket-mode/repl.rkt"
racket-repl-history-directory
"~/.emacs.d/racket-mode/"
racket-repl-mode-hook
nil
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-eldoc-level
summary
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)
 (blink-cursor-mode)
 (electric-indent-mode)
 (file-name-shadow-mode)
 (font-lock-mode)
 (global-eldoc-mode)
 (global-font-lock-mode)
 (line-number-mode)
 (menu-bar-mode)
 (mouse-wheel-mode)
 (semantic-minor-modes-format)
 (shell-dirtrack-mode)
 (show-paren-mode)
 (tool-bar-mode)
 (tooltip-mode)
 (transient-mark-mode))
Disabled minor modes
disabled
((abbrev-mode)
 (auto-fill-function)
 (auto-fill-mode)
 (auto-save-mode)
 (auto-save-visited-mode)
 (buffer-face-mode)
 (buffer-read-only)
 (button-mode)
 (cl-old-struct-compat-mode)
 (column-number-mode)
 (comint-fontify-input-mode)
 (compilation-minor-mode)
 (compilation-shell-minor-mode)
 (completion-in-region-mode)
 (context-menu-mode)
 (cursor-face-highlight-mode)
 (defining-kbd-macro)
 (dired-hide-details-mode)
 (doc-view-minor-mode)
 (doc-view-presentation-mode)
 (eldoc-mode)
 (electric-layout-mode)
 (electric-pair-mode)
 (electric-quote-mode)
 (geiser-autodoc-mode)
 (geiser-mode)
 (geiser-repl-autoeval-mode)
 (geiser-repl-superparen-mode)
 (geiser-smart-tab-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)
 (gnus-dead-summary-mode)
 (gnus-undo-mode)
 (horizontal-scroll-bar-mode)
 (hs-minor-mode)
 (image-minor-mode)
 (indent-tabs-mode)
 (isearch-fold-quotes-mode)
 (isearch-mode)
 (jit-lock-debug-mode)
 (lock-file-mode)
 (lost-selection-mode)
 (mail-abbrevs-mode)
 (mml-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-hash-lang-repl-mode)
 (racket-input-mode)
 (racket-smart-open-bracket-mode)
 (racket-xp-mode)
 (read-extended-command-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)
 (shell-highlight-undef-mode)
 (size-indication-mode)
 (tab-bar-history-mode)
 (tab-bar-mode)
 (temp-buffer-resize-mode)
 (text-scale-mode)
 (transient-resume-mode)
 (treesit-explore-mode)
 (treesit-inspect-mode)
 (undelete-frame-mode)
 (url-handler-mode)
 (use-hard-newlines)
 (view-mode)
 (visible-mode)
 (visual-line-mode)
 (window-divider-mode)
 (xref-etags-mode))

Steps to reproduce:

Issues with paren groupings when using || in variable names, e.g.

(define var1 '(fn (fn |some text| |more text|) |even more text|))

racket mode thinks that there is a missing paren.

When adding a new line the issue is fixed:

(define var1 '(fn (fn |some text| |more text|)
                |even more text|))
@atodoron atodoron added the bug label Dec 24, 2024
@greghendershott
Copy link
Owner

greghendershott commented Dec 26, 2024

Thanks for the report.

The most minimal example I can find so far is:

'((|a| |b|) |c|)  ;bug

The bars around both a and b seem necessary. Neither of these examples exhibits the bug (for me):

'((|a| b) |c|)   ;OK
'((a |b|) |c|)   ;OK

Note: The bug happens with racket-mode, which lexes things in Emacs, mostly using regexps -- which means I think there will be always edge cases, and fixing one can easily create another. Regardless, I'll try to find time to dig in.

OTOH racket-hash-lang-mode uses the lexer provided by each #lang, and the racket lexer of course handles this fine and doesn't exhibit the bug. Although using that instead of racket-mode has its own set of pros and cons, you might prefer it if you like to write many expressions like your example. See Which major mode to use.

@greghendershott greghendershott added the fix-via-hash-lang-mode Bugs that probably can only be fixed via racket-hash-lang-mode label Dec 26, 2024
@greghendershott
Copy link
Owner

I added the fix-via-hash-lang-mode label. That's a bit misleading; as I said above, I plan to try to fix this in racket-mode. Instead, I added the label just as a hint/explanation that this is the kind of lexing edge case that racket-hash-lang-mode avoids.

greghendershott added a commit that referenced this issue Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug fix-via-hash-lang-mode Bugs that probably can only be fixed via racket-hash-lang-mode
Projects
None yet
Development

No branches or pull requests

2 participants