From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jonathan H Newsgroups: gmane.emacs.bugs Subject: bug#19455: Preliminary Patch Date: Sat, 20 Feb 2016 18:07:56 -0800 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=001a113f8f8e0d713a052c3e31b3 X-Trace: ger.gmane.org 1456020565 25536 80.91.229.3 (21 Feb 2016 02:09:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 21 Feb 2016 02:09:25 +0000 (UTC) To: 19455@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Feb 21 03:09:12 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aXJSQ-0000qQ-0T for geb-bug-gnu-emacs@m.gmane.org; Sun, 21 Feb 2016 03:09:10 +0100 Original-Received: from localhost ([::1]:37139 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aXJSP-0000HV-4B for geb-bug-gnu-emacs@m.gmane.org; Sat, 20 Feb 2016 21:09:09 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43676) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aXJSL-0000Gm-TX for bug-gnu-emacs@gnu.org; Sat, 20 Feb 2016 21:09:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aXJSI-0004j9-Lb for bug-gnu-emacs@gnu.org; Sat, 20 Feb 2016 21:09:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:38571) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aXJSI-0004j5-H0 for bug-gnu-emacs@gnu.org; Sat, 20 Feb 2016 21:09:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84) (envelope-from ) id 1aXJSI-0000Vq-8F for bug-gnu-emacs@gnu.org; Sat, 20 Feb 2016 21:09:02 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: Resent-From: Jonathan H Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 21 Feb 2016 02:09:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 19455 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 19455-submit@debbugs.gnu.org id=B19455.14560205131934 (code B ref 19455); Sun, 21 Feb 2016 02:09:02 +0000 Original-Received: (at 19455) by debbugs.gnu.org; 21 Feb 2016 02:08:33 +0000 Original-Received: from localhost ([127.0.0.1]:35698 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aXJRp-0000V8-4K for submit@debbugs.gnu.org; Sat, 20 Feb 2016 21:08:33 -0500 Original-Received: from mail-io0-f173.google.com ([209.85.223.173]:34403) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aXJRn-0000Uv-Kt for 19455@debbugs.gnu.org; Sat, 20 Feb 2016 21:08:31 -0500 Original-Received: by mail-io0-f173.google.com with SMTP id 9so146696479iom.1 for <19455@debbugs.gnu.org>; Sat, 20 Feb 2016 18:08:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=jCc0GWuXaQXeKAU+jz2D0oc8p1RMvyfcyJBWN3w2E4E=; b=c9NG93LcTiumYS4w5udp2BjNSbc5k7PUzCLYupgHMBVWR9GtIyoci6Gb0HDCe7twR/ iZSZTjeia/0PG+AAXeB3nppehKZwxaHDluIf3leY20E59O17A83bj/E8d8DlTL6NdDOx mpVBx0J8ZuLK0ee6ZAFlGqO13pdzppkMFhjucVoZkY2/0nulps71JitwYZr6Npx3eEy8 ONxjqCkHki8o1uC4Dh3lDqkJqlBdXFNst9KC3TA4dkEDUX5Mk+4urfLw7yzCFae+DdNe fw8MInwb6bVEUB6qmcD0vhx+iqV9wQOpYJhg/RAvC5CVGUJdNLelKYPhGa4OLq14CkU7 6OAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to :content-type; bh=jCc0GWuXaQXeKAU+jz2D0oc8p1RMvyfcyJBWN3w2E4E=; b=jRNXNSsE477pRD5MZqP7DI9ZewKQo+RO9u3K5ExHC5p6dwMI8hLMcc5md9WFRel1CC qRoFoqvVPRmiV8fPVtpM9UCLF2AKfTrWH1V79wWVxU/RIOfoFHpnTUTi083E+xz9OuA/ dnEjMan8LFngHlH/7wSDegIoObgNpAcJDNW9RpziL49YBQ+u1MmPWrCQ+EkYg+gaZEgh GByDQr8XVADiyyOx5Geo9xGh8+ZOmPjwJobe7aU0l5IiLZJ6rt7xc1nAeaM8elTJbdme r/S5hrg6evkAY8OLGMP/PaaGdCbUCoWqS6v0hgyps31cWa/20KGs33eGvv6vGCJXmZ5+ q7ow== X-Gm-Message-State: AG10YOQ09ZhEcLree3ezGxLlDoL6MbfnHB7PStXJv0aDHqqlRWer5mhNYwqu1zkRsJuakgt7fTFKZ3aenGsaag== X-Received: by 10.107.12.226 with SMTP id 95mr22863538iom.70.1456020506104; Sat, 20 Feb 2016 18:08:26 -0800 (PST) Original-Received: by 10.79.90.71 with HTTP; Sat, 20 Feb 2016 18:07:56 -0800 (PST) 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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:113388 Archived-At: --001a113f8f8e0d713a052c3e31b3 Content-Type: multipart/alternative; boundary=001a113f8f8e0d7135052c3e31b1 --001a113f8f8e0d7135052c3e31b1 Content-Type: text/plain; charset=UTF-8 Hi all! I've produced a patch that should fix this issue. As brought up in this Emacs.SE answer , the main challenge was distinguishing the qualifiers from subshells. To do this, I disallowed leading octothorpes wrapped in parentheses where the parentheses are not separated from other tokens by metacharacters. For qualifiers (which appear after a glob), the fix is trivial. For flags (which appear before the glob), I have to rely on the fact that flags may not contain parentheses themselves to avoid needing more sophisticated parsing. I've tested this against a fairly comprehensive test file, which I've also attached. Thanks, Jonathan --001a113f8f8e0d7135052c3e31b1 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi all!

