;;; 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-2015 Free Software Foundation, Inc.
;; Author: Daniel Pfeiffer <occitan@esperanto.org>
;; Version: 2.0f
\\[backward-delete-char-untabify] Delete backward one position, even if it was a tab.
-\\[newline-and-indent] Delete unquoted space and indent new line same as this one.
\\[sh-end-of-command] Go to end of successive commands.
\\[sh-beginning-of-command] Go to beginning of successive commands.
\\[sh-set-shell] Set this buffer's shell, and maybe its magic number.
(and (numberp indent) (numberp initial)
(<= indent initial)))))
`(column . ,(+ initial sh-indentation)))
- (`(:before . ,(or `"(" `"{" `"["))
+ (`(:before . ,(or `"(" `"{" `"[" "while" "if" "for" "case"))
(if (not (smie-rule-prev-p "&&" "||" "|"))
(when (smie-rule-hanging-p)
(smie-rule-parent))
(unless (smie-rule-bolp)
- (smie-backward-sexp 'halfexp)
+ (while (equal "|" (nth 2 (smie-backward-sexp 'halfexp))))
`(column . ,(smie-indent-virtual)))))
;; FIXME: Maybe this handling of ;; should be made into
;; a smie-rule-terminator function that takes the substitute ";" as arg.
(sh-make-vars-local))
(message "Indentation setup for shell type %s" sh-shell))
(message "No indentation for this shell type.")
- (setq indent-line-function 'sh-basic-indent-line))
+ (setq-local indent-line-function 'sh-basic-indent-line))
(when font-lock-mode
(setq font-lock-set-defaults nil)
(font-lock-set-defaults)
(current-column)))
current)
(save-excursion
- (indent-to (if (eq this-command 'newline-and-indent)
+ (indent-to (if (or (eq this-command 'newline-and-indent)
+ (and electric-indent-mode (eq this-command 'newline)))
previous
(if (< (current-column)
(setq current (progn (back-to-indentation)
(or arg (sh--maybe-here-document)))
(defun sh--maybe-here-document ()
- (or (not (looking-back "[^<]<<"))
+ (or (not (looking-back "[^<]<<" (line-beginning-position)))
(save-excursion
(backward-char 2)
(or (sh-quoted-p)