all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Jostein Kjønigsen" <jostein@secure.kjonigsen.net>
To: emacs-devel@gnu.org,
	Vladimir Panteleev <vladimir@thecybershadow.net>,
	Eli Zaretskii <eliz@gnu.org>
Subject: Support variable-unquoting syntax in bat-mode
Date: Wed, 14 Mar 2018 09:37:29 +0100	[thread overview]
Message-ID: <1521016649.71943.1302515928.19D18627@webmail.messagingengine.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1645 bytes --]

Hey everyone.

For those of us still stuck meddling with Windows batch-files, these
scripts are definitely not getting cleaner or smaller with time.
In such batch-files there are various ways to extract script-parameters
provided by the script/function caller. The most common syntax is
percentage + a numeral, that is %1 represents the first script/function
parameter. Etc.
But when parameters contains spaces, they have to be quoted by the
caller. The variable/parameter then contains the quote, and to
further process them inside your script, they typically need to be
unquoted first.
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))

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?
If not, does anyone object to this change? And if not, how do I get it
merged into master? :)
--
Regards
Jostein Kjønigsen

jostein@kjonigsen.net 🍵 jostein@gmail.com
https://jostein.kjonigsen.net


[-- Attachment #2: Type: text/html, Size: 2891 bytes --]

             reply	other threads:[~2018-03-14  8:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-14  8:37 Jostein Kjønigsen [this message]
2018-03-14 14:15 ` Support variable-unquoting syntax in bat-mode Vladimir Panteleev
2018-03-14 16:22 ` Eli Zaretskii
2018-03-14 20:48   ` Jostein Kjønigsen
2018-03-15 13:25     ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1521016649.71943.1302515928.19D18627@webmail.messagingengine.com \
    --to=jostein@secure.kjonigsen.net \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=jostein@kjonigsen.net \
    --cc=vladimir@thecybershadow.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.