From 3618df4590230a7321aea685705eda63bf47116b Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Tue, 30 Oct 2012 23:10:25 -0400 Subject: [PATCH] * lisp/progmodes/sh-script.el (sh--inside-noncommand-expression): Rename from sh--inside-arithmetic-expression, handle more cases. Fixes: debbugs:11263 --- lisp/ChangeLog | 4 ++++ lisp/progmodes/sh-script.el | 12 +++++++----- test/indent/shell.sh | 5 +++++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 8f4f5153747..88ea199cd20 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,9 @@ 2012-10-31 Stefan Monnier + * progmodes/sh-script.el (sh--inside-noncommand-expression): + Rename from sh--inside-arithmetic-expression, handle more cases + (bug#11263). + * progmodes/sh-script.el (sh--inside-arithmetic-expression): New func. (sh-font-lock-open-heredoc): Use it (bug#12770). diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index c57468bf52f..5af14e51f49 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -940,14 +940,16 @@ See `sh-feature'.") (concat "<<-?\\s-*\\\\?\\(\\(?:['\"][^'\"]+['\"]\\|\\sw\\|[-/~._]\\)+\\)" sh-escaped-line-re "\\(\n\\)"))) -(defun sh--inside-arithmetic-expression (pos) +(defun sh--inside-noncommand-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))))))))) + (pcase (char-after) + ;; $((...)) or $[...] or ${...}. + (`?\( (and (eq ?\( (char-before)) + (eq ?\$ (char-before (1- (point)))))) + ((or `?\{ `?\[) (eq ?\$ (char-before)))))))) (defun sh-font-lock-open-heredoc (start string eol) "Determine the syntax of the \\n after a <)) (sh-in-comment-or-string start) - (sh--inside-arithmetic-expression start)) + (sh--inside-noncommand-expression start)) ;; We're looking at <