]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/sh-script.el
from trunk
[gnu-emacs] / lisp / progmodes / sh-script.el
index 27dbbb4f9502847bcfc23c3a8bdaee9c3088d79d..ca0971bf675f753c29a700be19056314f0d9112d 100644 (file)
@@ -1,7 +1,7 @@
 ;;; sh-script.el --- shell-script editing commands for Emacs
 
-;; Copyright (C) 1993, 1994, 1995, 1996, 1997, 1999, 2001, 2002,
-;;  2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+;; Copyright (C) 1993, 1994, 1995, 1996, 1997, 1999, 2001, 2002, 2003,
+;;  2004, 2005, 2006, 2007, 2008, 2009, 2010  Free Software Foundation, Inc.
 
 ;; Author: Daniel Pfeiffer <occitan@esperanto.org>
 ;; Version: 2.0f
@@ -244,12 +244,12 @@ By default we have the following three hierarchies:
 
 csh            C Shell
   jcsh         C Shell with Job Control
-  tcsh         Turbo C Shell
-    itcsh      ? Turbo C Shell
+  tcsh         TENEX C Shell
+    itcsh      Ian's TENEX C Shell
 rc             Plan 9 Shell
   es           Extensible Shell
 sh             Bourne Shell
-  ash          ? Shell
+  ash          Almquist Shell
   jsh          Bourne Shell with Job Control
     bash       GNU Bourne Again Shell
     ksh88      Korn Shell '88
@@ -495,8 +495,13 @@ This is buffer-local in every such buffer.")
                  :help "Set the indentation for the current line"))
 
     (define-key menu-map [sh-pair]
-      '(menu-item "Insert braces and quotes in pairs" (lambda () (interactive) (setq skeleton-pair (not skeleton-pair)))
-                 :button (:toggle . skeleton-pair)
+      '(menu-item "Insert braces and quotes in pairs"
+                 (lambda ()
+                   (interactive)
+                   (require 'skeleton)
+                   (setq skeleton-pair (not skeleton-pair)))
+                 :button (:toggle . (and (boundp 'skeleton-pair)
+                                         skeleton-pair))
                  :help "Inserting a brace or quote automatically inserts the matching pair"))
 
     (define-key menu-map [sh-s0] '("--"))
@@ -884,9 +889,7 @@ See `sh-feature'.")
      (:weight bold)))
   "Face to show quoted execs like ``"
   :group 'sh-indentation)
-
-;; backward-compatibility alias
-(put 'sh-heredoc-face 'face-alias 'sh-heredoc)
+(define-obsolete-face-alias 'sh-heredoc-face 'sh-heredoc "22.1")
 (defvar sh-heredoc-face 'sh-heredoc)
 
 (defface sh-escaped-newline '((t :inherit font-lock-string-face))
@@ -1003,7 +1006,7 @@ If non-nil INDENTED indicates that the EOF was indented."
 (defun sh-font-lock-open-heredoc (start string)
   "Determine the syntax of the \\n after a <<EOF.
 START is the position of <<.
-STRING is the actual word used as delimiter (f.ex. \"EOF\").
+STRING is the actual word used as delimiter (e.g. \"EOF\").
 INDENTED is non-nil if the here document's content (and the EOF mark) can
 be indented (i.e. a <<- was used rather than just <<).
 Point is at the beginning of the next line."
@@ -1058,7 +1061,9 @@ subshells can nest."
                                (< (point) limit)))
         ;; unescape " inside a $( ... ) construct.
         (case (char-after)
-          (?\' (forward-char 1) (skip-chars-forward "^'" limit))
+          (?\' (case state
+                 (double-quote nil)
+                 (t (forward-char 1) (skip-chars-forward "^'" limit))))
           (?\\ (forward-char 1))
           (?\" (case state
                  (double-quote (setq state (pop states)))
@@ -1104,6 +1109,9 @@ subshells can nest."
                  (when (memq (char-before) '(?\" ?\'))
                    (condition-case nil (progn (backward-sexp 1) t)
                      (error nil)))))
+         ;; Patterns can be preceded by an open-paren (Bug#1320).
+         (if (eq (char-before (point)) ?\()
+             (backward-char 1))
           (while (progn
                    (forward-comment (- (point-max)))
                    ;; Maybe we've bumped into an escaped newline.
@@ -2591,7 +2599,7 @@ If AND-MOVE is non-nil then move to end of word."
        (goto-char where))
     (prog1
        (buffer-substring (point)
-                         (progn (skip-chars-forward "^ \t\n;&|()")(point)))
+                         (progn (skip-chars-forward "^ \t\n;&|")(point)))
       (unless and-move
        (goto-char start)))))
 
@@ -2970,8 +2978,7 @@ so that `occur-next' and `occur-prev' will work."
 ;;
 ;; (defun what-i-learned (list)
 ;;   (let ((p list))
-;;     (save-excursion
-;;       (set-buffer "*scratch*")
+;;     (with-current-buffer "*scratch*"
 ;;       (goto-char (point-max))
 ;;       (insert "(setq\n")
 ;;       (while p
@@ -2992,7 +2999,8 @@ so that `occur-next' and `occur-prev' will work."
 
 Output in buffer \"*indent*\" shows any lines which have conflicting
 values of a variable, and the final value of all variables learned.
-This buffer is popped to automatically if there are any discrepancies.
+When called interactively, pop to this buffer automatically if
+there are any discrepancies.
 
 If no prefix ARG is given, then variables are set to numbers.
 If a prefix arg is given, then variables are set to symbols when
@@ -3204,9 +3212,9 @@ This command can often take a long time to run."
           )))
       ;; Are abnormal hooks considered bad form?
       (run-hook-with-args 'sh-learned-buffer-hook learned-var-list)
-      (if (or sh-popup-occur-buffer (> num-diffs 0))
-         (pop-to-buffer out-buffer))
-      )))
+      (and (called-interactively-p 'any)
+          (or sh-popup-occur-buffer (> num-diffs 0))
+          (pop-to-buffer out-buffer)))))
 
 (defun sh-guess-basic-offset (vec)
   "See if we can determine a reasonable value for `sh-basic-offset'.
@@ -3742,7 +3750,7 @@ The document is bounded by `sh-here-document-word'."
   (interactive "*P")
   (self-insert-command (prefix-numeric-value arg))
   (or arg
-      (not (eq (char-after (- (point) 2)) last-command-char))
+      (not (looking-back "[^<]<<"))
       (save-excursion
        (backward-char 2)
        (sh-quoted-p))