emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/progmodes/sh-script.el [lexbind]


From: Miles Bader
Subject: [Emacs-diffs] Changes to emacs/lisp/progmodes/sh-script.el [lexbind]
Date: Tue, 14 Oct 2003 19:30:31 -0400

Index: emacs/lisp/progmodes/sh-script.el
diff -c emacs/lisp/progmodes/sh-script.el:1.110.4.1 
emacs/lisp/progmodes/sh-script.el:1.110.4.2
*** emacs/lisp/progmodes/sh-script.el:1.110.4.1 Fri Apr  4 01:20:36 2003
--- emacs/lisp/progmodes/sh-script.el   Tue Oct 14 19:30:18 2003
***************
*** 358,378 ****
  ;; I turned off this feature because it doesn't permit typing commands
  ;; in the usual way without help.
  ;;(defvar sh-abbrevs
! ;;  '((csh eval sh-abbrevs shell
  ;;     "switch" 'sh-case
  ;;     "getopts" 'sh-while-getopts)
  
! ;;    (es eval sh-abbrevs shell
  ;;    "function" 'sh-function)
  
! ;;    (ksh88 eval sh-abbrevs sh
  ;;       "select" 'sh-select)
  
! ;;    (rc eval sh-abbrevs shell
  ;;    "case" 'sh-case
  ;;    "function" 'sh-function)
  
! ;;    (sh eval sh-abbrevs shell
  ;;    "case" 'sh-case
  ;;    "function" 'sh-function
  ;;    "until" 'sh-until
--- 358,378 ----
  ;; I turned off this feature because it doesn't permit typing commands
  ;; in the usual way without help.
  ;;(defvar sh-abbrevs
! ;;  '((csh sh-abbrevs shell
  ;;     "switch" 'sh-case
  ;;     "getopts" 'sh-while-getopts)
  
! ;;    (es sh-abbrevs shell
  ;;    "function" 'sh-function)
  
! ;;    (ksh88 sh-abbrevs sh
  ;;       "select" 'sh-select)
  
! ;;    (rc sh-abbrevs shell
  ;;    "case" 'sh-case
  ;;    "function" 'sh-function)
  
! ;;    (sh sh-abbrevs shell
  ;;    "case" 'sh-case
  ;;    "function" 'sh-function
  ;;    "until" 'sh-until
***************
*** 385,391 ****
  ;;       "tmpfile" sh-tmp-file
  ;;       "while" sh-while)
  
! ;;    (zsh eval sh-abbrevs ksh88
  ;;     "repeat" 'sh-repeat))
  ;;  "Abbrev-table used in Shell-Script mode.  See `sh-feature'.
  ;;;Due to the internal workings of abbrev tables, the shell name symbol is
--- 385,391 ----
  ;;       "tmpfile" sh-tmp-file
  ;;       "while" sh-while)
  
! ;;    (zsh sh-abbrevs ksh88
  ;;     "repeat" 'sh-repeat))
  ;;  "Abbrev-table used in Shell-Script mode.  See `sh-feature'.
  ;;;Due to the internal workings of abbrev tables, the shell name symbol is
***************
*** 393,400 ****
  
  
  
! (defvar sh-mode-syntax-table
!   '((sh eval sh-mode-syntax-table ()
        ?\# "<"
        ?\n ">#"
        ?\" "\"\""
--- 393,411 ----
  
  
  
! (defun sh-mode-syntax-table (table &rest list)
!   "Copy TABLE and set syntax for successive CHARs according to strings S."
!   (setq table (copy-syntax-table table))
!   (while list
!     (modify-syntax-entry (pop list) (pop list) table))
!   table)
! 
! (defvar sh-mode-syntax-table nil
!   "The syntax table to use for Shell-Script mode.
! This is buffer-local in every such buffer.")
! 
! (defvar sh-mode-default-syntax-table
!   (sh-mode-syntax-table ()
        ?\# "<"
        ?\n ">#"
        ?\" "\"\""
***************
*** 406,416 ****
        ?. "_"
        ?^ "_"
        ?~ "_"
        ?< "."
        ?> ".")
!     (csh eval identity sh)
!     (rc eval identity sh))
  
    "Syntax-table used in Shell-Script mode.  See `sh-feature'.")
  
  (defvar sh-mode-map
--- 417,429 ----
        ?. "_"
        ?^ "_"
        ?~ "_"
+       ?, "_"
        ?< "."
        ?> ".")
!   "Default syntax table for shell mode.")
  
+ (defvar sh-mode-syntax-table-input
+   '((sh . nil))
    "Syntax-table used in Shell-Script mode.  See `sh-feature'.")
  
  (defvar sh-mode-map
***************
*** 479,486 ****
  (defcustom sh-require-final-newline
    '((csh . t)
      (pdksh . t)
!     (rc eval . require-final-newline)
!     (sh eval . require-final-newline))
    "*Value of `require-final-newline' in Shell-Script mode buffers.
  See `sh-feature'."
    :type '(repeat (cons (symbol :tag "Shell")
--- 492,499 ----
  (defcustom sh-require-final-newline
    '((csh . t)
      (pdksh . t)
!     (rc . require-final-newline)
!     (sh . require-final-newline))
    "*Value of `require-final-newline' in Shell-Script mode buffers.
  See `sh-feature'."
    :type '(repeat (cons (symbol :tag "Shell")
***************
*** 543,549 ****
  
  
  (defvar sh-here-document-word "EOF"
!   "Word to delimit here documents.")
  
  (defvar sh-test
    '((sh "[  ]" . 3)
--- 556,568 ----
  
  
  (defvar sh-here-document-word "EOF"
!   "Word to delimit here documents.
! If the first character of this string is \"-\", this character will
! be removed from the string when it is used to close the here document.
! This convention is used by the Bash shell, for example, to indicate
! that leading tabs inside the here document should be ignored.
! Note that Emacs currently has no support for indenting inside here
! documents - you must insert literal tabs by hand.")
  
  (defvar sh-test
    '((sh "[  ]" . 3)
***************
*** 554,613 ****
  ;; customized this out of sheer bravado.  not for the faint of heart.
  ;; but it *did* have an asterisk in the docstring!
  (defcustom sh-builtins
!   '((bash eval sh-append posix
!         "alias" "bg" "bind" "builtin" "declare" "dirs" "enable" "fc" "fg"
!         "help" "history" "jobs" "kill" "let" "local" "popd" "pushd" "source"
!         "suspend" "typeset" "unalias")
  
      ;; The next entry is only used for defining the others
!     (bourne eval sh-append shell
            "eval" "export" "getopts" "newgrp" "pwd" "read" "readonly"
            "times" "ulimit")
  
!     (csh eval sh-append shell
         "alias" "chdir" "glob" "history" "limit" "nice" "nohup" "rehash"
         "setenv" "source" "time" "unalias" "unhash")
  
!     (dtksh eval identity wksh)
  
      (es "access" "apids" "cd" "echo" "eval" "false" "let" "limit" "local"
        "newpgrp" "result" "time" "umask" "var" "vars" "wait" "whatis")
  
!     (jsh eval sh-append sh
         "bg" "fg" "jobs" "kill" "stop" "suspend")
  
!     (jcsh eval sh-append csh
          "bg" "fg" "jobs" "kill" "notify" "stop" "suspend")
  
!     (ksh88 eval sh-append bourne
           "alias" "bg" "false" "fc" "fg" "jobs" "kill" "let" "print" "time"
           "typeset" "unalias" "whence")
  
!     (oash eval sh-append sh
          "checkwin" "dateline" "error" "form" "menu" "newwin" "oadeinit"
          "oaed" "oahelp" "oainit" "pp" "ppfile" "scan" "scrollok" "wattr"
          "wclear" "werase" "win" "wmclose" "wmmessage" "wmopen" "wmove"
          "wmtitle" "wrefresh")
  
!     (pdksh eval sh-append ksh88
           "bind")
  
!     (posix eval sh-append sh
           "command")
  
      (rc "builtin" "cd" "echo" "eval" "limit" "newpgrp" "shift" "umask" "wait"
        "whatis")
  
!     (sh eval sh-append bourne
        "hash" "test" "type")
  
      ;; The next entry is only used for defining the others
      (shell "cd" "echo" "eval" "set" "shift" "umask" "unset" "wait")
  
!     (wksh eval sh-append ksh88
          "Xt[A-Z][A-Za-z]*")
  
!     (zsh eval sh-append ksh88
         "autoload" "bindkey" "builtin" "chdir" "compctl" "declare" "dirs"
         "disable" "disown" "echotc" "enable" "functions" "getln" "hash"
         "history" "integer" "limit" "local" "log" "popd" "pushd" "r"
--- 573,633 ----
  ;; customized this out of sheer bravado.  not for the faint of heart.
  ;; but it *did* have an asterisk in the docstring!
  (defcustom sh-builtins
!   '((bash sh-append posix
!         "." "alias" "bg" "bind" "builtin" "compgen" "complete"
!           "declare" "dirs" "disown" "enable" "fc" "fg" "help" "history"
!           "jobs" "kill" "let" "local" "popd" "printf" "pushd" "shopt"
!           "source" "suspend" "typeset" "unalias")
  
      ;; The next entry is only used for defining the others
!     (bourne sh-append shell
            "eval" "export" "getopts" "newgrp" "pwd" "read" "readonly"
            "times" "ulimit")
  
!     (csh sh-append shell
         "alias" "chdir" "glob" "history" "limit" "nice" "nohup" "rehash"
         "setenv" "source" "time" "unalias" "unhash")
  
!     (dtksh sh-append wksh)
  
      (es "access" "apids" "cd" "echo" "eval" "false" "let" "limit" "local"
        "newpgrp" "result" "time" "umask" "var" "vars" "wait" "whatis")
  
!     (jsh sh-append sh
         "bg" "fg" "jobs" "kill" "stop" "suspend")
  
!     (jcsh sh-append csh
          "bg" "fg" "jobs" "kill" "notify" "stop" "suspend")
  
!     (ksh88 sh-append bourne
           "alias" "bg" "false" "fc" "fg" "jobs" "kill" "let" "print" "time"
           "typeset" "unalias" "whence")
  
!     (oash sh-append sh
          "checkwin" "dateline" "error" "form" "menu" "newwin" "oadeinit"
          "oaed" "oahelp" "oainit" "pp" "ppfile" "scan" "scrollok" "wattr"
          "wclear" "werase" "win" "wmclose" "wmmessage" "wmopen" "wmove"
          "wmtitle" "wrefresh")
  
!     (pdksh sh-append ksh88
           "bind")
  
!     (posix sh-append sh
           "command")
  
      (rc "builtin" "cd" "echo" "eval" "limit" "newpgrp" "shift" "umask" "wait"
        "whatis")
  
!     (sh sh-append bourne
        "hash" "test" "type")
  
      ;; The next entry is only used for defining the others
      (shell "cd" "echo" "eval" "set" "shift" "umask" "unset" "wait")
  
!     (wksh sh-append ksh88
          "Xt[A-Z][A-Za-z]*")
  
!     (zsh sh-append ksh88
         "autoload" "bindkey" "builtin" "chdir" "compctl" "declare" "dirs"
         "disable" "disown" "echotc" "enable" "functions" "getln" "hash"
         "history" "integer" "limit" "local" "log" "popd" "pushd" "r"
***************
*** 627,633 ****
  
  
  (defcustom sh-leading-keywords
!   '((csh "else")
  
      (es "true" "unwind-protect" "whatis")
  
--- 647,656 ----
  
  
  (defcustom sh-leading-keywords
!   '((bash sh-append sh
!           "time")
! 
!     (csh "else")
  
      (es "true" "unwind-protect" "whatis")
  
***************
*** 647,679 ****
  
  
  (defcustom sh-other-keywords
!   '((bash eval sh-append bourne
!         "bye" "logout")
  
      ;; The next entry is only used for defining the others
!     (bourne eval sh-append sh
            "function")
  
!     (csh eval sh-append shell
         "breaksw" "default" "end" "endif" "endsw" "foreach" "goto"
         "if" "logout" "onintr" "repeat" "switch" "then" "while")
  
      (es "break" "catch" "exec" "exit" "fn" "for" "forever" "fork" "if"
        "return" "throw" "while")
  
!     (ksh88 eval sh-append bourne
           "select")
  
      (rc "break" "case" "exec" "exit" "fn" "for" "if" "in" "return" "switch"
        "while")
  
!     (sh eval sh-append shell
        "done" "esac" "fi" "for" "in" "return")
  
      ;; The next entry is only used for defining the others
      (shell "break" "case" "continue" "exec" "exit")
  
!     (zsh eval sh-append bash
         "select"))
    "*List of keywords not in `sh-leading-keywords'.
  See `sh-feature'."
--- 670,702 ----
  
  
  (defcustom sh-other-keywords
!   '((bash sh-append bourne
!         "bye" "logout" "select")
  
      ;; The next entry is only used for defining the others
!     (bourne sh-append sh
            "function")
  
!     (csh sh-append shell
         "breaksw" "default" "end" "endif" "endsw" "foreach" "goto"
         "if" "logout" "onintr" "repeat" "switch" "then" "while")
  
      (es "break" "catch" "exec" "exit" "fn" "for" "forever" "fork" "if"
        "return" "throw" "while")
  
!     (ksh88 sh-append bourne
           "select")
  
      (rc "break" "case" "exec" "exit" "fn" "for" "if" "in" "return" "switch"
        "while")
  
!     (sh sh-append shell
        "done" "esac" "fi" "for" "in" "return")
  
      ;; The next entry is only used for defining the others
      (shell "break" "case" "continue" "exec" "exit")
  
!     (zsh sh-append bash
         "select"))
    "*List of keywords not in `sh-leading-keywords'.
  See `sh-feature'."
***************
*** 687,727 ****
  
  
  (defvar sh-variables
!   '((bash eval sh-append sh
!         "allow_null_glob_expansion" "auto_resume" "BASH" "BASH_VERSION"
!         "cdable_vars" "ENV" "EUID" "FCEDIT" "FIGNORE" "glob_dot_filenames"
!         "histchars" "HISTFILE" "HISTFILESIZE" "history_control" "HISTSIZE"
!         "hostname_completion_file" "HOSTTYPE" "IGNOREEOF" "ignoreeof"
!         "LINENO" "MAIL_WARNING" "noclobber" "nolinks" "notify"
!         "no_exit_on_failed_exec" "NO_PROMPT_VARS" "OLDPWD" "OPTERR" "PPID"
!         "PROMPT_COMMAND" "PS4" "pushd_silent" "PWD" "RANDOM" "REPLY"
!         "SECONDS" "SHLVL" "TMOUT" "UID")
  
!     (csh eval sh-append shell
         "argv" "cdpath" "child" "echo" "histchars" "history" "home"
         "ignoreeof" "mail" "noclobber" "noglob" "nonomatch" "path" "prompt"
         "shell" "status" "time" "verbose")
  
!     (es eval sh-append shell
        "apid" "cdpath" "CDPATH" "history" "home" "ifs" "noexport" "path"
        "pid" "prompt" "signals")
  
!     (jcsh eval sh-append csh
          "notify")
  
!     (ksh88 eval sh-append sh
           "ENV" "ERRNO" "FCEDIT" "FPATH" "HISTFILE" "HISTSIZE" "LINENO"
           "OLDPWD" "PPID" "PS3" "PS4" "PWD" "RANDOM" "REPLY" "SECONDS"
           "TMOUT")
  
!     (oash eval sh-append sh
          "FIELD" "FIELD_MAX" "LAST_KEY" "OALIB" "PP_ITEM" "PP_NUM")
  
!     (rc eval sh-append shell
        "apid" "apids" "cdpath" "CDPATH" "history" "home" "ifs" "path" "pid"
        "prompt" "status")
  
!     (sh eval sh-append shell
        "CDPATH" "IFS" "OPTARG" "OPTIND" "PS1" "PS2")
  
      ;; The next entry is only used for defining the others
--- 710,756 ----
  
  
  (defvar sh-variables
!   '((bash sh-append sh
!         "allow_null_glob_expansion" "auto_resume" "BASH" "BASH_ENV"
!         "BASH_VERSINFO" "BASH_VERSION" "cdable_vars" "COMP_CWORD"
!         "COMP_LINE" "COMP_POINT" "COMP_WORDS" "COMPREPLY" "DIRSTACK"
!         "ENV" "EUID" "FCEDIT" "FIGNORE" "FUNCNAME"
!         "glob_dot_filenames" "GLOBIGNORE" "GROUPS" "histchars"
!         "HISTCMD" "HISTCONTROL" "HISTFILE" "HISTFILESIZE"
!         "HISTIGNORE" "history_control" "HISTSIZE"
!         "hostname_completion_file" "HOSTFILE" "HOSTTYPE" "IGNOREEOF"
!         "ignoreeof" "INPUTRC" "LINENO" "MACHTYPE" "MAIL_WARNING"
!         "noclobber" "nolinks" "notify" "no_exit_on_failed_exec"
!         "NO_PROMPT_VARS" "OLDPWD" "OPTERR" "OSTYPE" "PIPESTATUS"
!         "PPID" "POSIXLY_CORRECT" "PROMPT_COMMAND" "PS3" "PS4"
!         "pushd_silent" "PWD" "RANDOM" "REPLY" "SECONDS" "SHELLOPTS"
!         "SHLVL" "TIMEFORMAT" "TMOUT" "UID")
  
!     (csh sh-append shell
         "argv" "cdpath" "child" "echo" "histchars" "history" "home"
         "ignoreeof" "mail" "noclobber" "noglob" "nonomatch" "path" "prompt"
         "shell" "status" "time" "verbose")
  
!     (es sh-append shell
        "apid" "cdpath" "CDPATH" "history" "home" "ifs" "noexport" "path"
        "pid" "prompt" "signals")
  
!     (jcsh sh-append csh
          "notify")
  
!     (ksh88 sh-append sh
           "ENV" "ERRNO" "FCEDIT" "FPATH" "HISTFILE" "HISTSIZE" "LINENO"
           "OLDPWD" "PPID" "PS3" "PS4" "PWD" "RANDOM" "REPLY" "SECONDS"
           "TMOUT")
  
!     (oash sh-append sh
          "FIELD" "FIELD_MAX" "LAST_KEY" "OALIB" "PP_ITEM" "PP_NUM")
  
!     (rc sh-append shell
        "apid" "apids" "cdpath" "CDPATH" "history" "home" "ifs" "path" "pid"
        "prompt" "status")
  
!     (sh sh-append shell
        "CDPATH" "IFS" "OPTARG" "OPTIND" "PS1" "PS2")
  
      ;; The next entry is only used for defining the others
***************
*** 730,736 ****
           "LINES" "LOGNAME" "MAIL" "MAILCHECK" "MAILPATH" "PAGER" "PATH"
           "SHELL" "TERM" "TERMCAP" "TERMINFO" "VISUAL")
  
!     (tcsh eval sh-append csh
          "addsuffix" "ampm" "autocorrect" "autoexpand" "autolist"
          "autologout" "chase_symlinks" "correct" "dextract" "edit" "el"
          "fignore" "gid" "histlit" "HOST" "HOSTTYPE" "HPATH"
--- 759,765 ----
           "LINES" "LOGNAME" "MAIL" "MAILCHECK" "MAILPATH" "PAGER" "PATH"
           "SHELL" "TERM" "TERMCAP" "TERMINFO" "VISUAL")
  
!     (tcsh sh-append csh
          "addsuffix" "ampm" "autocorrect" "autoexpand" "autolist"
          "autologout" "chase_symlinks" "correct" "dextract" "edit" "el"
          "fignore" "gid" "histlit" "HOST" "HOSTTYPE" "HPATH"
***************
*** 741,747 ****
          "tperiod" "tty" "uid" "version" "visiblebell" "watch" "who"
          "wordchars")
  
!     (zsh eval sh-append ksh88
         "BAUD" "bindcmds" "cdpath" "DIRSTACKSIZE" "fignore" "FIGNORE" "fpath"
         "HISTCHARS" "hostcmds" "hosts" "HOSTS" "LISTMAX" "LITHISTSIZE"
         "LOGCHECK" "mailpath" "manpath" "NULLCMD" "optcmds" "path" "POSTEDIT"
--- 770,776 ----
          "tperiod" "tty" "uid" "version" "visiblebell" "watch" "who"
          "wordchars")
  
!     (zsh sh-append ksh88
         "BAUD" "bindcmds" "cdpath" "DIRSTACKSIZE" "fignore" "FIGNORE" "fpath"
         "HISTCHARS" "hostcmds" "hosts" "HOSTS" "LISTMAX" "LITHISTSIZE"
         "LOGCHECK" "mailpath" "manpath" "NULLCMD" "optcmds" "path" "POSTEDIT"
***************
*** 770,803 ****
  
  
  (defvar sh-font-lock-keywords
!   '((csh eval sh-append shell
!        '("\\${?[#?]?\\([A-Za-z_][A-Za-z0-9_]*\\|0\\)" 1
!          font-lock-variable-name-face))
  
!     (es eval sh-append executable-font-lock-keywords
!       '("\\$#?\\([A-Za-z_][A-Za-z0-9_]*\\|[0-9]+\\)" 1
!         font-lock-variable-name-face))
  
!     (rc eval identity es)
  
!     (sh eval sh-append shell
        ;; Variable names.
!       '("\\$\\({#?\\)?\\([A-Za-z_][A-Za-z0-9_]*\\|address@hidden)" 2
          font-lock-variable-name-face)
        ;; Function names.
!       '("^\\(\\sw+\\)[ \t]*(" 1 font-lock-function-name-face)
!       '("\\<\\(function\\)\\>[ \t]*\\(\\sw+\\)?"
          (1 font-lock-keyword-face) (2 font-lock-function-name-face nil t)))
  
      ;; The next entry is only used for defining the others
!     (shell eval sh-append executable-font-lock-keywords
!          '("\\\\[^A-Za-z0-9]" 0 font-lock-string-face)
!          '("\\${?\\([A-Za-z_][A-Za-z0-9_]*\\|[0-9]+\\|[$*_]\\)" 1
             font-lock-variable-name-face))
!     (rpm eval sh-append rpm2
!        '("%{?\\(\\sw+\\)"  1 font-lock-keyword-face))
!     (rpm2 eval sh-append shell
!         '("^\\(\\sw+\\):"  1 font-lock-variable-name-face)))
    "Default expressions to highlight in Shell Script modes.  See 
`sh-feature'.")
  
  (defvar sh-font-lock-keywords-1
--- 799,834 ----
  
  
  (defvar sh-font-lock-keywords
!   '((csh sh-append shell
!        ("\\${?[#?]?\\([A-Za-z_][A-Za-z0-9_]*\\|0\\)" 1
!           font-lock-variable-name-face))
  
!     (es sh-append executable-font-lock-keywords
!       ("\\$#?\\([A-Za-z_][A-Za-z0-9_]*\\|[0-9]+\\)" 1
!          font-lock-variable-name-face))
  
!     (rc sh-append es)
  
!     (sh sh-append shell
        ;; Variable names.
!       ("\\$\\({#?\\)?\\([A-Za-z_][A-Za-z0-9_]*\\|address@hidden)" 2
          font-lock-variable-name-face)
        ;; Function names.
!       ("^\\(\\sw+\\)[ \t]*(" 1 font-lock-function-name-face)
!       ("\\<\\(function\\)\\>[ \t]*\\(\\sw+\\)?"
          (1 font-lock-keyword-face) (2 font-lock-function-name-face nil t)))
  
      ;; The next entry is only used for defining the others
!     (shell sh-append executable-font-lock-keywords
!            ;; Using font-lock-string-face here confuses sh-get-indent-info.
!            ("\\\\$" 0 font-lock-warning-face)
!          ("\\\\[^A-Za-z0-9]" 0 font-lock-string-face)
!          ("\\${?\\([A-Za-z_][A-Za-z0-9_]*\\|[0-9]+\\|[$*_]\\)" 1
             font-lock-variable-name-face))
!     (rpm sh-append rpm2
!        ("%{?\\(\\sw+\\)"  1 font-lock-keyword-face))
!     (rpm2 sh-append shell
!         ("^\\(\\sw+\\):"  1 font-lock-variable-name-face)))
    "Default expressions to highlight in Shell Script modes.  See 
`sh-feature'.")
  
  (defvar sh-font-lock-keywords-1
***************
*** 884,889 ****
--- 915,924 ----
    ;; This looks silly, but it's because `sh-here-doc-re' keeps changing.
    (re-search-forward sh-here-doc-re limit t))
  
+ (defun sh-is-quoted-p (pos)
+   (and (eq (char-before pos) ?\\)
+        (not (sh-is-quoted-p (1- pos)))))
+ 
  (defun sh-font-lock-paren (start)
    (save-excursion
      (goto-char start)
***************
*** 894,900 ****
          ;; Skip through one pattern
          (while
              (or (/= 0 (skip-syntax-backward "w_"))
!                 (/= 0 (skip-chars-backward "?*/"))
                  (when (memq (char-before) '(?\" ?\'))
                    (condition-case nil (progn (backward-sexp 1) t)
                      (error nil)))))
--- 929,937 ----
          ;; Skip through one pattern
          (while
              (or (/= 0 (skip-syntax-backward "w_"))
!                 (/= 0 (skip-chars-backward "?[]*/\\"))
!                 (and (sh-is-quoted-p (1- (point)))
!                      (goto-char (- (point) 2)))
                  (when (memq (char-before) '(?\" ?\'))
                    (condition-case nil (progn (backward-sexp 1) t)
                      (error nil)))))
***************
*** 1215,1223 ****
  ;; mode-command and utility functions
  
  ;;;###autoload
- (put 'sh-mode 'mode-class 'special)
- 
- ;;;###autoload
  (defun sh-mode ()
    "Major mode for editing shell scripts.
  This mode works for many shells, since they all have roughly the same syntax,
--- 1252,1257 ----
***************
*** 1456,1471 ****
        (setq sh-shell-file
            (executable-set-magic shell (sh-feature sh-shell-arg)
                                  no-query-flag insert-flag)))
!   (setq require-final-newline (sh-feature sh-require-final-newline)
! ;;;   local-abbrev-table (sh-feature sh-abbrevs)
        comment-start-skip "#+[\t ]*"
        mode-line-process (format "[%s]" sh-shell)
        sh-shell-variables nil
        sh-shell-variables-initialized nil
        imenu-generic-expression (sh-feature sh-imenu-generic-expression)
        imenu-case-fold-search nil)
!   (set-syntax-table (or (sh-feature sh-mode-syntax-table)
!                       (standard-syntax-table)))
    (dolist (var (sh-feature sh-variables))
      (sh-remember-variable var))
    (make-local-variable 'indent-line-function)
--- 1490,1512 ----
        (setq sh-shell-file
            (executable-set-magic shell (sh-feature sh-shell-arg)
                                  no-query-flag insert-flag)))
!   (let ((tem (sh-feature sh-require-final-newline)))
!     (unless (eq tem 'require-final-newline)
!       (setq require-final-newline tem)))
!   (setq
        comment-start-skip "#+[\t ]*"
+ ;;;   local-abbrev-table (sh-feature sh-abbrevs)
        mode-line-process (format "[%s]" sh-shell)
        sh-shell-variables nil
        sh-shell-variables-initialized nil
        imenu-generic-expression (sh-feature sh-imenu-generic-expression)
        imenu-case-fold-search nil)
!   (make-local-variable 'sh-mode-syntax-table)
!   (let ((tem (sh-feature sh-mode-syntax-table-input)))
!     (setq sh-mode-syntax-table
!         (if tem (apply 'sh-mode-syntax-table tem)
!           sh-mode-default-syntax-table)))
!   (set-syntax-table sh-mode-syntax-table)
    (dolist (var (sh-feature sh-variables))
      (sh-remember-variable var))
    (make-local-variable 'indent-line-function)
***************
*** 1491,1497 ****
  
  
  
! (defun sh-feature (list &optional function)
    "Index ALIST by the current shell.
  If ALIST isn't a list where every element is a cons, it is returned as is.
  Else indexing follows an inheritance logic which works in two ways:
--- 1532,1538 ----
  
  
  
! (defun sh-feature (alist &optional function)
    "Index ALIST by the current shell.
  If ALIST isn't a list where every element is a cons, it is returned as is.
  Else indexing follows an inheritance logic which works in two ways:
***************
*** 1500,1545 ****
      the alist contains no value for the current shell.
      The ultimate default is always `sh'.
  
!   - If the value thus looked up is a list starting with `eval' its `cdr' is
!     first evaluated.  If that is also a list and the first argument is a
!     symbol in ALIST it is not evaluated, but rather recursively looked up in
!     ALIST to allow the function called to define the value for one shell to be
!     derived from another shell.  While calling the function, is the car of the
!     alist element is the current shell.
      The value thus determined is physically replaced into the alist.
  
  Optional FUNCTION is applied to the determined value and the result is cached
  in ALIST."
!   (or (if (consp list)
!         (let ((l list))
            (while (and l (consp (car l)))
              (setq l (cdr l)))
!           (if l list)))
        (if function
!         (cdr (assoc (setq function (cons sh-shell function)) list)))
        (let ((sh-shell sh-shell)
            elt val)
        (while (and sh-shell
!                   (not (setq elt (assq sh-shell list))))
          (setq sh-shell (cdr (assq sh-shell sh-ancestor-alist))))
        ;; If the shell is not known, treat it as sh.
        (unless elt
!         (setq elt (assq 'sh list)))
        (if (and (consp (setq val (cdr elt)))
!                (eq (car val) 'eval))
            (setcdr elt
                    (setq val
!                         (eval (if (consp (setq val (cdr val)))
!                                   (let ((sh-shell (car (cdr val)))
!                                         function)
!                                     (if (assq sh-shell list)
!                                         (setcar (cdr val)
!                                                 (list 'quote
!                                                       (sh-feature list))))
!                                     val)
!                                 val)))))
        (if function
!           (nconc list
                   (list (cons function
                               (setq sh-shell (car function)
                                     val (funcall (cdr function) val))))))
--- 1541,1583 ----
      the alist contains no value for the current shell.
      The ultimate default is always `sh'.
  
!   - If the value thus looked up is a list starting with `sh-append',
!     we call the function `sh-append' with the rest of the list as
!     arguments, and use the value.  However, the next element of the
!     list is not used as-is; instead, we look it up recursively
!     in ALIST to allow the function called to define the value for
!     one shell to be derived from another shell.
      The value thus determined is physically replaced into the alist.
  
  Optional FUNCTION is applied to the determined value and the result is cached
  in ALIST."
!   (or (if (consp alist)
!         (let ((l alist))
            (while (and l (consp (car l)))
              (setq l (cdr l)))
!           (if l alist)))
        (if function
!         (cdr (assoc (setq function (cons sh-shell function)) alist)))
        (let ((sh-shell sh-shell)
            elt val)
        (while (and sh-shell
!                   (not (setq elt (assq sh-shell alist))))
          (setq sh-shell (cdr (assq sh-shell sh-ancestor-alist))))
        ;; If the shell is not known, treat it as sh.
        (unless elt
!         (setq elt (assq 'sh alist)))
        (if (and (consp (setq val (cdr elt)))
!                (memq (car val) '(sh-append sh-modify)))
            (setcdr elt
                    (setq val
!                         (apply (car val)
!                                (let ((sh-shell (car (cdr val))))
!                                    (if (assq sh-shell alist)
!                                        (sh-feature alist)
!                                      (eval sh-shell)))
!                                (cddr val)))))
        (if function
!           (nconc alist
                   (list (cons function
                               (setq sh-shell (car function)
                                     val (funcall (cdr function) val))))))
***************
*** 1580,1592 ****
  ;;      (symbol-value sh-shell)))
  
  
- (defun sh-mode-syntax-table (table &rest list)
-   "Copy TABLE and set syntax for successive CHARs according to strings S."
-   (setq table (copy-syntax-table table))
-   (while list
-     (modify-syntax-entry (pop list) (pop list) table))
-   table)
- 
  (defun sh-append (ancestor &rest list)
    "Return list composed of first argument (a list) physically appended to 
rest."
    (nconc list ancestor))
--- 1618,1623 ----
***************
*** 1941,1968 ****
             what the indentation is based on."
    ;; See comments before `sh-kw'.
    (save-excursion
!     (let ((prev-kw nil)
!         (prev-stmt nil)
!         (have-result nil)
!         depth-bol depth-eol
          this-kw
-         (state nil)
-         state-bol
-         (depth-prev-bol nil)
          start
!         func val
          (result nil)
-         prev-lines-indent
-         (prev-list nil)
-         (this-list nil)
          (align-point nil)
          prev-line-end x)
        (beginning-of-line)
        ;; Note: setting result to t means we are done and will return nil.
        ;;(This function never returns just t.)
        (cond
!        ((or (and (boundp 'font-lock-string-face)
!                (eq (get-text-property (point) 'face) font-lock-string-face))
            (eq (get-text-property (point) 'face) sh-heredoc-face))
        (setq result t)
        (setq have-result t))
--- 1972,1991 ----
             what the indentation is based on."
    ;; See comments before `sh-kw'.
    (save-excursion
!     (let ((have-result nil)
          this-kw
          start
!         val
          (result nil)
          (align-point nil)
          prev-line-end x)
        (beginning-of-line)
        ;; Note: setting result to t means we are done and will return nil.
        ;;(This function never returns just t.)
        (cond
!        ((or (and (boundp 'font-lock-string-face) (not (bobp))
!                (eq (get-text-property (1- (point)) 'face)
!                    font-lock-string-face))
            (eq (get-text-property (point) 'face) sh-heredoc-face))
        (setq result t)
        (setq have-result t))
***************
*** 2259,2269 ****
    ;;
    (if (bolp)
        nil
!     (let ((going t)
!         c n
!         min-point
!         (start (point))
!         (found nil))
        (save-restriction
        (narrow-to-region
        (if (sh-this-is-a-continuation)
--- 2282,2289 ----
    ;;
    (if (bolp)
        nil
!     (let (c min-point
!         (start (point)))
        (save-restriction
        (narrow-to-region
        (if (sh-this-is-a-continuation)
***************
*** 2552,2558 ****
    (sh-must-support-indent)
    (let* ((info (sh-get-indent-info))
         (var (sh-get-indent-var-for-line info))
!        val val0 new-val old-val indent-val)
      (if (stringp var)
        (message (format "Cannot set indent - %s" var))
        (setq old-val (symbol-value var))
--- 2572,2578 ----
    (sh-must-support-indent)
    (let* ((info (sh-get-indent-info))
         (var (sh-get-indent-var-for-line info))
!        val old-val indent-val)
      (if (stringp var)
        (message (format "Cannot set indent - %s" var))
        (setq old-val (symbol-value var))
***************
*** 2747,2753 ****
      (let ((learned-var-list nil)
          (out-buffer "*indent*")
          (num-diffs 0)
-         last-pos
          previous-set-info
          (max 17)
          vec
--- 2767,2772 ----
***************
*** 2908,2921 ****
            (append (list (list 'sh-indent-comment comment-col (point-max)))
                    learned-var-list))
        (setq sh-indent-comment comment-col)
!       (let ((name (buffer-name))
!           (lines (if (and (eq (point-min) 1)
!                           (eq (point-max) (1+ (buffer-size))))
!                      ""
!                    (format "lines %d to %d of "
!                            (1+ (count-lines 1 (point-min)))
!                            (1+ (count-lines 1 (point-max))))))
!           )
        (sh-mark-line  "\nLearned variable settings:" nil out-buffer)
        (if arg
            ;; Set learned variables to symbolic rather than numeric
--- 2927,2933 ----
            (append (list (list 'sh-indent-comment comment-col (point-max)))
                    learned-var-list))
        (setq sh-indent-comment comment-col)
!       (let ((name (buffer-name)))
        (sh-mark-line  "\nLearned variable settings:" nil out-buffer)
        (if arg
            ;; Set learned variables to symbolic rather than numeric
***************
*** 2960,2971 ****
    nil           - we couldn't find a reasonable one."
    (let* ((max (1- (length vec)))
         (i 1)
!        (totals (make-vector max 0))
!        (return nil)
!        j)
      (while (< i max)
        (aset totals i (+ (aref totals i) (* 4 (aref vec i))))
-       (setq j (/ i 2))
        (if (zerop (% i 2))
          (aset totals i (+ (aref totals i) (aref vec (/ i 2)))))
        (if (< (* i 2) max)
--- 2972,2980 ----
    nil           - we couldn't find a reasonable one."
    (let* ((max (1- (length vec)))
         (i 1)
!        (totals (make-vector max 0)))
      (while (< i max)
        (aset totals i (+ (aref totals i) (* 4 (aref vec i))))
        (if (zerop (% i 2))
          (aset totals i (+ (aref totals i) (aref vec (/ i 2)))))
        (if (< (* i 2) max)
***************
*** 3119,3134 ****
  
  (define-skeleton sh-for
    "Insert a for loop.  See `sh-feature'."
!   (csh eval sh-modify sh
         1 ""
         2 "foreach "
         4 " ( "
         6 " )"
         15 '<
         16 "end")
!   (es eval sh-modify rc
        4 " = ")
!   (rc eval sh-modify sh
        2 "for( "
        6 " ) {"
        15 ?\} )
--- 3128,3143 ----
  
  (define-skeleton sh-for
    "Insert a for loop.  See `sh-feature'."
!   (csh sh-modify sh
         1 ""
         2 "foreach "
         4 " ( "
         6 " )"
         15 '<
         16 "end")
!   (es sh-modify rc
        4 " = ")
!   (rc sh-modify sh
        2 "for( "
        6 " ) {"
        15 ?\} )
***************
*** 3141,3154 ****
  
  (define-skeleton sh-indexed-loop
    "Insert an indexed loop from 1 to n.  See `sh-feature'."
!   (bash eval identity posix)
    (csh "Index variable: "
         "@ " str " = 1" \n
         "while( $" str " <= " (read-string "upper limit: ") " )" \n
         > _ ?$ str \n
         "@ " str "++" \n
         < "end" \n)
!   (es eval sh-modify rc
        4 " =")
    (ksh88 "Index variable: "
         > "integer " str "=0" \n
--- 3150,3163 ----
  
  (define-skeleton sh-indexed-loop
    "Insert an indexed loop from 1 to n.  See `sh-feature'."
!   (bash sh-modify posix)
    (csh "Index variable: "
         "@ " str " = 1" \n
         "while( $" str " <= " (read-string "upper limit: ") " )" \n
         > _ ?$ str \n
         "@ " str "++" \n
         < "end" \n)
!   (es sh-modify rc
        4 " =")
    (ksh88 "Index variable: "
         > "integer " str "=0" \n
***************
*** 3216,3222 ****
                          process-environment)
                  sh-shell-variables))))
      (case code
!       (nil (try-completion string sh-shell-variables predicate))
        (lambda (test-completion string sh-shell-variables predicate))
        (t (all-completions string sh-shell-variables predicate)))))
  
--- 3225,3231 ----
                          process-environment)
                  sh-shell-variables))))
      (case code
!       ((nil) (try-completion string sh-shell-variables predicate))
        (lambda (test-completion string sh-shell-variables predicate))
        (t (all-completions string sh-shell-variables predicate)))))
  
***************
*** 3246,3258 ****
  
  (define-skeleton sh-function
    "Insert a function definition.  See `sh-feature'."
!   (bash eval sh-modify ksh88
        3 "() {")
    (ksh88 "name: "
         "function " str " {" \n
         > _ \n
         < "}" \n)
!   (rc eval sh-modify ksh88
        1 "fn ")
    (sh ()
        "() {" \n
--- 3255,3267 ----
  
  (define-skeleton sh-function
    "Insert a function definition.  See `sh-feature'."
!   (bash sh-modify ksh88
        3 "() {")
    (ksh88 "name: "
         "function " str " {" \n
         > _ \n
         < "}" \n)
!   (rc sh-modify ksh88
        1 "fn ")
    (sh ()
        "() {" \n
***************
*** 3328,3341 ****
         > "select " str " in " _ "; do" \n
         > ?$ str \n
         "done" > \n)
!   (bash eval sh-append ksh88))
  ;;;(put 'sh-select 'menu-enable '(sh-feature sh-select))
  
  
  
  (define-skeleton sh-tmp-file
    "Insert code to setup temporary file handling.  See `sh-feature'."
!   (bash eval identity ksh88)
    (csh (file-name-nondirectory (buffer-file-name))
         "set tmp = /tmp/" str ".$$" \n
         "onintr exit" \n _
--- 3337,3350 ----
         > "select " str " in " _ "; do" \n
         > ?$ str \n
         "done" > \n)
!   (bash sh-append ksh88))
  ;;;(put 'sh-select 'menu-enable '(sh-feature sh-select))
  
  
  
  (define-skeleton sh-tmp-file
    "Insert code to setup temporary file handling.  See `sh-feature'."
!   (bash sh-append ksh88)
    (csh (file-name-nondirectory (buffer-file-name))
         "set tmp = /tmp/" str ".$$" \n
         "onintr exit" \n _
***************
*** 3354,3360 ****
        _ \n
        ?\} > \n
        ?\} > \n)
!   (ksh88 eval sh-modify sh
         7 "EXIT")
    (rc (file-name-nondirectory (buffer-file-name))
        > "tmp = /tmp/" str ".$pid" \n
--- 3363,3369 ----
        _ \n
        ?\} > \n
        ?\} > \n)
!   (ksh88 sh-modify sh
         7 "EXIT")
    (rc (file-name-nondirectory (buffer-file-name))
        > "tmp = /tmp/" str ".$pid" \n
***************
*** 3378,3394 ****
  
  (define-skeleton sh-while
    "Insert a while loop.  See `sh-feature'."
!   (csh eval sh-modify sh
         2 ""
         3 "while( "
         5 " )"
         10 '<
         11 "end")
!   (es eval sh-modify sh
        3 "while { "
        5 " } {"
        10 ?\} )
!   (rc eval sh-modify sh
        3 "while( "
        5 " ) {"
        10 ?\} )
--- 3387,3403 ----
  
  (define-skeleton sh-while
    "Insert a while loop.  See `sh-feature'."
!   (csh sh-modify sh
         2 ""
         3 "while( "
         5 " )"
         10 '<
         11 "end")
!   (es sh-modify sh
        3 "while { "
        5 " } {"
        10 ?\} )
!   (rc sh-modify sh
        3 "while( "
        5 " ) {"
        10 ?\} )
***************
*** 3404,3410 ****
    "Insert a while getopts loop.  See `sh-feature'.
  Prompts for an options string which consists of letters for each recognized
  option followed by a colon `:' if the option accepts an argument."
!   (bash eval sh-modify sh
        18 "${0##*/}")
    (csh nil
         "while( 1 )" \n
--- 3413,3419 ----
    "Insert a while getopts loop.  See `sh-feature'.
  Prompts for an options string which consists of letters for each recognized
  option followed by a colon `:' if the option accepts an argument."
!   (bash sh-modify sh
        18 "${0##*/}")
    (csh nil
         "while( 1 )" \n
***************
*** 3429,3439 ****
         < < "endsw" \n
         "shift" \n
         < "end" \n)
!   (ksh88 eval sh-modify sh
         16 "print"
         18 "${0##*/}"
!        36 "OPTIND-1")
!   (posix eval sh-modify sh
         18 "$(basename $0)")
    (sh "optstring: "
        > "while getopts :" str " OPT; do" \n
--- 3438,3448 ----
         < < "endsw" \n
         "shift" \n
         < "end" \n)
!   (ksh88 sh-modify sh
         16 "print"
         18 "${0##*/}"
!        37 "OPTIND-1")
!   (posix sh-modify sh
         18 "$(basename $0)")
    (sh "optstring: "
        > "while getopts :" str " OPT; do" \n
***************
*** 3498,3504 ****
            (sh-quoted-p)
          (end-of-line 2))
        (newline)
!       (save-excursion (insert ?\n sh-here-document-word)))))
  
  
  ;; various other commands
--- 3507,3516 ----
            (sh-quoted-p)
          (end-of-line 2))
        (newline)
!       (save-excursion
!           (insert ?\n (substring
!                        sh-here-document-word
!                        (if (string-match "^-" sh-here-document-word) 1 
0)))))))
  
  
  ;; various other commands
***************
*** 3543,3546 ****
--- 3555,3559 ----
  
  (provide 'sh-script)
  
+ ;;; arch-tag: eccd8b72-f337-4fc2-ae86-18155a69d937
  ;;; sh-script.el ends here




reply via email to

[Prev in Thread] Current Thread [Next in Thread]