greghendershott / racket-mode

Emacs major and minor modes for Racket: edit, REPL, check-syntax, debug, profile, packages, and more.
https://www.racket-mode.com/
GNU General Public License v3.0
682 stars 93 forks source link

Length of popup error #702

Closed soegaard closed 8 months ago

soegaard commented 8 months ago

The following image shows what happens when I enter an { and waits a bit.

image

The popup error is correct of course - but the error location is unhelpful - since the cursor is already on that line. It would better just to display "remember the closing }" when the cursor is on the same line as the error location.

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)
 (hi-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)
 (dired-isearch-filenames-mode)
 (eldoc-mode)
 (electric-layout-mode)
 (electric-pair-mode)
 (electric-quote-mode)
 (global-hi-lock-mode)
 (global-hl-line-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)
 (hl-line-mode)
 (horizontal-scroll-bar-mode)
 (hs-minor-mode)
 (html-autoview-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)
 (sgml-electric-tag-pair-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))
greghendershott commented 8 months ago

I believe racket-xp-mode is showing the exn-message string as-is.

When the error-print-source-location parameter is true (the default) then that path:line:column prefix is baked into the exn-message string.

I guess it would be possible to prevent it by setting error-print-source-location false, OR, try to eliminate it via a regexp. I can think of gotchas both ways, not sure which way is the least worst...

greghendershott commented 8 months ago

Rather than remove the location prefix from the error message at a low level, I decided to detect it with a regexp and remove it only as a "presentation detail" for the specific purpose of the help-echo property (displayed as a popup).

The full error message text is used in other places, e.g. for M-x next-error, and I think that's fine and less likely to cause unintended consequences.