From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Anders Lindgren Newsgroups: gmane.emacs.bugs Subject: bug#28311: 25.2; Improve syntax highlighting in bat-mode Date: Thu, 31 Aug 2017 21:06:14 +0200 Message-ID: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="f403043ed118abead9055811561c" X-Trace: blaine.gmane.org 1504206442 15389 195.159.176.226 (31 Aug 2017 19:07:22 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 31 Aug 2017 19:07:22 +0000 (UTC) To: 28311@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Aug 31 21:07:11 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1dnUo2-0003OK-JF for geb-bug-gnu-emacs@m.gmane.org; Thu, 31 Aug 2017 21:07:10 +0200 Original-Received: from localhost ([::1]:57138 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dnUo7-0006LN-Ko for geb-bug-gnu-emacs@m.gmane.org; Thu, 31 Aug 2017 15:07:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54252) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dnUo1-0006LF-B5 for bug-gnu-emacs@gnu.org; Thu, 31 Aug 2017 15:07:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dnUnu-0003NS-KZ for bug-gnu-emacs@gnu.org; Thu, 31 Aug 2017 15:07:09 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:57568) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dnUnu-0003NO-H7 for bug-gnu-emacs@gnu.org; Thu, 31 Aug 2017 15:07:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dnUnu-0008GT-93 for bug-gnu-emacs@gnu.org; Thu, 31 Aug 2017 15:07:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Anders Lindgren Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 31 Aug 2017 19:07:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 28311 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.150420639131722 (code B ref -1); Thu, 31 Aug 2017 19:07:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 31 Aug 2017 19:06:31 +0000 Original-Received: from localhost ([127.0.0.1]:38016 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dnUnP-0008Fa-6h for submit@debbugs.gnu.org; Thu, 31 Aug 2017 15:06:31 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:34911) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dnUnN-0008FN-1n for submit@debbugs.gnu.org; Thu, 31 Aug 2017 15:06:29 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dnUnG-00033c-6f for submit@debbugs.gnu.org; Thu, 31 Aug 2017 15:06:24 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:60587) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dnUnG-00033Y-3L for submit@debbugs.gnu.org; Thu, 31 Aug 2017 15:06:22 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54115) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dnUnD-0006Ix-Uf for bug-gnu-emacs@gnu.org; Thu, 31 Aug 2017 15:06:21 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dnUnB-00032o-MD for bug-gnu-emacs@gnu.org; Thu, 31 Aug 2017 15:06:19 -0400 Original-Received: from mail-ua0-x234.google.com ([2607:f8b0:400c:c08::234]:33906) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dnUnB-00032Y-Ev for bug-gnu-emacs@gnu.org; Thu, 31 Aug 2017 15:06:17 -0400 Original-Received: by mail-ua0-x234.google.com with SMTP id l11so1656503uaf.1 for ; Thu, 31 Aug 2017 12:06:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=d+BE/7lWpx1bOfjrOyl3ZGp8BIaKjqTt31kqjHNevFE=; b=ADNxSVbnl7THKAXSl+Mi5tLls0SYgLrL6aWS+yP8Kwbb6YAnIXCgM54pgDuJ+2WcwZ AxDIU/kKigZXzH5j1KJyDxh9niatWMGHt6388vJHZZU5DibddkhZehe7POZFrktBSgZw t1mW5C80e1QGrGBr+yIMkQEW4uCl0w9IcWSa+mqFGq6SRkWAU26I2kCU45WOKhsqUd9F 0OhCKMVZqvbFrp/4VLwwrCD3qTp1bIH8l1+o/p5b6mlEx5pP1csj72gljtCoCToFBuKE iBt0Nhwjk3IwOJguyQwPwyz+TizuEZlh2AX977xCyXfIXnILnXibjxd//ukYdf2EhyL6 ioIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=d+BE/7lWpx1bOfjrOyl3ZGp8BIaKjqTt31kqjHNevFE=; b=LlVSBU5Izt+pi7djgrykm3kLbKOqgwXrUTrkaIzkF6aaLwYK1Wkn3LOZN0LFLAjGqr p3PhJ0qUBZlTPbIrGaZ8143FBZsfwTuq8X8dxzgumDiTXLufGRtkLaOtxhiHLVBqvcjb 64kL+brlZBDo1UCJAfMuvmy88U64bO3x8phT2Mk87/Wt65opXfvFdKDAVTqw8Cp5IgAJ a0JwrysrPUbGwFFHkFnuG8/3zXj3RDzXh7MYLc3KeGZUs/TNfPOhBhlBL1/w4SKvllA8 vliFn9C4ioYt8/MK32tFFRNZIuwjUnmJTcPthe5Jp1aoPMBy9pcxYYzWY9I8OFfP5VBV /91Q== X-Gm-Message-State: AHYfb5gSHRO3NMRiX/OxR4rWETaVUy2DOsvVlDQJCNf3eeMRr18kvI7O jxZdZ4ZN2g3kYo3ZXhP1IKUqMEBOB/fK X-Google-Smtp-Source: ADKCNb6WpLwprUw1xG/qh22XCqahxq37S72R00mGIEs1SH+kuzTjqKM7b9ez871zMR+Jr+U0NMbrqRtazStp2Ddsl9g= X-Received: by 10.176.78.157 with SMTP id l29mr3925341uah.2.1504206375345; Thu, 31 Aug 2017 12:06:15 -0700 (PDT) Original-Received: by 10.31.171.202 with HTTP; Thu, 31 Aug 2017 12:06:14 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:136420 Archived-At: --f403043ed118abead9055811561c Content-Type: text/plain; charset="UTF-8" Hi! I've noticed some problems with syntax highlighting in bat-mode. In addition, I have two improvement suggestions. Problem 1: bat-mode highlights variables surrounded by "%":s, as in "%alpha%". However, when the variable contains an underscore, as in "%alpha_beta%", only "alpha" is highlighted. Problem 2: Similarly, bat-mode highlights variables defined using "set". As with problem 1 above, it does not handle words with underscore. Concretely, in "set alpha_beta=value", only "alpha" is highlighted. Problem 3: bat-mode highlights keywords like "in". Unfortunately, it also highlights the word "in" when used as a file extension. For example "xxx alpha.in". Improvement suggestion 1: In bat scripts, the command "echo" can be used to print strings to the console. Unlike in shell scripts, the argument to "echo" does not require quotes. It would be nice if Emacs would highlight anything after "echo" as a string (using font-lock-string-face). Improvement suggestion 2: In bat scripts, variable substitution is performed inside quoted strings, for example: xxx "hello %alpha goodbye" Unfortunately, emacs does not highlight this, which I hereby propose that it should. I had plans to fix all of the above myself. Unfortunately, my Emacs todo-list is too long for my available time, so Richard S. suggested that I report this here, in case someone else would have more time than I do. Anyway, problem 1 and 2 can probably be fixed by adapting a regexp. Problem 3 should easily be fixed by using a custom font-lock syntax table, where "." is seen as a word character, or possibly a symbol character. Improvement suggestion 1 could probably be handled by a simple rule matching echo + space + whatever and highlight "whatever" using font-lock-string-face. All of these are easy to fix. Improvement suggestion 2 raises the bar to "medium", as it would require replacing the current rexexp rule with one written in elisp. The rule will need to use the "prepend" (not "t") override flag to add font-lock-variable-name-face to the variable name in top of the string face. However, the code must ensure that it does not do this for comments. Side note: Typically, the "prepend" override flag is preferred over "t", as the end result will mix face properties from both the new and old faces. Concretely, I use a string face with a red foreground and a grey background. With the "prepend" flag, the variable name will be drawn using yellow from font-lock-variable-name-face but the background will still be grey, matching the rest of the string. -- Anders Lindgren In GNU Emacs 25.2.1 (x86_64-apple-darwin13.4.0, NS appkit-1265.21 Version 10.9.5 (Build 13F1911)) of 2017-04-21 built on builder10-9.porkrind.org Windowing system distributor 'Apple', version 10.3.1504 Configured using: 'configure --with-ns '--enable-locallisppath=/Library/Application Support/Emacs/${version}/site-lisp:/Library/Application Support/Emacs/site-lisp' --with-modules' Configured features: NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS MODULES Important settings: value of $LC_CTYPE: UTF-8 value of $LANG: en_SE.UTF-8 locale-coding-system: utf-8-unix Major mode: Bat Minor modes in effect: tooltip-mode: t global-eldoc-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t Recent messages: For information about GNU Emacs and the GNU system, type C-h C-a. next-line: End of buffer Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message dired format-spec rfc822 mml mml-sec password-cache epg epg-config gnus-util mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util help-fns help-mode cl-loaddefs pcase cl-lib mail-prsvr mail-utils vc-dispatcher vc-svn bat-mode easymenu time-date mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel ns-win ucs-normalize term/common-win tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment elisp-mode lisp-mode prog-mode register page menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese charscript case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer cl-preloaded nadvice loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote kqueue cocoa ns multi-tty make-network-process emacs) Memory information: ((conses 16 196862 6811) (symbols 48 19646 0) (miscs 40 53 163) (strings 32 15415 5200) (string-bytes 1 442636) (vectors 16 33051) (vector-slots 8 651956 5657) (floats 8 162 94) (intervals 56 216 0) (buffers 976 19)) --f403043ed118abead9055811561c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi!

