From 4a8c54f922a241ab298e8ef688ea10ebf9988b5f Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Thu, 25 May 2023 00:17:29 -0700 Subject: [PATCH] [oni-csharp] Use text properties instead of overlays Use text properties instead of overlays and add some extra information. --- oni-csharp/oni-csharp.el | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/oni-csharp/oni-csharp.el b/oni-csharp/oni-csharp.el index 02b1cd7..1eb20a4 100644 --- a/oni-csharp/oni-csharp.el +++ b/oni-csharp/oni-csharp.el @@ -186,24 +186,34 @@ _cs_: Solution (interactive) (save-excursion (goto-char (point-min)) - (remove-overlays (point-min) (point-max) 'oni-csharp--overlayp t) (while (re-search-forward (rx bol (zero-or-more whitespace) - "{" - (group (minimal-match (one-or-more (or alphanumeric "-")))) - "} = {" - (group (minimal-match (one-or-more (or alphanumeric "-")))) - "}" + (group + "{" + (group (minimal-match (one-or-more (or alphanumeric "-")))) + "}") + " = " + (group + "{" + (group (minimal-match (one-or-more (or alphanumeric "-")))) + "}") eol) nil :noerror) - (let ((current-overlay (make-overlay (line-beginning-position) (line-end-position)))) - (overlay-put current-overlay 'after-string - (propertize (format " => %s" (gethash (match-string 1) oni-csharp--projects)) - 'face '(:foreground "#808080"))) - (overlay-put current-overlay 'oni-csharp--overlayp t) - (overlay-put current-overlay 'evaporate t))))) + (add-text-properties + (match-beginning 1) (match-end 1) + (list 'display (gethash (match-string 2) oni-csharp--projects) + 'face 'font-lock-variable-name-face + 'help-echo (buffer-substring-no-properties + (match-beginning 1) (match-end 1)) + 'intangile nil)) + (add-text-properties + (match-beginning 3) (match-end 3) + (list 'display (gethash (match-string 4) oni-csharp--projects) + 'face 'font-lock-variable-name-face + 'help-echo (buffer-substring-no-properties + (match-beginning 3) (match-end 3))))))) (define-derived-mode csharp-solution-mode prog-mode "Sln" "A major mode for viewing and editing C# ‘.sln’ files."