* sh-script.el : don't colorize $(( 4 << 2 )) as here-document
@ 2009-11-20 9:40 Thomas Gambier
2009-11-21 17:27 ` Andreas Röhler
0 siblings, 1 reply; 7+ messages in thread
From: Thomas Gambier @ 2009-11-20 9:40 UTC (permalink / raw)
To: help-gnu-emacs
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.
--
Thomas Gambier.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: sh-script.el : don't colorize $(( 4 << 2 )) as here-document
2009-11-20 9:40 sh-script.el : don't colorize $(( 4 << 2 )) as here-document Thomas Gambier
@ 2009-11-21 17:27 ` Andreas Röhler
2009-11-21 17:38 ` Lennart Borgman
0 siblings, 1 reply; 7+ messages in thread
From: Andreas Röhler @ 2009-11-21 17:27 UTC (permalink / raw)
To: Thomas Gambier; +Cc: help-gnu-emacs
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.
HTH
Andreas
--
https://code.launchpad.net/s-x-emacs-werkstatt/
http://bazaar.launchpad.net/~a-roehler/python-mode/python-mode.el/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: sh-script.el : don't colorize $(( 4 << 2 )) as here-document
2009-11-21 17:27 ` Andreas Röhler
@ 2009-11-21 17:38 ` Lennart Borgman
2009-11-21 19:27 ` Andreas Röhler
0 siblings, 1 reply; 7+ messages in thread
From: Lennart Borgman @ 2009-11-21 17:38 UTC (permalink / raw)
To: Andreas Röhler; +Cc: help-gnu-emacs
On Sat, Nov 21, 2009 at 6:27 PM, Andreas Röhler
<andreas.roehler@easy-emacs.de> 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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: sh-script.el : don't colorize $(( 4 << 2 )) as here-document
2009-11-21 17:38 ` Lennart Borgman
@ 2009-11-21 19:27 ` Andreas Röhler
2009-11-24 9:32 ` Thomas Gambier
0 siblings, 1 reply; 7+ messages in thread
From: Andreas Röhler @ 2009-11-21 19:27 UTC (permalink / raw)
To: Lennart Borgman; +Cc: help-gnu-emacs
Lennart Borgman wrote:
> On Sat, Nov 21, 2009 at 6:27 PM, Andreas Röhler
> <andreas.roehler@easy-emacs.de> 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/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: sh-script.el : don't colorize $(( 4 << 2 )) as here-document
2009-11-21 19:27 ` Andreas Röhler
@ 2009-11-24 9:32 ` Thomas Gambier
0 siblings, 0 replies; 7+ messages in thread
From: Thomas Gambier @ 2009-11-24 9:32 UTC (permalink / raw)
To: Andreas Röhler, Stefan Monnier; +Cc: help-gnu-emacs
Hi,
Andreas Röhler wrote:
>
> 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...
>
>
>
It worked here except I had to change the variable name
"sh-here-document-word" because it was used as the word to insert after
typing <<. I will use this for now.
Thanks a lot.
Stefan Monnier wrote:
>> 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.
>>
>
> Ever heard of M-x report-emacs-bug?
>
>
You're right, I've just send a bug report using this function.
So I'm happy with Andreas' solution and hopefully it will be corrected
in next version of sh-script.el
Regards.
Thomas.
^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <mailman.11231.1258815847.2239.help-gnu-emacs@gnu.org>]
* sh-script.el : don't colorize $(( 4 << 2 )) as here-document
@ 2009-11-19 17:18 Thomas Gambier
0 siblings, 0 replies; 7+ messages in thread
From: Thomas Gambier @ 2009-11-19 17:18 UTC (permalink / raw)
To: help-gnu-emacs
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.
--
Thomas Gambier.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2009-11-24 9:32 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-20 9:40 sh-script.el : don't colorize $(( 4 << 2 )) as here-document Thomas Gambier
2009-11-21 17:27 ` Andreas Röhler
2009-11-21 17:38 ` Lennart Borgman
2009-11-21 19:27 ` Andreas Röhler
2009-11-24 9:32 ` Thomas Gambier
[not found] <mailman.11231.1258815847.2239.help-gnu-emacs@gnu.org>
2009-11-24 2:51 ` Stefan Monnier
-- strict thread matches above, loose matches on Subject: below --
2009-11-19 17:18 Thomas Gambier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).