I've produced a patch th= at should fix this issue. As brought up in this Emacs.SE answer, the main challenge was di= stinguishing the qualifiers from subshells. To do this, I disallowed leadin= g octothorpes wrapped in parentheses where the parentheses are not separate= d from other tokens by metacharacters. For qualifiers (which appear after a= glob), the fix is trivial. For flags (which appear before the glob), I hav= e to rely on the fact that flags may not contain parentheses themselves to = avoid needing more sophisticated parsing.

I've tested thi= s against a fairly comprehensive test file, which I've also attached. <= br>
Thanks,
Jonathan
--001a113f8f8e0d7135052c3e31b1-- --001a113f8f8e0d713a052c3e31b3 Content-Type: application/octet-stream; name="0001-Highlight-zsh-glob-flags-and-qualifiers-in-sh-mode.patch" Content-Disposition: attachment; filename="0001-Highlight-zsh-glob-flags-and-qualifiers-in-sh-mode.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_ikvwz84d0 RnJvbSBhNDc4ZWRlZjJiNTViMDQ5NTEyOGVhYWFkM2ExYTdiMjc3MDYyZmNhIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAw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RoIGAkJyByZW1vdmVkLgotICAgICgiXFwoPzpbXnwmOzw+KClgXFxcIicgXHRcbl1cXHxc XCR7XFwpXFwoIytcXCkiICgxICJfIikpCisgICAgKCJcXCg/OltefCY7PD4oYFxcXCInIFx0XG5d XFx8XFwke1xcKVxcKCMrXFwpIiAoMSAiXyIpKQorICAgIDs7IEluIGFkZGl0aW9uLCBgIycgYXQg dGhlIGJlZ2lubmluZyBvZiBjbG9zZWQgcGFyZW50aGVzZXMKKyAgICA7OyBkb2VzIG5vdCBzdGFy dCBhIGNvbW1lbnQgaWYgdGhlIHBhcmVudGhlc2VzIGFyZSBub3QgaXNvbGF0ZWQKKyAgICA7OyBi eSBtZXRhY2hhcmFjdGVycywgZXhjbHVkaW5nIFsoKV0uCisgICAgOzsgKGUuZy4gYGZvbygjcS8p JyBhbmQgYCgjYilmb28nIGluIHpzaCkKKyAgICAoIltefCY7PD4oYFxcXCInIFx0XG5dKFxcKCMr XFwpIiAoMSAiXyIpKQorICAgICgiKFxcKCNcXClbXildKz8pW158Jjs8PilgXFxcIicgXHRcbl0i ICgxICJfIikpCiAgICAgOzsgSW4gYSAnLi4uJyB0aGUgYmFja3NsYXNoIGlzIG5vdCBlc2NhcGlu Zy4KICAgICAoIlxcKFxcXFxcXCknIiAoMSAoc2gtZm9udC1sb2NrLWJhY2tzbGFzaC1xdW90ZSkp KQogICAgIDs7IE1ha2Ugc3VyZSAkQCBhbmQgJD8gYXJlIGNvcnJlY3RseSByZWNvZ25pemVkIGFz IHNleHBzLgotLSAKMi41LjAKCg== --001a113f8f8e0d713a052c3e31b3 Content-Type: application/x-sh; name="sh_comment_tests.sh" Content-Disposition: attachment; filename="sh_comment_tests.sh" Content-Transfer-Encoding: base64 X-Attachment-Id: f_ikvwz85q1 IyBmb28KZWNobyAjIGZvbwooI2ZvbwogICAgICBlY2hvIGJhcikKZWNobyAkIwplY2hvICQjZm9v CmVjaG8gJHsjZm9vfQplY2hvICJmb28gIyBiYXIiCmVjaG8gJ2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