branch: elpa/nix-mode commit 9b705381c40ef1ac28a929b7019659f3d996494a Author: Matthew Bauer <mjbaue...@gmail.com> Commit: Matthew Bauer <mjbaue...@gmail.com>
Fix antiquote highlighting. Fixes #3. --- nix-mode.el | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/nix-mode.el b/nix-mode.el index 9b2576a2c6..966ce793ff 100644 --- a/nix-mode.el +++ b/nix-mode.el @@ -107,11 +107,16 @@ (defun nix-syntax-propertize-antiquote () "Set syntax properties for an antiquote mark." - (let* ((start (match-beginning 0))) - (put-text-property start (1+ start) - 'syntax-table (string-to-syntax "|")) - (put-text-property start (+ start 2) - 'nix-syntax-antiquote t))) + (let* ((start (match-beginning 0)) + (context (save-excursion (save-match-data (syntax-ppss start)))) + (string-type (nth 3 context))) + + ;; only add antiquote when we're already in a string + (when string-type + (put-text-property start (1+ start) + 'syntax-table (string-to-syntax "|")) + (put-text-property start (+ start 2) + 'nix-syntax-antiquote t)))) (defun nix-syntax-propertize-close-brace () "Set syntax properties for close braces.