help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sh-script.el : don't colorize $(( 4 << 2 )) as here-document


From: Andreas Röhler
Subject: Re: sh-script.el : don't colorize $(( 4 << 2 )) as here-document
Date: Sat, 21 Nov 2009 20:27:00 +0100
User-agent: Thunderbird 2.0.0.19 (X11/20081227)

Lennart Borgman wrote:
> On Sat, Nov 21, 2009 at 6:27 PM, Andreas Röhler
> <address@hidden> 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/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]