From b08b6da7fe21922d7e8838847cd065c88597b191 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Tue, 30 Oct 2012 22:45:34 -0400 Subject: [PATCH] * lisp/progmodes/sh-script.el (sh--inside-arithmetic-expression): New func. (sh-font-lock-open-heredoc): Use it. Fixes: debbugs:12770 --- lisp/ChangeLog | 5 +++++ lisp/progmodes/sh-script.el | 12 +++++++++++- test/indent/perl.perl | 5 +++++ test/indent/shell.sh | 4 ++++ 4 files changed, 25 insertions(+), 1 deletion(-) create mode 100755 test/indent/perl.perl diff --git a/lisp/ChangeLog b/lisp/ChangeLog index bd535894cdf..8f4f5153747 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2012-10-31 Stefan Monnier + + * progmodes/sh-script.el (sh--inside-arithmetic-expression): New func. + (sh-font-lock-open-heredoc): Use it (bug#12770). + 2012-10-30 Glenn Morris * 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'.") (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 <)) - (sh-in-comment-or-string start)) + (sh-in-comment-or-string start) + (sh--inside-arithmetic-expression start)) ;; We're looking at <{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 # 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 -- 2.39.2