From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: =?utf-8?Q?Jostein=20Kj=C3=B8nigsen?= Newsgroups: gmane.emacs.devel Subject: Support variable-unquoting syntax in bat-mode Date: Wed, 14 Mar 2018 09:37:29 +0100 Message-ID: <1521016649.71943.1302515928.19D18627@webmail.messagingengine.com> Reply-To: jostein@kjonigsen.net NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="_----------=_1521016649719431" Content-Transfer-Encoding: 7bit X-Trace: blaine.gmane.org 1521016563 27471 195.159.176.226 (14 Mar 2018 08:36:03 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 14 Mar 2018 08:36:03 +0000 (UTC) To: emacs-devel@gnu.org, Vladimir Panteleev , Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Mar 14 09:35:58 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ew1t7-00070J-Ve for ged-emacs-devel@m.gmane.org; Wed, 14 Mar 2018 09:35:58 +0100 Original-Received: from localhost ([::1]:44953 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ew1vA-0002Po-WB for ged-emacs-devel@m.gmane.org; Wed, 14 Mar 2018 04:38:05 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43550) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ew1uo-0002EH-MK for emacs-devel@gnu.org; Wed, 14 Mar 2018 04:37:47 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ew1ul-0000NT-Ht for emacs-devel@gnu.org; Wed, 14 Mar 2018 04:37:42 -0400 Original-Received: from out1-smtp.messagingengine.com ([66.111.4.25]:44765) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ew1ud-0000H9-OS; Wed, 14 Mar 2018 04:37:31 -0400 Original-Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id B4F2D21949; Wed, 14 Mar 2018 04:37:29 -0400 (EDT) Original-Received: from web5 ([10.202.2.215]) by compute6.internal (MEProxy); Wed, 14 Mar 2018 04:37:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= secure.kjonigsen.net; h=content-transfer-encoding:content-type :date:from:message-id:mime-version:reply-to:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=vNfmYmKJF2scX17tU 0CAS2D3asSrmPDpQPpHfiVfPsw=; b=uNSliMFmsXMLCS1uwGisaYcG3qqNkEUm9 Bo+bpAf/yBmyfl/rK7fFoON2fbUZ3OlnIGHwGkWuo7I1CUR8M6LJ0eV1Ga26I0Eq 6fA/dlkksMrwDfny9LZar/QxOt8a6m808AvV+6KRnAeXXvTqE571Y/YkvzfoglHa A7QLQ/0BREQUABi/8PTJUI0X1KSzlRyEVRZB31aufmxX19M0QjLBzP+TewkA/iJ6 0+hwku2JGlteq5iDx+zsICJ9Eg9p6PdAyrnqPZtF+94jT2ixgJrV3pvLqPrWXxxo NwRdrZdKzNbasMwGV73l2IHlFp4b+YUrPoD24Uw8GNEYJg77BTZ6g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:message-id:mime-version:reply-to:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=vNfmYmKJF2scX17tU 0CAS2D3asSrmPDpQPpHfiVfPsw=; b=nyZdXl1Tiajayf9MIMaOiNPhMIlSVcWGk +lZXwUSJ+KoqL7xqBsjTcu8V/5z3GeZfGcs1k1hrqKRO+9rOFHOYxvDJQGwDzHRi Q9sUFfByRuWc+QPzCDQEW3Sc/jt7MQE6pH1AwCHs6wehJbFMNUoBniSIDTue8ZJg 85ciIVUNmxJVYTThb9C/6QCvE6wf6gOchcNJY1KsbmtZr1nllVOoPbyOPFNIQleh tMq6sRIB7I0bax6kBukE6A81GLThQd3dK6QX/rk3noFQ4t8koK6IKRKxKYsPs6Y7 b+vOsWPT7ORNIIW/HD/bTJU/XB7bD90o6OVylY+rwxIGLWt6Bolqg== X-ME-Sender: Original-Received: by mailuser.nyi.internal (Postfix, from userid 99) id 8D0439E087; Wed, 14 Mar 2018 04:37:29 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface - ajax-54087d22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.111.4.25 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:223713 Archived-At: This is a multi-part message in MIME format. --_----------=_1521016649719431 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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=C3=B8nigsen jostein@kjonigsen.net =F0=9F=8D=B5 jostein@gmail.com https://jostein.kjonigsen.net --_----------=_1521016649719431 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset="utf-8"
Hey everyone.

For those of us still stuck meddling with Windows batch-files, these s= cripts are definitely not getting cleaner or smaller with time.

In such batch-files there are various ways to extract script-parameter= s provided by the script/function caller. The most common syntax is percent= age + a numeral, that is %1 represents the first script/function parameter.= Etc.

But when parameters contains spaces, they have to be quoted by the cal= ler. 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.  Applyi= ng 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-fa= ce)
         ("\\_<\\(defined\\= |set\\)\\_>[ \t]*\\(\\(\\sw\\|\\s_\\)+\\)"
          (2 font-lock-va= riable-name-face))
-        ("%\\([^%~ \n]+\\)%?"
<= /div>
+        ("%\\([^% \n]+\\)%?"
          (1 font-lock-va= riable-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 the= re. 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? :)

--
Regard= s
Jostein Kj=C3=B8nigsen


--_----------=_1521016649719431--