From: Stefan Monnier Date: Wed, 31 Oct 2012 02:45:34 +0000 (-0400) Subject: * lisp/progmodes/sh-script.el (sh--inside-arithmetic-expression): New func. X-Git-Tag: emacs-24.2.90~205 X-Git-Url: https://code.delx.au/gnu-emacs/commitdiff_plain/b08b6da7fe21922d7e8838847cd065c88597b191 * lisp/progmodes/sh-script.el (sh--inside-arithmetic-expression): New func. (sh-font-lock-open-heredoc): Use it. Fixes: debbugs:12770 --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index bd535894cd..8f4f515374 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 daa8362005..c57468bf52 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 895a9325b7..0636e62a06 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