Subject: bug#20101: 24.4; sh-mode sets indent-line-function globally

From: Jens Kjerrström <[email-masked]>
Date: Fri, 13 Mar 2015 18:55:52 +0100

- Create a new buffer "*apa*". Should be in fundamental mode. Press
  return, notice no indentation. Check the value of variable
  indent-line-function, should be indent-relative.

- Create a new buffer "*bepa*", insert "#!/bin/tcsh" on the first
  line. M-x sh-mode. The message "No indentation for this shell type."
  should appear. Press return in buffer "*bepa*", notice incorrect
  indentation.

- Switch to buffer "*apa*", press return, notice that this now indents
  lines too. The value of indent-line-function is now
  sh-basic-indent-line.

This is likely due to the following lines in sh-set-shell in sh-mode.el:

...
(message "No indentation for this shell type.")
(setq indent-line-function 'sh-basic-indent-line))
...

The above lines are the else branch of an if, in the if branch
setq-local is used.

In GNU Emacs 24.4.1 (i686-pc-mingw32)
 of 2014-10-24 on LEG570
Windowing system distributor `Microsoft Corp.', version 6.3.9600
Configured using:
 `configure --prefix=/c/usr'

Important settings:
  value of $LANG: SVE
  locale-coding-system: cp1252

Major mode: Lisp Interaction

Minor modes in effect:
  global-company-mode: t
  company-mode: t
  helm-mode: t
  shell-dirtrack-mode: t
  helm-match-plugin-mode: t
  helm-occur-match-plugin-mode: t
  show-paren-mode: t
  delete-selection-mode: t
  recentf-mode: t
  tooltip-mode: t
  electric-indent-mode: t
  mouse-wheel-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
  line-number-mode: t
  transient-mark-mode: t

Recent input:
M-x r e p o r t <return>

Recent messages:
Loading c:/Users/Jens/AppData/Roaming/.emacs.d/recentf...done
Cleaning up the recentf list...done (0 removed)
zlib library not found
ad-handle-definition: `tramp-read-passwd' got redefined
Helm completion enabled
Key Chord mode on
For information about GNU Emacs and the GNU system, type C-h C-a.
Making helm-map local to *helm M-x* while let-bound!
Making helm-sources local to *helm M-x* while let-bound!

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rfc822 mml mml-sec mm-decode
mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
sendmail rfc2047 rfc2045 ietf-drums mail-utils helm-command helm-elisp
helm-eval eldoc company-files company-oddmuse company-keywords
company-etags etags company-gtags company-dabbrev-code company-dabbrev
company-capf company-cmake company-ropemacs company-xcode company-clang
company-semantic company-eclim company-template company-css company-nxml
company-bbdb company jk-key-chords key-chord helm-mode helm-files rx
image-dired tramp tramp-compat tramp-loaddefs trampver shell dired-x
dired-aux ffap thingatpt helm-buffers helm-elscreen helm-tags
helm-bookmark helm-adaptive helm-info helm-net browse-url xml url
url-proxy url-privacy url-expand url-methods url-history url-cookie
url-domsuf url-util url-parse auth-source gnus-util mm-util mail-prsvr
password-cache url-vars mailcap bookmark pp helm-locate helm-help
helm-org org org-macro org-footnote org-pcomplete pcomplete org-list
org-faces org-entities noutline outline org-version ob-emacs-lisp ob
ob-tangle ob-ref ob-lob ob-table ob-exp org-src ob-keys ob-comint
ob-core ob-eval org-compat org-macs org-loaddefs format-spec find-func
cal-menu calendar cal-loaddefs helm-match-plugin helm-grep helm-regexp
helm-plugin grep helm-external helm-utils dired compile comint
ansi-color ring helm advice help-fns easy-mmode edmacro kmacro cl-macs
gv helm-source eieio byte-opt bytecomp byte-compile cconv eieio-core
info paren delsel jk-edit-functions jk-styles recentf tree-widget
wid-edit cl-loaddefs cl-lib easymenu package epg-config time-date
tooltip electric uniquify ediff-hook vc-hooks lisp-float-type mwheel
dos-w32 ls-lisp w32-common-fns disp-table w32-win w32-vars tool-bar dnd
fontset image regexp-opt fringe tabulated-list newcomment lisp-mode
prog-mode register page menu-bar rfn-eshadow timer select scroll-bar
mouse jit-lock font-lock syntax facemenu font-core frame cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev
minibuffer 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 make-network-process
w32notify w32 multi-tty emacs)

Memory information:
((conses 8 246070 8936)
 (symbols 32 34844 0)
 (miscs 32 76 161)
 (strings 16 69440 9436)
 (string-bytes 1 1982791)
 (vectors 8 27246)
 (vector-slots 4 577293 8296)
 (floats 8 165 76)
 (intervals 28 1659 624)
 (buffers 508 13))