Skip to content

Commit

Permalink
racket-xp: Omit loc prefix in help-echo error messages; closes #702
Browse files Browse the repository at this point in the history
Rationale: It is redundant and a waste of screen space to show
"/path/to/file.rkt:line:col" in a text property attached to that
location, and which is displayed only when point or the mouse cursor
is at that location.
  • Loading branch information
greghendershott committed Mar 1, 2024
1 parent 892388f commit 5e9412a
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions racket-xp.el
Original file line number Diff line number Diff line change
Expand Up @@ -463,9 +463,9 @@ manually."
'racket-xp-def nil
'racket-xp-use nil))
(racket--add-overlay beg end racket-xp-error-face)
(add-text-properties
beg end
(list 'help-echo str)))))
(put-text-property beg end
'help-echo
(racket--error-message-sans-location-prefix str)))))
(`(info ,beg ,end ,str)
(put-text-property beg end 'help-echo str)
(when (and (string-equal str "no bound occurrences")
Expand Down Expand Up @@ -526,6 +526,20 @@ manually."
(list 'racket-xp-doc
(list (racket-file-name-back-to-front path) anchor))))))))

(defun racket--error-message-sans-location-prefix (str)
"Remove \"/path/to/file.rkt:line:col: \" location prefix from an
error message, which is just noise for a help-echo at that
point."
(save-match-data
(if (string-match (rx bos
(+? anything) ?: (+ digit) (any ?: ?.) (+ digit) ?:
(+? space)
(group-n 1 (+? anything))
eos)
str)
(match-string 1 str)
str)))

(defun racket--xp-add-binding-face (beg end face)
(add-text-properties beg end
(list 'font-lock-face face)))
Expand Down

0 comments on commit 5e9412a

Please sign in to comment.