I've noticed some pr= oblems with syntax highlighting in bat-mode. In addition, I have two improv= ement suggestions.

Problem 1:

=
bat-mode highlights variables surrounded by "%":s, as in &qu= ot;%alpha%". However, when the variable contains an underscore, as in = "%alpha_beta%", only "alpha" is highlighted.
=
Problem 2:

Similarly, bat-mode high= lights variables defined using "set". As with problem 1 above, it= does not handle words with underscore. Concretely, in "set alpha_beta= =3Dvalue", only "alpha" is highlighted.

=
Problem 3:

bat-mode highlights keywords like = "in". Unfortunately, it also highlights the word "in" w= hen used as a file extension. For example "xxx alpha.in".

Improvement suggestion 1:=

In bat scripts, the command "echo" can = be used to print strings to the console. Unlike in shell scripts, the argum= ent to "echo" does not require quotes. It would be nice if Emacs = would highlight anything after "echo" as a string (using font-loc= k-string-face).

Improvement suggestion 2:

In bat scripts, variable substitution is performed inside = quoted strings, for example:

=C2=A0 =C2=A0 xxx &qu= ot;hello %alpha goodbye"

Unfortunately, emacs= does not highlight this, which I hereby propose that it should.
=

I had plans to fix all of the above myself. U= nfortunately, my Emacs todo-list is too long for my available time, so Rich= ard S. suggested that I report this here, in case someone else would have m= ore time than I do.

