[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Support variable-unquoting syntax in bat-mode
From: |
Eli Zaretskii |
Subject: |
Re: Support variable-unquoting syntax in bat-mode |
Date: |
Wed, 14 Mar 2018 18:22:22 +0200 |
> From: Jostein Kjønigsen <address@hidden>
> Date: Wed, 14 Mar 2018 09:37:29 +0100
>
> To do unquoting, you typically use the variable unquote syntax: %~1
>
> In latest Emacs this syntax is not correctly highlighted. Applying the
> following patch seems to fix this:
>
> diff --git a/lisp/progmodes/bat-mode.el b/lisp/progmodes/bat-mode.el
> index 102c318..b2edf64 100644
> --- a/lisp/progmodes/bat-mode.el
> +++ b/lisp/progmodes/bat-mode.el
> @@ -84,7 +84,7 @@ bat-font-lock-keywords
> . 'bat-label-face)
> ("\\_<\\(defined\\|set\\)\\_>[ \t]*\\(\\(\\sw\\|\\s_\\)+\\)"
> (2 font-lock-variable-name-face))
> - ("%\\([^%~ \n]+\\)%?"
> + ("%\\([^% \n]+\\)%?"
> (1 font-lock-variable-name-face))
I think this will break the test suite for bat-mode.el. Did you run
it after applying the change?
> That seems to work for me, but ~ seems like a odd special case to put in
> there in the first place, so I would
> assume it was intentionally put there. Anyone have any background on this?
That's because in the likes of "%~dp1" we want only "1" to be
highlighted as variable name. With your change, "~dp1" will be
highlighted in its entirety.
How about the patch below instead?
--- lisp/progmodes/bat-mode.el~ 2018-01-03 13:09:15.000000000 +0200
+++ lisp/progmodes/bat-mode.el 2018-03-14 17:10:44.238856900 +0200
@@ -84,6 +84,8 @@
. 'bat-label-face)
("\\_<\\(defined\\|set\\)\\_>[ \t]*\\(\\(\\sw\\|\\s_\\)+\\)"
(2 font-lock-variable-name-face))
+ ("%~\\([1-9]\\)"
+ (1 font-lock-variable-name-face))
("%\\([^%~ \n]+\\)%?"
(1 font-lock-variable-name-face))
("!\\([^!%~ \n]+\\)!?" ; delayed-expansion !variable!