]> code.delx.au - gnu-emacs/commitdiff
* lisp/progmodes/sh-script.el (sh--inside-arithmetic-expression): New func.
authorStefan Monnier <monnier@iro.umontreal.ca>
Wed, 31 Oct 2012 02:45:34 +0000 (22:45 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Wed, 31 Oct 2012 02:45:34 +0000 (22:45 -0400)
(sh-font-lock-open-heredoc): Use it.

Fixes: debbugs:12770
lisp/ChangeLog
lisp/progmodes/sh-script.el
test/indent/perl.perl [new file with mode: 0755]
test/indent/shell.sh

index bd535894cdfd0cfb33329ea59d155e3ffb60542f..8f4f5153747dad4dfeacd8d8891283d5749f2c99 100644 (file)
@@ -1,3 +1,8 @@
+2012-10-31  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * progmodes/sh-script.el (sh--inside-arithmetic-expression): New func.
+       (sh-font-lock-open-heredoc): Use it (bug#12770).
+
 2012-10-30  Glenn Morris  <rgm@gnu.org>
 
        * emacs-lisp/cl-extra.el (cl-mapc): Add autoload cookie.  Doc fix.
index daa83620051ddd21efe0fbe16d1eb4f6410a741f..c57468bf52ffba3fb15781b40a3cb830fa9fad0f 100644 (file)
@@ -940,6 +940,15 @@ See `sh-feature'.")
     (concat "<<-?\\s-*\\\\?\\(\\(?:['\"][^'\"]+['\"]\\|\\sw\\|[-/~._]\\)+\\)"
             sh-escaped-line-re "\\(\n\\)")))
 
+(defun sh--inside-arithmetic-expression (pos)
+  (save-excursion
+    (let ((ppss (syntax-ppss pos)))
+      (when (nth 1 ppss)
+        (goto-char (nth 1 ppss))
+        (and (eq ?\( (char-after))
+             (eq ?\( (char-before))
+             (eq ?\$ (char-before (1- (point)))))))))
+
 (defun sh-font-lock-open-heredoc (start string eol)
   "Determine the syntax of the \\n after a <<EOF.
 START is the position of <<.
@@ -948,7 +957,8 @@ INDENTED is non-nil if the here document's content (and the EOF mark) can
 be indented (i.e. a <<- was used rather than just <<).
 Point is at the beginning of the next line."
   (unless (or (memq (char-before start) '(?< ?>))
-             (sh-in-comment-or-string start))
+             (sh-in-comment-or-string start)
+              (sh--inside-arithmetic-expression start))
     ;; We're looking at <<STRING, so we add "^STRING$" to the syntactic
     ;; font-lock keywords to detect the end of this here document.
     (let ((str (replace-regexp-in-string "['\"]" "" string))
diff --git a/test/indent/perl.perl b/test/indent/perl.perl
new file mode 100755 (executable)
index 0000000..2411c96
--- /dev/null
@@ -0,0 +1,5 @@
+#!/usr/bin/perl
+# -*- eval: (bug-reference-mode 1) -*-
+
+$fileType_filesButNot           # bug#12373?
+    = join( '|', map { quotemeta($_).'$' } @{$fileType->{filesButNot}} );
index 895a9325b7ed85a38cc0ac7b95a57cf3bc2fec06..0636e62a062523f6dee08301e5fc9abc0572731b 100755 (executable)
@@ -5,6 +5,10 @@ setlock -n /tmp/getmail.lock && echo getmail isn\'t running
 
 # adsgsdg
 
+echo -n $(( 5 << 2 ))
+# This should not be treated as a heredoc (bug#12770).
+2
+
 declare -a VERSION
 for i in $(ls "$PREFIX/sbin") ; do
     echo -e $N')' $i