Anyway, problem 1 and 2 can pr= obably be fixed by adapting a regexp. Problem 3 should easily be fixed by u= sing a custom font-lock syntax table, where "." is seen as a word= character, or possibly a symbol character. Improvement suggestion 1 could = probably be handled by a simple rule matching echo + space + whatever and h= ighlight "whatever" using font-lock-string-face. All of these are= easy to fix.

Improvement suggestion 2 raises the = bar to "medium", as it would require replacing the current rexexp= rule with one written in elisp. The rule will need to use the "prepen= d" (not "t") override flag to add font-lock-variable-name-fa= ce to the variable name in top of the string face. However, the code must e= nsure that it does not do this for comments.

Side = note: Typically, the "prepend" override flag is preferred over &q= uot;t", as the end result will mix face properties from both the new a= nd old faces. Concretely, I use a string face with a red foreground and a g= rey background. With the "prepend" flag, the variable name will b= e drawn using yellow from font-lock-variable-name-face but the background w= ill still be grey, matching the rest of the string.

=C2=A0 =C2=A0 -- Anders Lindgren


=
In GNU Emacs 25.2.1 (x86_64-apple-darwin13.4.0, NS appkit-12= 65.21 Version 10.9.5 (Build 13F1911))
=C2=A0of 2017-04-21 built o= n builder10-9.porkrind.org<= /div>
Windowing system distributor 'Apple', version 10.3.1504
Configured using:
=C2=A0'configure --with-ns '--= enable-locallisppath=3D/Library/Application
=C2=A0Support/Emacs/$= {version}/site-lisp:/Library/Application
=C2=A0Support/Emacs/site= -lisp' --with-modules'

Configured features= :
NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS MODULES

Important settings:
=C2=A0 value of $LC_C= TYPE: UTF-8
=C2=A0 value of $LANG: en_SE.UTF-8
=C2=A0 l= ocale-coding-system: utf-8-unix

Major mode: Bat

Minor modes in effect:
=C2=A0 tooltip-mode= : t
=C2=A0 global-eldoc-mode: t
=C2=A0 electric-indent-= mode: t
=C2=A0 mouse-wheel-mode: t
=C2=A0 tool-bar-mode= : t
=C2=A0 menu-bar-mode: t
=C2=A0 file-name-shadow-mod= e: t
=C2=A0 global-font-lock-mode: t
=C2=A0 font-lock-m= ode: t
=C2=A0 blink-cursor-mode: t
=C2=A0 auto-composit= ion-mode: t
=C2=A0 auto-encryption-mode: t
=C2=A0 auto-= compression-mode: t
=C2=A0 line-number-mode: t
=C2=A0 t= ransient-mark-mode: t

Recent messages:
F= or information about GNU Emacs and the GNU system, type C-h C-a.
= next-line: End of buffer

Load-path shadows:
<= div>None found.

Features:
(shadow sort m= ail-extr emacsbug message dired format-spec rfc822 mml
mml-sec pa= ssword-cache epg epg-config gnus-util mm-decode mm-bodies
mm-enco= de mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail
rf= c2047 rfc2045 ietf-drums mm-util help-fns help-mode cl-loaddefs pcase
=
cl-lib mail-prsvr mail-utils vc-dispatcher vc-svn bat-mode easymenu
time-date mule-util tooltip eldoc electric uniquify ediff-hook vc-h= ooks
lisp-float-type mwheel ns-win ucs-normalize term/common-win = tool-bar dnd
fontset image regexp-opt fringe tabulated-list newco= mment elisp-mode
lisp-mode prog-mode register page menu-bar rfn-e= shadow timer select
scroll-bar mouse jit-lock font-lock syntax fa= cemenu font-core frame
cl-generic cham georgian utf-8-lang misc-l= ang vietnamese tibetan thai
tai-viet lao korean japanese eucjp-ms= cp51932 hebrew greek romanian
slovak czech european ethiopic ind= ian cyrillic chinese charscript
case-table epa-hook jka-cmpr-hook= help simple abbrev minibuffer
cl-preloaded nadvice loaddefs butt= on faces cus-face macroexp files
text-properties overlay sha1 md5= base64 format env code-pages mule
custom widget hashtable-print-= readable backquote kqueue cocoa ns
multi-tty make-network-process= emacs)

Memory information:
((conses 16 = 196862 6811)
=C2=A0(symbols 48 19646 0)
=C2=A0(miscs 40= 53 163)
=C2=A0(strings 32 15415 5200)
=C2=A0(string-by= tes 1 442636)
=C2=A0(vectors 16 33051)
=C2=A0(vector-sl= ots 8 651956 5657)
=C2=A0(floats 8 162 94)
=C2=A0(inter= vals 56 216 0)
=C2=A0(buffers 976 19))

<= br>
--f403043ed118abead9055811561c--