Subject: bug#31609: 25.3; sh-mode is confused about bash extglobs in case patterns

From: Ville Skyttä <[email-masked]>
Date: Sun, 27 May 2018 18:44:08 +0200

When using bash's extended globbing constructs such as @(...), +(...),
!(...), *(...) in case patterns, sh-mode gets confused and indentation
         no longer works properly.

For example:

case $foo in
    @(bar|quux))
                <-- TAB brings the cursor here
        <-- ...whereas I would have expected it to be here
[...]

The indentation continues to be off for the remainder of the file,
i.e. after the ;; and terminating `esac'.

This is a largish annoyance for me when working with bash-completion,
which currently uses these constructs quite a bit in case patterns, and
more is on the way.

In GNU Emacs 25.3.2 (x86_64-pc-linux-gnu, GTK+ Version 3.22.25)
 of 2018-04-19 built on lgw01-amd64-032
Windowing system distributor 'The X.Org Foundation', version 11.0.11905000
System Description: Ubuntu 17.10

Configured using:
 'configure --build=x86_64-linux-gnu --prefix=/usr
 '--includedir=${prefix}/include' '--mandir=${prefix}/share/man'
 '--infodir=${prefix}/share/info' --sysconfdir=/etc --localstatedir=/var
 --disable-silent-rules '--libdir=${prefix}/lib/x86_64-linux-gnu'
 '--libexecdir=${prefix}/lib/x86_64-linux-gnu' --disable-maintainer-mode
 --disable-dependency-tracking --prefix=/usr --sharedstatedir=/var/lib
 --program-suffix=25 --with-modules --with-x=yes --with-x-toolkit=gtk3
 'CFLAGS=-g -O2
 -fdebug-prefix-map=/build/emacs25-VAyiBS/emacs25-25.3~1.gite0284ab=.
-fstack-protector-strong
 -Wformat -Werror=format-security -no-pie' 'CPPFLAGS=-Wdate-time
 -D_FORTIFY_SOURCE=2' 'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro
 -no-pie''

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF GSETTINGS
NOTIFY LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 MODULES

Important settings:
  value of $LC_MONETARY: fi_FI.UTF-8
  value of $LC_NUMERIC: fi_FI.UTF-8
  value of $LC_TIME: fi_FI.UTF-8
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  shell-dirtrack-mode: t
  global-company-mode: t
  company-mode: t
  projectile-global-mode: t
  projectile-mode: t
  which-function-mode: t
  show-paren-mode: t
  global-hl-line-mode: t
  editorconfig-mode: t
  global-flycheck-mode: t
  flycheck-mode: t
  override-global-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent messages:
Loading editorconfig...done
Loading hl-line...done
Loading paren...done
Loading which-func...done
Turn on helm-projectile key bindings
For information about GNU Emacs and the GNU system, type C-h C-a.

Load-path shadows:
/home/scop/.emacs.d/elpa/editorconfig-0.7.11/editorconfig-autoloads
hides /usr/share/emacs/site-lisp/elpa-src/editorconfig-0.4/editorconfig-autoloads
/home/scop/.emacs.d/elpa/editorconfig-0.7.11/editorconfig-pkg hides
/usr/share/emacs/site-lisp/elpa-src/editorconfig-0.4/editorconfig-pkg
/home/scop/.emacs.d/elpa/editorconfig-0.7.11/editorconfig hides
/usr/share/emacs/site-lisp/elpa-src/editorconfig-0.4/editorconfig
/usr/share/emacs/site-lisp/dictionaries-common/ispell hides
/usr/share/emacs/25.3/lisp/textmodes/ispell
/usr/share/emacs/site-lisp/dictionaries-common/flyspell hides
/usr/share/emacs/25.3/lisp/textmodes/flyspell
/home/scop/.emacs.d/elpa/let-alist-1.0.5/let-alist hides
/usr/share/emacs/25.3/lisp/emacs-lisp/let-alist

Features:
(shadow sort mail-extr emacsbug message dired rfc822 mml mml-sec epg
mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils
mailheader sendmail rfc2047 rfc2045 ietf-drums mail-utils
company-oddmuse company-keywords company-etags etags xref project
company-gtags company-dabbrev-code company-dabbrev company-files
company-capf company-cmake company-xcode company-clang company-semantic
company-eclim company-template company-css company-nxml company-bbdb
company-anaconda anaconda-mode pythonic f s python tramp-sh url
url-proxy url-privacy url-expand url-methods url-history url-cookie
url-domsuf url-util url-parse url-vars mailcap tramp tramp-compat
auth-source gnus-util mm-util help-fns mail-prsvr password-cache
tramp-loaddefs trampver ucs-normalize shell pcomplete company
helm-projectile helm-files helm-tags helm-buffers helm-locate helm-types
projectile grep compile comint ansi-color ring ibuf-ext ibuffer
thingatpt helm-swoop helm-grep helm-regexp format-spec helm-utils
helm-help helm helm-source cl-seq eieio-compat eieio eieio-core cl-macs
helm-multi-match helm-lib advice async iso-transl edmacro kmacro
jka-compr which-func imenu paren hl-line editorconfig cus-start cus-load
flycheck json map find-func subr-x dash use-package diminish bind-key
easy-mmode finder-inf rx info package epg-config seq byte-opt gv
bytecomp byte-compile cl-extra help-mode easymenu cconv cl-loaddefs
pcase cl-lib time-date mule-util tooltip eldoc electric uniquify
ediff-hook vc-hooks lisp-float-type mwheel x-win term/common-win x-dnd
tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment
elisp-mode lisp-mode prog-mode register page menu-bar rfn-eshadow timer
select scroll-bar mouse jit-lock font-lock syntax facemenu font-core
frame cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan
thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian
slovak czech european ethiopic indian cyrillic chinese charscript
case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer
cl-preloaded nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote dbusbind inotify
dynamic-setting system-font-setting font-render-setting move-toolbar gtk
x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 16 324999 11377)
 (symbols 48 32532 0)
 (miscs 40 452 122)
 (strings 32 60098 10582)
 (string-bytes 1 1978257)
 (vectors 16 52692)
 (vector-slots 8 860266 5620)
 (floats 8 424 17)
 (intervals 56 309 71)
 (buffers 976 17))