diff options
| -rw-r--r-- | lisp/progmodes/sh-script.el | 62 |
1 files changed, 28 insertions, 34 deletions
diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index 3d8214a13a0..2f312cd4db0 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | ;; Copyright (C) 1993, 1994, 1995 by Free Software Foundation, Inc. | 2 | ;; Copyright (C) 1993, 1994, 1995 by Free Software Foundation, Inc. |
| 3 | 3 | ||
| 4 | ;; Author: Daniel.Pfeiffer@Informatik.START.dbp.de, fax (+49 69) 7588-2389 | 4 | ;; Author: Daniel.Pfeiffer@Informatik.START.dbp.de, fax (+49 69) 7588-2389 |
| 5 | ;; Version: 2.0d | 5 | ;; Version: 2.0e |
| 6 | ;; Maintainer: FSF | 6 | ;; Maintainer: FSF |
| 7 | ;; Keywords: languages, unix | 7 | ;; Keywords: languages, unix |
| 8 | 8 | ||
| @@ -32,12 +32,7 @@ | |||
| 32 | 32 | ||
| 33 | ;;; Known Bugs: | 33 | ;;; Known Bugs: |
| 34 | 34 | ||
| 35 | ;; - Since GNU Emacs' syntax can't handle the context-sensitive meanings of | 35 | ;; - In Bourne the keyword `in' is not anchored to case, for, select ... |
| 36 | ;; the variable/number base/comment symbol `#', that has to be fontified by | ||
| 37 | ;; regexp. This alas means that a quote `'' or `"' in a comment will | ||
| 38 | ;; fontify VERY badly. The alternative is to have these frequent constructs | ||
| 39 | ;; with `#' fontify as comments. Or maybe we intoduce a 'syntax text- | ||
| 40 | ;; property? | ||
| 41 | ;; - Variables in `"' strings aren't fontified because there's no way of | 36 | ;; - Variables in `"' strings aren't fontified because there's no way of |
| 42 | ;; syntactically distinguishing those from `'' strings. | 37 | ;; syntactically distinguishing those from `'' strings. |
| 43 | 38 | ||
| @@ -222,7 +217,8 @@ actually defined as the table for the like of \\[edit-abbrevs].") | |||
| 222 | 217 | ||
| 223 | 218 | ||
| 224 | (defvar sh-mode-map | 219 | (defvar sh-mode-map |
| 225 | (let ((map (make-sparse-keymap))) | 220 | (let ((map (make-sparse-keymap)) |
| 221 | (menu-map (make-sparse-keymap "Insert"))) | ||
| 226 | (define-key map "\C-c(" 'sh-function) | 222 | (define-key map "\C-c(" 'sh-function) |
| 227 | (define-key map "\C-c\C-w" 'sh-while) | 223 | (define-key map "\C-c\C-w" 'sh-while) |
| 228 | (define-key map "\C-c\C-u" 'sh-until) | 224 | (define-key map "\C-c\C-u" 'sh-until) |
| @@ -263,28 +259,19 @@ actually defined as the table for the like of \\[edit-abbrevs].") | |||
| 263 | map (current-global-map)) | 259 | map (current-global-map)) |
| 264 | (substitute-key-definition 'forward-sentence 'sh-end-of-command | 260 | (substitute-key-definition 'forward-sentence 'sh-end-of-command |
| 265 | map (current-global-map)) | 261 | map (current-global-map)) |
| 266 | (define-key map [menu-bar insert] | 262 | (define-key map [menu-bar insert] (cons "Insert" menu-map)) |
| 267 | (cons "Insert" (make-sparse-keymap "Insert"))) | 263 | (define-key menu-map [sh-while] '("While Loop" . sh-while)) |
| 268 | (define-key map [menu-bar insert sh-while] | 264 | (define-key menu-map [sh-until] '("Until Loop" . sh-until)) |
| 269 | '("While loop" . sh-while)) | 265 | (define-key menu-map [sh-tmp-file] '("Temporary File" . sh-tmp-file)) |
| 270 | (define-key map [menu-bar insert sh-until] | 266 | (define-key menu-map [sh-select] '("Select Statement" . sh-select)) |
| 271 | '("Until loop" . sh-until)) | 267 | (define-key menu-map [sh-repeat] '("Repeat Loop" . sh-repeat)) |
| 272 | (define-key map [menu-bar insert sh-tmp-file] | 268 | (define-key menu-map [sh-while-getopts] |
| 273 | '("Temporary file" . sh-tmp-file)) | 269 | '("Options Loop" . sh-while-getopts)) |
| 274 | (define-key map [menu-bar insert sh-select] | 270 | (define-key menu-map [sh-indexed-loop] |
| 275 | '("Select statement" . sh-select)) | 271 | '("Indexed Loop" . sh-indexed-loop)) |
| 276 | (define-key map [menu-bar insert sh-repeat] | 272 | (define-key menu-map [sh-if] '("If Statement" . sh-if)) |
| 277 | '("Repeat loop" . sh-repeat)) | 273 | (define-key menu-map [sh-for] '("For Loop" . sh-for)) |
| 278 | (define-key map [menu-bar insert sh-while-getopts] | 274 | (define-key menu-map [sh-case] '("Case Statement" . sh-case)) |
| 279 | '("Options loop" . sh-while-getopts)) | ||
| 280 | (define-key map [menu-bar insert sh-indexed-loop] | ||
| 281 | '("Indexed loop" . sh-indexed-loop)) | ||
| 282 | (define-key map [menu-bar insert sh-if] | ||
| 283 | '("If statement" . sh-if)) | ||
| 284 | (define-key map [menu-bar insert sh-for] | ||
| 285 | '("For loop" . sh-for)) | ||
| 286 | (define-key map [menu-bar insert sh-case] | ||
| 287 | '("Case statement" . sh-case)) | ||
| 288 | map) | 275 | map) |
| 289 | "Keymap used in Shell-Script mode.") | 276 | "Keymap used in Shell-Script mode.") |
| 290 | 277 | ||
| @@ -565,12 +552,18 @@ See `sh-feature'.") | |||
| 565 | "*Rules for highlighting shell scripts. See `sh-feature'.") | 552 | "*Rules for highlighting shell scripts. See `sh-feature'.") |
| 566 | 553 | ||
| 567 | (defvar sh-font-lock-keywords-1 | 554 | (defvar sh-font-lock-keywords-1 |
| 568 | '((sh "[ \t]in[ \t]")) | 555 | '((sh "[ \t]in\\>")) |
| 569 | "*Additional rules for highlighting shell scripts. See `sh-feature'.") | 556 | "*Additional rules for highlighting shell scripts. See `sh-feature'.") |
| 570 | 557 | ||
| 571 | (defvar sh-font-lock-keywords-2 () | 558 | (defvar sh-font-lock-keywords-2 () |
| 572 | "*Yet more rules for highlighting shell scripts. See `sh-feature'.") | 559 | "*Yet more rules for highlighting shell scripts. See `sh-feature'.") |
| 573 | 560 | ||
| 561 | (defvar sh-font-lock-keywords-only t | ||
| 562 | "*Value of `font-lock-keywords-only' for highlighting shell scripts. | ||
| 563 | Default value is `t' because Emacs' syntax is not expressive enough to | ||
| 564 | detect that $# does not start a comment. Thus comments are fontified by | ||
| 565 | regexp which means that a single apostrophe in a comment turns everything | ||
| 566 | upto the next one or end of buffer into a string.") | ||
| 574 | 567 | ||
| 575 | ;; mode-command and utility functions | 568 | ;; mode-command and utility functions |
| 576 | 569 | ||
| @@ -656,17 +649,18 @@ with your script for an edit-interpret-debug cycle." | |||
| 656 | (indent-rigidly b (point) sh-indentation))) | 649 | (indent-rigidly b (point) sh-indentation))) |
| 657 | skeleton-end-hook (lambda () | 650 | skeleton-end-hook (lambda () |
| 658 | (or (eolp) (newline) (indent-relative))) | 651 | (or (eolp) (newline) (indent-relative))) |
| 659 | paragraph-start (concat page-delimiter "\\|$") | 652 | paragraph-start (concat page-delimiter "\\|$") |
| 660 | paragraph-separate paragraph-start | 653 | paragraph-separate paragraph-start |
| 661 | comment-start "# " | 654 | comment-start "# " |
| 662 | comint-dynamic-complete-functions sh-dynamic-complete-functions | 655 | comint-dynamic-complete-functions sh-dynamic-complete-functions |
| 663 | ;; we can't look if previous line ended with `\' | 656 | ;; we can't look if previous line ended with `\' |
| 664 | comint-prompt-regexp "^[ \t]*" | 657 | comint-prompt-regexp "^[ \t]*" |
| 665 | font-lock-defaults | 658 | font-lock-defaults |
| 666 | '((sh-font-lock-keywords | 659 | `((sh-font-lock-keywords |
| 667 | sh-font-lock-keywords-1 | 660 | sh-font-lock-keywords-1 |
| 668 | sh-font-lock-keywords-2) | 661 | sh-font-lock-keywords-2) |
| 669 | nil nil | 662 | ,sh-font-lock-keywords-only |
| 663 | nil | ||
| 670 | ((?/ . "w") (?~ . "w") (?. . "w") (?- . "w") (?_ . "w"))) | 664 | ((?/ . "w") (?~ . "w") (?. . "w") (?- . "w") (?_ . "w"))) |
| 671 | skeleton-pair-alist '((?` _ ?`)) | 665 | skeleton-pair-alist '((?` _ ?`)) |
| 672 | skeleton-pair-filter 'sh-quoted-p | 666 | skeleton-pair-filter 'sh-quoted-p |