> I saved the following into a file called script.sh and then visited
> the file. The "echo a backquote" comment was coloured as if it was a
> string, as was the rest of the file after the comment:
> ------------------------------------------------------------------------
> #!/bin/sh
> echo "\`" # echo a backquote
> echo hello
> echo hello
> echo hello
> echo "hello"
> ------------------------------------------------------------------------
> I changed the file, removing the last 2 double quotes, and re-visited
> the file. The comment was then coloured correctly, as was the rest of
> the file:
> ------------------------------------------------------------------------
> #!/bin/sh
> echo "\`" # echo a backquote
> echo hello
> echo hello
> echo hello
> echo hello
> ------------------------------------------------------------------------
> It seems that the presence of double quotes in the file after the \`
> breaks highlighting.
No, it's the backslash before the ` which confused Emacs. I've installed
the patch below which I believe fixes it. But this code that tries to
handle backquotes and $(..) inside strings is not very reliable. Other than
the problem mentioned in the patch, there's also the fact that
echo "$(echo ") there)")"
doesn't recognize that the `there' is still within the $(...).
It's a difficult problem.
Stefan
Index: lisp/progmodes/sh-script.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/progmodes/sh-script.el,v
retrieving revision 1.181
diff -u -r1.181 sh-script.el
--- lisp/progmodes/sh-script.el 3 Jun 2006 08:37:49 -0000 1.181
+++ lisp/progmodes/sh-script.el 17 Jul 2006 21:06:14 -0000
@@ -982,7 +982,10 @@
(defun sh-quoted-subshell (limit)
"Search for a subshell embedded in a string. Find all the unescaped
\" characters within said subshell, remembering that subshells can nest."
- (if (re-search-forward "\"\\(?:.\\|\n\\)*?\\(\\$(\\|`\\)" limit t)
+ ;; FIXME: This can (and often does) match multiple lines, yet it makes no
+ ;; effort to handle multiline cases correctly, so it ends up being
+ ;; rather flakey.
+ (if (re-search-forward
"\"\\(?:\\(?:.\\|\n\\)*?[^\\]\\(\\\\\\\\\\)*\\)?\\(\\$(\\|`\\)" limit t)
;; bingo we have a $( or a ` inside a ""
(let ((char (char-after (point)))
(continue t)
_______________________________________________
emacs-pretest-bug mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug