diff options
| -rw-r--r-- | lisp/progmodes/sh-script.el | 50 |
1 files changed, 14 insertions, 36 deletions
diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index 30effb24c14..de456719d04 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el | |||
| @@ -179,25 +179,22 @@ the car and cdr are the same symbol.") | |||
| 179 | 179 | ||
| 180 | 180 | ||
| 181 | (defvar sh-mode-syntax-table | 181 | (defvar sh-mode-syntax-table |
| 182 | '((csh eval identity sh) | 182 | '((sh eval sh-mode-syntax-table () |
| 183 | (sh eval sh-mode-syntax-table () | 183 | ?\# "<" |
| 184 | ;; #'s meanings depend on context which can't be expressed here | 184 | ?\^l ">#" |
| 185 | ;; ?\# "<" | 185 | ?\n ">#" |
| 186 | ;; ?\^l ">#" | ||
| 187 | ;; ?\n ">#" | ||
| 188 | ?\" "\"\"" | 186 | ?\" "\"\"" |
| 189 | ?\' "\"'" | 187 | ?\' "\"'" |
| 190 | ?\` ".`" | 188 | ?\` "\"`" |
| 191 | ?$ "_" | 189 | ?$ "\\" ; `escape' so $# doesn't start a comment |
| 192 | ?! "_" | 190 | ?! "_" |
| 193 | ?% "_" | 191 | ?% "_" |
| 194 | ?: "_" | 192 | ?: "_" |
| 195 | ?. "_" | 193 | ?. "_" |
| 196 | ?^ "_" | 194 | ?^ "_" |
| 197 | ?~ "_") | 195 | ?~ "_") |
| 198 | (rc eval sh-mode-syntax-table sh | 196 | (csh eval identity sh) |
| 199 | ?\" "_" | 197 | (rc eval identity sh)) |
| 200 | ?\` ".")) | ||
| 201 | "Syntax-table used in Shell-Script mode. See `sh-feature'.") | 198 | "Syntax-table used in Shell-Script mode. See `sh-feature'.") |
| 202 | 199 | ||
| 203 | 200 | ||
| @@ -279,16 +276,6 @@ the car and cdr are the same symbol.") | |||
| 279 | See `sh-feature'.") | 276 | See `sh-feature'.") |
| 280 | 277 | ||
| 281 | 278 | ||
| 282 | (defvar sh-comment-prefix | ||
| 283 | '((csh . "\\(^\\|[^$]\\|\\$[^{]\\)") | ||
| 284 | (rc eval identity csh) | ||
| 285 | (sh . "\\(^\\|[ \t|&;()]\\)")) | ||
| 286 | "*Regexp matching what may come before a comment `#'. | ||
| 287 | This must contain one \\(grouping\\) since it is the basis for fontifying | ||
| 288 | comments as well as for `comment-start-skip'. | ||
| 289 | See `sh-feature'.") | ||
| 290 | |||
| 291 | |||
| 292 | (defvar sh-assignment-regexp | 279 | (defvar sh-assignment-regexp |
| 293 | '((csh . "\\<\\([a-zA-Z0-9_]+\\)\\(\\[.+\\]\\)?[ \t]*[-+*/%^]?=") | 280 | '((csh . "\\<\\([a-zA-Z0-9_]+\\)\\(\\[.+\\]\\)?[ \t]*[-+*/%^]?=") |
| 294 | ;; actually spaces are only supported in let/(( ... )) | 281 | ;; actually spaces are only supported in let/(( ... )) |
| @@ -544,12 +531,6 @@ See `sh-feature'.") | |||
| 544 | (defvar sh-font-lock-keywords-2 () | 531 | (defvar sh-font-lock-keywords-2 () |
| 545 | "*Yet more rules for highlighting shell scripts. See `sh-feature'.") | 532 | "*Yet more rules for highlighting shell scripts. See `sh-feature'.") |
| 546 | 533 | ||
| 547 | (defvar sh-font-lock-keywords-only t | ||
| 548 | "*Value of `font-lock-keywords-only' for highlighting shell scripts. | ||
| 549 | Default value is `t' because Emacs' syntax is not expressive enough to | ||
| 550 | detect that $# does not start a comment. Thus comments are fontified by | ||
| 551 | regexp which means that a single apostrophe in a comment turns everything | ||
| 552 | upto the next one or end of buffer into a string.") | ||
| 553 | 534 | ||
| 554 | ;; mode-command and utility functions | 535 | ;; mode-command and utility functions |
| 555 | 536 | ||
| @@ -641,7 +622,7 @@ with your script for an edit-interpret-debug cycle." | |||
| 641 | paragraph-start (concat page-delimiter "\\|$") | 622 | paragraph-start (concat page-delimiter "\\|$") |
| 642 | paragraph-separate paragraph-start | 623 | paragraph-separate paragraph-start |
| 643 | comment-start "# " | 624 | comment-start "# " |
| 644 | comment-start-skip (concat (sh-feature sh-comment-prefix) "#+[\t ]*") | 625 | comment-start-skip "#+[\t ]*" |
| 645 | comint-dynamic-complete-functions sh-dynamic-complete-functions | 626 | comint-dynamic-complete-functions sh-dynamic-complete-functions |
| 646 | ;; we can't look if previous line ended with `\' | 627 | ;; we can't look if previous line ended with `\' |
| 647 | comint-prompt-regexp "^[ \t]*" | 628 | comint-prompt-regexp "^[ \t]*" |
| @@ -649,8 +630,7 @@ with your script for an edit-interpret-debug cycle." | |||
| 649 | `((sh-font-lock-keywords | 630 | `((sh-font-lock-keywords |
| 650 | sh-font-lock-keywords-1 | 631 | sh-font-lock-keywords-1 |
| 651 | sh-font-lock-keywords-2) | 632 | sh-font-lock-keywords-2) |
| 652 | ,sh-font-lock-keywords-only | 633 | nil nil |
| 653 | nil | ||
| 654 | ((?/ . "w") (?~ . "w") (?. . "w") (?- . "w") (?_ . "w"))) | 634 | ((?/ . "w") (?~ . "w") (?. . "w") (?- . "w") (?_ . "w"))) |
| 655 | skeleton-pair-alist '((?` _ ?`)) | 635 | skeleton-pair-alist '((?` _ ?`)) |
| 656 | skeleton-pair-filter 'sh-quoted-p | 636 | skeleton-pair-filter 'sh-quoted-p |
| @@ -659,8 +639,8 @@ with your script for an edit-interpret-debug cycle." | |||
| 659 | skeleton-filter 'sh-feature | 639 | skeleton-filter 'sh-feature |
| 660 | skeleton-newline-indent-rigidly t) | 640 | skeleton-newline-indent-rigidly t) |
| 661 | (save-excursion | 641 | (save-excursion |
| 662 | ;; parse or insert magic number for exec() and set all variables depending | 642 | ;; Parse or insert magic number for exec, and set all variables depending |
| 663 | ;; on the shell thus determined | 643 | ;; on the shell thus determined. |
| 664 | (goto-char (point-min)) | 644 | (goto-char (point-min)) |
| 665 | (and (zerop (buffer-size)) | 645 | (and (zerop (buffer-size)) |
| 666 | (not buffer-read-only) | 646 | (not buffer-read-only) |
| @@ -675,9 +655,7 @@ with your script for an edit-interpret-debug cycle." | |||
| 675 | This adds rules for comments and assignments." | 655 | This adds rules for comments and assignments." |
| 676 | (sh-feature sh-font-lock-keywords | 656 | (sh-feature sh-font-lock-keywords |
| 677 | (lambda (list) | 657 | (lambda (list) |
| 678 | `((,(concat (sh-feature sh-comment-prefix) "\\(#.*\\)") | 658 | `((,(sh-feature sh-assignment-regexp) |
| 679 | 2 font-lock-comment-face t) | ||
| 680 | (,(sh-feature sh-assignment-regexp) | ||
| 681 | 1 font-lock-variable-name-face) | 659 | 1 font-lock-variable-name-face) |
| 682 | ,@keywords | 660 | ,@keywords |
| 683 | ,@list)))) | 661 | ,@list)))) |
| @@ -728,7 +706,7 @@ Calls the value of `sh-set-shell-hook' if set." | |||
| 728 | ;;; local-abbrev-table (sh-feature sh-abbrevs) | 706 | ;;; local-abbrev-table (sh-feature sh-abbrevs) |
| 729 | font-lock-keywords nil ; force resetting | 707 | font-lock-keywords nil ; force resetting |
| 730 | font-lock-syntax-table nil | 708 | font-lock-syntax-table nil |
| 731 | comment-start-skip (concat (sh-feature sh-comment-prefix) "#+[\t ]*") | 709 | comment-start-skip "#+[\t ]*" |
| 732 | mode-line-process (format "[%s]" sh-shell) | 710 | mode-line-process (format "[%s]" sh-shell) |
| 733 | sh-shell-variables nil | 711 | sh-shell-variables nil |
| 734 | sh-shell-variables-initialized nil | 712 | sh-shell-variables-initialized nil |