aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2011-02-09 13:59:55 -0500
committerStefan Monnier2011-02-09 13:59:55 -0500
commitccded26c1e57045a8941dd69b2566ac9a49cfe4b (patch)
tree3d44fbef168b0f826a035dc7db88902b68c1b3b7
parent33cd3ee46b26307e4f0ccd2a622a736e05041a25 (diff)
downloademacs-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.
-rw-r--r--ChangeLog4
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/progmodes/sh-script.el48
-rw-r--r--test/ChangeLog5
-rwxr-xr-xtest/indent/shell.rc30
-rwxr-xr-xtest/indent/shell.sh98
6 files changed, 166 insertions, 24 deletions
diff --git a/ChangeLog b/ChangeLog
index 8b7b674470c..d75ec5150f7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
12011-02-09 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * .bzrignore: Ignore globals.h and related stamp.
4
12011-02-09 Paul Eggert <eggert@cs.ucla.edu> 52011-02-09 Paul Eggert <eggert@cs.ucla.edu>
2 6
3 * lib/Makefile.in, lib/gnulib.mk: Regenerate. 7 * lib/Makefile.in, lib/gnulib.mk: Regenerate.
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index dd3bb3d475c..67276ef574d 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
12011-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
12011-02-09 Deniz Dogan <deniz.a.m.dogan@gmail.com> 62011-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
diff --git a/test/ChangeLog b/test/ChangeLog
index f555878cb49..3f2dbec1e55 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,8 @@
12011-02-09 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * indent/shell.sh:
4 * indent/shell.rc: New files.
5
12011-01-27 Chong Yidong <cyd@stupidchicken.com> 62011-01-27 Chong Yidong <cyd@stupidchicken.com>
2 7
3 * automated/font-parse-tests.el: Move from 8 * automated/font-parse-tests.el: Move from
diff --git a/test/indent/shell.rc b/test/indent/shell.rc
new file mode 100755
index 00000000000..841223555b9
--- /dev/null
+++ b/test/indent/shell.rc
@@ -0,0 +1,30 @@
1#!/bin/rc
2
3if (foo) {
4 echo 1
5}
6if not {
7 echo 2
8}
9
10if (foo)
11 echo 3 # KNOWN INDENT BUG
12if not
13 echo 4 # KNOWN INDENT BUG
14
15switch ($a) {
16 case 3
17 echo 4
18 case 5
19 echo 7
20 for (i in a b c) {
21 echo $i
22 }
23 for (i in a b c)
24 echo "$i" # KNOWN INDENT BUG
25 echo titi
26
27 case *
28 echo other
29}
30
diff --git a/test/indent/shell.sh b/test/indent/shell.sh
new file mode 100755
index 00000000000..89f47d0bfe3
--- /dev/null
+++ b/test/indent/shell.sh
@@ -0,0 +1,98 @@
1#!/bin/sh
2
3setlock -n /tmp/getmail.lock && echo getmail isn\'t running
4
5# adsgsdg
6
7foo () {
8
9 bar () {
10 blilbi
11 }
12
13 case toto
14 in a) hello # KNOWN INDENT BUG
15 ;; b) hi # KNOWN INDENT BUG
16 esac
17
18 case $toto in
19 a) echo 1;; b) echo 2;;
20 c) echo 3;;
21 esac
22
23 case $as_nl`(ac_space=' '; set) 2>&1` in #(
24 *${as_nl}ac_space=\ *)
25 # `set' does not quote correctly, so add quotes: double-quote
26 # substitution turns \\\\ into \\, and sed turns \\ into \.
27 sed -n \
28 "s/'/'\\\\''/g;
29 s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=/\\1=''/p"
30 ;; #(
31 *)
32 # `set' quotes correctly as required by POSIX, so do not add
33 # quotes.
34 sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
35 ;;
36 esac |
37 cat # KNOWN INDENT BUG
38
39 case toto in
40 -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
41 | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* \
42 | --exec=* | --exe=* | --ex=*)
43 exec_prefix=$ac_optarg ;;
44 5)
45 hello ;;
46 3) hello $(adfad)
47 echo esac ;; # KNOWN INDENT BUG
48 5) hello ;;
49 4) hello ;&
50 4) hello ;;&
51 5) hello ;;
52 5) hello ;;
53 esac
54
55 echo "'" wfgfe
56
57 #!/bin/bash
58 cat << EOF \
59 | cat sadfsafd \
60 sadfsafd "KNOWN INDENT BUG" \
61 | tee -a bug.txt
62asdfsaf
63This is a test case for a bug in bash shell mode text highlighting
64EOF
65
66 cat <<EOF1 <<EOF2 # KNOWN INDENT BUG
67help1
68EOF1
69help2
70EOF2
71}
72bar () {
73 if [ $# == 0 ]; then
74 while
75 f # KNOWN INDENT BUG
76 do
77 bla;
78 done
79 echo "Highlighting is screwed up now"
80 if [ 1 = 1 ]; then
81 # adsgsdg
82 echo "screwed up"
83 fi
84
85 $@ $? $#
86
87 for f in *
88 do
89 sdfg
90 done
91
92 if swrgfef
93 then blas
94 else sdf
95 fi
96
97 fi
98}