diff options
| author | Stefan Monnier | 2011-02-09 13:59:55 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2011-02-09 13:59:55 -0500 |
| commit | ccded26c1e57045a8941dd69b2566ac9a49cfe4b (patch) | |
| tree | 3d44fbef168b0f826a035dc7db88902b68c1b3b7 /lisp | |
| parent | 33cd3ee46b26307e4f0ccd2a622a736e05041a25 (diff) | |
| download | emacs-ccded26c1e57045a8941dd69b2566ac9a49cfe4b.tar.gz emacs-ccded26c1e57045a8941dd69b2566ac9a49cfe4b.zip | |
* lisp/progmodes/sh-script.el (sh-font-lock-open-heredoc): Fix case
of here-doc that immediately follows a comment.
* .bzrignore: Ignore globals.h and related stamp.
* test/indent/shell.sh:
* test/indent/shell.rc: New files.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/progmodes/sh-script.el | 48 |
2 files changed, 29 insertions, 24 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index dd3bb3d475c..67276ef574d 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2011-02-09 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * progmodes/sh-script.el (sh-font-lock-open-heredoc): Fix case | ||
| 4 | of here-doc that immediately follows a comment. | ||
| 5 | |||
| 1 | 2011-02-09 Deniz Dogan <deniz.a.m.dogan@gmail.com> | 6 | 2011-02-09 Deniz Dogan <deniz.a.m.dogan@gmail.com> |
| 2 | 7 | ||
| 3 | * net/rcirc.el (rcirc-ctcp-sender-PING): Simplifying. | 8 | * net/rcirc.el (rcirc-ctcp-sender-PING): Simplifying. |
diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index d80d814156e..900072fe356 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el | |||
| @@ -948,12 +948,12 @@ Point is at the beginning of the next line." | |||
| 948 | ;; We're looking at <<STRING, so we add "^STRING$" to the syntactic | 948 | ;; We're looking at <<STRING, so we add "^STRING$" to the syntactic |
| 949 | ;; font-lock keywords to detect the end of this here document. | 949 | ;; font-lock keywords to detect the end of this here document. |
| 950 | (let ((str (replace-regexp-in-string "['\"]" "" string)) | 950 | (let ((str (replace-regexp-in-string "['\"]" "" string)) |
| 951 | (ppss (save-excursion (syntax-ppss (1- (point)))))) | 951 | (ppss (save-excursion (syntax-ppss eol)))) |
| 952 | (if (nth 4 ppss) | 952 | (if (nth 4 ppss) |
| 953 | ;; The \n not only starts the heredoc but also closes a comment. | 953 | ;; The \n not only starts the heredoc but also closes a comment. |
| 954 | ;; Let's close the comment just before the \n. | 954 | ;; Let's close the comment just before the \n. |
| 955 | (put-text-property (1- (point)) (point) 'syntax-table '(12))) ;">" | 955 | (put-text-property (1- eol) eol 'syntax-table '(12))) ;">" |
| 956 | (if (or (nth 5 ppss) (> (count-lines start (point)) 1)) | 956 | (if (or (nth 5 ppss) (> (count-lines start eol) 1)) |
| 957 | ;; If the sh-escaped-line-re part of sh-here-doc-open-re has matched | 957 | ;; If the sh-escaped-line-re part of sh-here-doc-open-re has matched |
| 958 | ;; several lines, make sure we refontify them together. | 958 | ;; several lines, make sure we refontify them together. |
| 959 | ;; Furthermore, if (nth 5 ppss) is non-nil (i.e. the \n is | 959 | ;; Furthermore, if (nth 5 ppss) is non-nil (i.e. the \n is |
| @@ -961,7 +961,7 @@ Point is at the beginning of the next line." | |||
| 961 | ;; Don't bother fixing it now, but place a multiline property so | 961 | ;; Don't bother fixing it now, but place a multiline property so |
| 962 | ;; that when jit-lock-context-* refontifies the rest of the | 962 | ;; that when jit-lock-context-* refontifies the rest of the |
| 963 | ;; buffer, it also refontifies the current line with it. | 963 | ;; buffer, it also refontifies the current line with it. |
| 964 | (put-text-property start (point) 'syntax-multiline t)) | 964 | (put-text-property start (1+ eol) 'syntax-multiline t)) |
| 965 | (put-text-property eol (1+ eol) 'sh-here-doc-marker str) | 965 | (put-text-property eol (1+ eol) 'sh-here-doc-marker str) |
| 966 | (prog1 sh-here-doc-syntax | 966 | (prog1 sh-here-doc-syntax |
| 967 | (goto-char (+ 2 start)))))) | 967 | (goto-char (+ 2 start)))))) |
| @@ -1083,33 +1083,33 @@ subshells can nest." | |||
| 1083 | (defun sh-syntax-propertize-function (start end) | 1083 | (defun sh-syntax-propertize-function (start end) |
| 1084 | (goto-char start) | 1084 | (goto-char start) |
| 1085 | (sh-syntax-propertize-here-doc end) | 1085 | (sh-syntax-propertize-here-doc end) |
| 1086 | (funcall | 1086 | (funcall |
| 1087 | (syntax-propertize-rules | 1087 | (syntax-propertize-rules |
| 1088 | (sh-here-doc-open-re | 1088 | (sh-here-doc-open-re |
| 1089 | (2 (sh-font-lock-open-heredoc | 1089 | (2 (sh-font-lock-open-heredoc |
| 1090 | (match-beginning 0) (match-string 1) (match-beginning 2)))) | 1090 | (match-beginning 0) (match-string 1) (match-beginning 2)))) |
| 1091 | ("\\s|" (0 (prog1 nil (sh-syntax-propertize-here-doc end)))) | 1091 | ("\\s|" (0 (prog1 nil (sh-syntax-propertize-here-doc end)))) |
| 1092 | ;; A `#' begins a comment when it is unquoted and at the | 1092 | ;; A `#' begins a comment when it is unquoted and at the |
| 1093 | ;; beginning of a word. In the shell, words are separated by | 1093 | ;; beginning of a word. In the shell, words are separated by |
| 1094 | ;; metacharacters. The list of special chars is taken from | 1094 | ;; metacharacters. The list of special chars is taken from |
| 1095 | ;; the single-unix spec of the shell command language (under | 1095 | ;; the single-unix spec of the shell command language (under |
| 1096 | ;; `quoting') but with `$' removed. | 1096 | ;; `quoting') but with `$' removed. |
| 1097 | ("[^|&;<>()`\\\"' \t\n]\\(#+\\)" (1 "_")) | 1097 | ("[^|&;<>()`\\\"' \t\n]\\(#+\\)" (1 "_")) |
| 1098 | ;; In a '...' the backslash is not escaping. | 1098 | ;; In a '...' the backslash is not escaping. |
| 1099 | ("\\(\\\\\\)'" (1 (sh-font-lock-backslash-quote))) | 1099 | ("\\(\\\\\\)'" (1 (sh-font-lock-backslash-quote))) |
| 1100 | ;; Make sure $@ and $? are correctly recognized as sexps. | 1100 | ;; Make sure $@ and $? are correctly recognized as sexps. |
| 1101 | ("\\$\\([?@]\\)" (1 "_")) | 1101 | ("\\$\\([?@]\\)" (1 "_")) |
| 1102 | ;; Distinguish the special close-paren in `case'. | 1102 | ;; Distinguish the special close-paren in `case'. |
| 1103 | (")" (0 (sh-font-lock-paren (match-beginning 0)))) | 1103 | (")" (0 (sh-font-lock-paren (match-beginning 0)))) |
| 1104 | ;; Highlight (possibly nested) subshells inside "" quoted | 1104 | ;; Highlight (possibly nested) subshells inside "" quoted |
| 1105 | ;; regions correctly. | 1105 | ;; regions correctly. |
| 1106 | ("\"\\(?:\\(?:[^\\\"]\\|\\)*?[^\\]\\(?:\\\\\\\\\\)*\\)??\\(\\$(\\|`\\)" | 1106 | ("\"\\(?:\\(?:[^\\\"]\\|\\)*?[^\\]\\(?:\\\\\\\\\\)*\\)??\\(\\$(\\|`\\)" |
| 1107 | (1 (ignore | 1107 | (1 (ignore |
| 1108 | ;; Save excursion because we want to also apply other | 1108 | ;; Save excursion because we want to also apply other |
| 1109 | ;; syntax-propertize rules within the affected region. | 1109 | ;; syntax-propertize rules within the affected region. |
| 1110 | (if (nth 8 (syntax-ppss)) | 1110 | (if (nth 8 (syntax-ppss)) |
| 1111 | (goto-char (1+ (match-beginning 0))) | 1111 | (goto-char (1+ (match-beginning 0))) |
| 1112 | (save-excursion | 1112 | (save-excursion |
| 1113 | (sh-font-lock-quoted-subshell end))))))) | 1113 | (sh-font-lock-quoted-subshell end))))))) |
| 1114 | (point) end)) | 1114 | (point) end)) |
| 1115 | 1115 | ||