;;; sh-script.el --- shell-script editing commands for Emacs -*- lexical-binding:t -*-
-;; Copyright (C) 1993-1997, 1999, 2001-2014 Free Software Foundation,
-;; Inc.
+;; Copyright (C) 1993-1997, 1999, 2001-2014 Free Software Foundation, Inc.
;; Author: Daniel Pfeiffer <occitan@esperanto.org>
;; Version: 2.0f
-;; Maintainer: FSF
+;; Maintainer: emacs-devel@gnu.org
;; Keywords: languages, unix
;; This file is part of GNU Emacs.
'((ash . sh)
(bash . jsh)
(bash2 . jsh)
+ (dash . ash)
(dtksh . ksh)
(es . rc)
(itcsh . tcsh)
es Extensible Shell
sh Bourne Shell
ash Almquist Shell
+ dash Debian Almquist Shell
jsh Bourne Shell with Job Control
bash GNU Bourne Again Shell
ksh88 Korn Shell '88
posix IEEE 1003.2 Shell Standard
wsh ? Shell"
:type '(repeat (cons symbol symbol))
+ :version "24.4" ; added dash
:group 'sh-script)
(let ((ppss (syntax-ppss pos)))
(when (nth 1 ppss)
(goto-char (nth 1 ppss))
- (pcase (char-after)
- ;; $((...)) or $[...] or ${...}.
- (`?\( (and (eq ?\( (char-before))
- (eq ?\$ (char-before (1- (point))))))
- ((or `?\{ `?\[) (eq ?\$ (char-before))))))))
+ (or
+ (pcase (char-after)
+ ;; ((...)) or $((...)) or $[...] or ${...}. Nested
+ ;; parenthesis can occur inside the first of these forms, so
+ ;; parse backward recursively.
+ (`?\( (eq ?\( (char-before)))
+ ((or `?\{ `?\[) (eq ?\$ (char-before))))
+ (sh--inside-noncommand-expression (1- (point))))))))
(defun sh-font-lock-open-heredoc (start string eol)
"Determine the syntax of the \\n after a <<EOF.
(or (not (looking-back "[^<]<<"))
(save-excursion
(backward-char 2)
- (sh-quoted-p))
+ (or (sh-quoted-p)
+ (sh--inside-noncommand-expression (point))))
(nth 8 (syntax-ppss))
(let ((tabs (if (string-match "\\`-" sh-here-document-word)
(make-string (/ (current-indentation) tab-width) ?\t)