comparison lisp/progmodes/sh-script.el @ 81462:8de1bb9519fe

(sh-font-lock-paren): Mark the relevant text with font-lock-multiline.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Mon, 18 Jun 2007 20:10:06 +0000
parents db32b7ba9c76
children bf55b9b62e57 988f1edc9674
comparison
equal deleted inserted replaced
81461:e9cd7fd7a63b 81462:8de1bb9519fe
169 ;; To try and address points 2 3 and 5 I used a feature that cperl mode 169 ;; To try and address points 2 3 and 5 I used a feature that cperl mode
170 ;; uses, that of a text's syntax property. This, however, has 2 170 ;; uses, that of a text's syntax property. This, however, has 2
171 ;; disadvantages: 171 ;; disadvantages:
172 ;; 1. We need to scan the buffer to find which ")" symbols belong to a 172 ;; 1. We need to scan the buffer to find which ")" symbols belong to a
173 ;; case alternative, to find any here documents, and handle "$#". 173 ;; case alternative, to find any here documents, and handle "$#".
174 ;; 2. Setting the text property makes the buffer modified. If the
175 ;; buffer is read-only buffer we have to cheat and bypass the read-only
176 ;; status. This is for cases where the buffer started read-only buffer
177 ;; but the user issued `toggle-read-only'.
178 ;; 174 ;;
179 ;; Bugs 175 ;; Bugs
180 ;; ---- 176 ;; ----
181 ;; - Indenting many lines is slow. It currently does each line 177 ;; - Indenting many lines is slow. It currently does each line
182 ;; independently, rather than saving state information. 178 ;; independently, rather than saving state information.
183 ;; 179 ;;
184 ;; - `sh-learn-buffer-indent' is extremely slow. 180 ;; - `sh-learn-buffer-indent' is extremely slow.
181 ;;
182 ;; - "case $x in y) echo ;; esac)" the last ) is mis-identified as being
183 ;; part of a case-pattern. You need to add a semi-colon after "esac" to
184 ;; coerce sh-script into doing the right thing.
185 ;;
186 ;; - "echo $z in ps | head)" the last ) is mis-identified as being part of
187 ;; a case-pattern. You need to put the "in" between quotes to coerce
188 ;; sh-script into doing the right thing.
189 ;;
190 ;; - A line starting with "}>foo" is not indented like "} >foo".
185 ;; 191 ;;
186 ;; Richard Sharman <rsharman@pobox.com> June 1999. 192 ;; Richard Sharman <rsharman@pobox.com> June 1999.
187 193
188 ;;; Code: 194 ;;; Code:
189 195
1050 ;; Maybe we've bumped into an escaped newline. 1056 ;; Maybe we've bumped into an escaped newline.
1051 (sh-is-quoted-p (point))) 1057 (sh-is-quoted-p (point)))
1052 (backward-char 1)) 1058 (backward-char 1))
1053 (when (eq (char-before) ?|) 1059 (when (eq (char-before) ?|)
1054 (backward-char 1) t))) 1060 (backward-char 1) t)))
1055 (when (save-excursion (backward-char 2) (looking-at ";;\\|in")) 1061 ;; FIXME: ";; esac )" is a case that looks like a case-pattern but it's
1062 ;; really just a close paren after a case statement. I.e. if we skipped
1063 ;; over `esac' just now, we're not looking at a case-pattern.
1064 (when (progn (backward-char 2)
1065 (if (> start (line-end-position))
1066 (put-text-property (point) (1+ start)
1067 'font-lock-multiline t))
1068 ;; FIXME: The `in' may just be a random argument to
1069 ;; a normal command rather than the real `in' keyword.
1070 ;; I.e. we should look back to try and find the
1071 ;; corresponding `case'.
1072 (looking-at ";;\\|in"))
1056 sh-st-punc))) 1073 sh-st-punc)))
1057 1074
1058 (defun sh-font-lock-backslash-quote () 1075 (defun sh-font-lock-backslash-quote ()
1059 (if (eq (save-excursion (nth 3 (syntax-ppss (match-beginning 0)))) ?\') 1076 (if (eq (save-excursion (nth 3 (syntax-ppss (match-beginning 0)))) ?\')
1060 ;; In a '...' the backslash is not escaping. 1077 ;; In a '...' the backslash is not escaping.