aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2012-10-30 22:45:34 -0400
committerStefan Monnier2012-10-30 22:45:34 -0400
commitb08b6da7fe21922d7e8838847cd065c88597b191 (patch)
treedde470b2f64a1fc9d68550f45266528eec27cb10
parent86a7968c86b150c59ef62d27d2b139be18926fc2 (diff)
downloademacs-b08b6da7fe21922d7e8838847cd065c88597b191.tar.gz
emacs-b08b6da7fe21922d7e8838847cd065c88597b191.zip
* lisp/progmodes/sh-script.el (sh--inside-arithmetic-expression): New func.
(sh-font-lock-open-heredoc): Use it. Fixes: debbugs:12770
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/progmodes/sh-script.el12
-rwxr-xr-xtest/indent/perl.perl5
-rwxr-xr-xtest/indent/shell.sh4
4 files changed, 25 insertions, 1 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index bd535894cdf..8f4f5153747 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
12012-10-31 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * progmodes/sh-script.el (sh--inside-arithmetic-expression): New func.
4 (sh-font-lock-open-heredoc): Use it (bug#12770).
5
12012-10-30 Glenn Morris <rgm@gnu.org> 62012-10-30 Glenn Morris <rgm@gnu.org>
2 7
3 * emacs-lisp/cl-extra.el (cl-mapc): Add autoload cookie. Doc fix. 8 * emacs-lisp/cl-extra.el (cl-mapc): Add autoload cookie. Doc fix.
diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el
index daa83620051..c57468bf52f 100644
--- a/lisp/progmodes/sh-script.el
+++ b/lisp/progmodes/sh-script.el
@@ -940,6 +940,15 @@ See `sh-feature'.")
940 (concat "<<-?\\s-*\\\\?\\(\\(?:['\"][^'\"]+['\"]\\|\\sw\\|[-/~._]\\)+\\)" 940 (concat "<<-?\\s-*\\\\?\\(\\(?:['\"][^'\"]+['\"]\\|\\sw\\|[-/~._]\\)+\\)"
941 sh-escaped-line-re "\\(\n\\)"))) 941 sh-escaped-line-re "\\(\n\\)")))
942 942
943(defun sh--inside-arithmetic-expression (pos)
944 (save-excursion
945 (let ((ppss (syntax-ppss pos)))
946 (when (nth 1 ppss)
947 (goto-char (nth 1 ppss))
948 (and (eq ?\( (char-after))
949 (eq ?\( (char-before))
950 (eq ?\$ (char-before (1- (point)))))))))
951
943(defun sh-font-lock-open-heredoc (start string eol) 952(defun sh-font-lock-open-heredoc (start string eol)
944 "Determine the syntax of the \\n after a <<EOF. 953 "Determine the syntax of the \\n after a <<EOF.
945START is the position of <<. 954START is the position of <<.
@@ -948,7 +957,8 @@ INDENTED is non-nil if the here document's content (and the EOF mark) can
948be indented (i.e. a <<- was used rather than just <<). 957be indented (i.e. a <<- was used rather than just <<).
949Point is at the beginning of the next line." 958Point is at the beginning of the next line."
950 (unless (or (memq (char-before start) '(?< ?>)) 959 (unless (or (memq (char-before start) '(?< ?>))
951 (sh-in-comment-or-string start)) 960 (sh-in-comment-or-string start)
961 (sh--inside-arithmetic-expression start))
952 ;; We're looking at <<STRING, so we add "^STRING$" to the syntactic 962 ;; We're looking at <<STRING, so we add "^STRING$" to the syntactic
953 ;; font-lock keywords to detect the end of this here document. 963 ;; font-lock keywords to detect the end of this here document.
954 (let ((str (replace-regexp-in-string "['\"]" "" string)) 964 (let ((str (replace-regexp-in-string "['\"]" "" string))
diff --git a/test/indent/perl.perl b/test/indent/perl.perl
new file mode 100755
index 00000000000..2411c96a5e4
--- /dev/null
+++ b/test/indent/perl.perl
@@ -0,0 +1,5 @@
1#!/usr/bin/perl
2# -*- eval: (bug-reference-mode 1) -*-
3
4$fileType_filesButNot # bug#12373?
5 = join( '|', map { quotemeta($_).'$' } @{$fileType->{filesButNot}} );
diff --git a/test/indent/shell.sh b/test/indent/shell.sh
index 895a9325b7e..0636e62a062 100755
--- a/test/indent/shell.sh
+++ b/test/indent/shell.sh
@@ -5,6 +5,10 @@ setlock -n /tmp/getmail.lock && echo getmail isn\'t running
5 5
6# adsgsdg 6# adsgsdg
7 7
8echo -n $(( 5 << 2 ))
9# This should not be treated as a heredoc (bug#12770).
102
11
8declare -a VERSION 12declare -a VERSION
9for i in $(ls "$PREFIX/sbin") ; do 13for i in $(ls "$PREFIX/sbin") ; do
10 echo -e $N')' $i 14 echo -e $N')' $i