From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?UTF-8?B?QW5kcmVhcyBSw7ZobGVy?= Newsgroups: gmane.emacs.help Subject: Re: sh-script.el : don't colorize $(( 4 << 2 )) as here-document Date: Sat, 21 Nov 2009 20:27:00 +0100 Message-ID: <4B083F04.1090707@easy-emacs.de> References: <4B06640D.2060206@sdesigns.eu> <4B0822F8.4070909@easy-emacs.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1258841503 31744 80.91.229.12 (21 Nov 2009 22:11:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 21 Nov 2009 22:11:43 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Lennart Borgman Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Nov 21 23:11:36 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NByA9-0003SB-Jj for geh-help-gnu-emacs@m.gmane.org; Sat, 21 Nov 2009 23:10:37 +0100 Original-Received: from localhost ([127.0.0.1]:57618 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NBvdC-0006Rf-AL for geh-help-gnu-emacs@m.gmane.org; Sat, 21 Nov 2009 14:28:26 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NBvcn-0006P0-7x for help-gnu-emacs@gnu.org; Sat, 21 Nov 2009 14:28:01 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NBvci-0006Ln-MF for help-gnu-emacs@gnu.org; Sat, 21 Nov 2009 14:28:00 -0500 Original-Received: from [199.232.76.173] (port=51768 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NBvci-0006LZ-J8 for help-gnu-emacs@gnu.org; Sat, 21 Nov 2009 14:27:56 -0500 Original-Received: from moutng.kundenserver.de ([212.227.17.8]:58623) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NBvci-0005Se-1o for help-gnu-emacs@gnu.org; Sat, 21 Nov 2009 14:27:56 -0500 Original-Received: from [192.168.178.27] (p54BEA529.dip0.t-ipconnect.de [84.190.165.41]) by mrelayeu.kundenserver.de (node=mrbap0) with ESMTP (Nemesis) id 0Mcgwj-1NTs0h31M1-00ISMO; Sat, 21 Nov 2009 20:27:39 +0100 User-Agent: Thunderbird 2.0.0.19 (X11/20081227) In-Reply-To: X-Provags-ID: V01U2FsdGVkX1+uHples9Xyy1gNz3iPlMI+krkvcmjAalyrKo6 tuOgzUnGZBSJTfNJZAYK1wvq+2wN2zJUrrGijQcpZhWe4PiLuw DaUlHn1HAYMBYY7sjuYq7UDEzEs06UyHvzxDuCfibk= X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:70008 Archived-At: Lennart Borgman wrote: > On Sat, Nov 21, 2009 at 6:27 PM, Andreas Röhler > wrote: >> Thomas Gambier wrote: >>> Hello, >>> >>> when I'm writing something like this in bash script value=$(( 4 << 2 )), >>> Emacs keep thinking it's the beginning of here-document and will >>> colorize in yellow all the code below this expression. >>> >>> I've seen that a bug in sh-script.el was corrected so that << between "" >>> won't be interpreted as a beginning of here-document >>> (http://lists.gnu.org/archive/html/help-gnu-emacs/2003-06/msg00158.html). >>> Is there any solution to don't consider also << between $(( )) ? I >>> looked into sh-script.el to try to correct it myself but I'm not very at >>> ease with lisp and regular expression and I didn't find what to change. >>> That's why I ask help here. If it's not possible, I will disable the >>> feature as explained in the previous link. >>> >>> Best regards. >>> >> >> Hi, >> >> AFAIS it's inside >> >> (defconst sh-here-doc-open-re >> (concat "<<-?\\s-*\\\\?\\(\\(?:['\"][^'\"]+['\"]\\|\\sw\\)+\\)" >> sh-escaped-line-re "\\(\n\\)")) >> >> If you say, `sh-here-doc-open-re' must start at bol or >> only permit whitespace before, inserting a ^[ \t]* into >> the regexp >> >> (setq sh-here-doc-open-re >> (concat "^[ \t]*<<-?\\s-*\\\\?\\(\\(?:['\"][^'\"]+['\"]\\|\\sw\\)+\\)" >> sh-escaped-line-re "\\(\n\\)")) >> >> it works here. > > > I have some trouble understanding those regexp. What are the proper > syntax for sh heredoc? > > I have some support for it in MuMaMo and just noticed that the example > Andreas mentioned did not work as I expected. > Hi Lennart, seems you got me. :-) Thanks. Preceding whitespaces resp. tabs are permitted by "-" in "<<-", so it's not possible to exclude it. Well, the only clean solution I see is based on a check if "<<" is inside a command like $(( 4 << 2 )) BTW, how it's called in english? Beside of writing such a check and include it into sh-script.el a quick and dirty solution might be (setq sh-here-doc-open-re (concat "<<-?\\s-" sh-here-document-word)) Then only customized `sh-here-document-word' will be accepted with some whitespace before, nothing else. Works here... Andreas -- https://code.launchpad.net/s-x-emacs-werkstatt/ http://bazaar.launchpad.net/~a-roehler/python-mode/python-mode.el/