aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2006-07-20 21:23:48 +0000
committerStefan Monnier2006-07-20 21:23:48 +0000
commit3a723c3afafefb2f75634691f14ab9f7bf307a8c (patch)
tree24dc342755956fab8e0a2657d3949702128fbb00
parentbde078957d6bf5f61da1b014a0be8795c8eb0304 (diff)
downloademacs-3a723c3afafefb2f75634691f14ab9f7bf307a8c.tar.gz
emacs-3a723c3afafefb2f75634691f14ab9f7bf307a8c.zip
(sh-quoted-subshell): Further fix last change.
-rw-r--r--lisp/ChangeLog12
-rw-r--r--lisp/progmodes/sh-script.el91
2 files changed, 54 insertions, 49 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 6dbd862e4c2..b46a8fef095 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,7 @@
12006-07-20 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * progmodes/sh-script.el (sh-quoted-subshell): Further fix last change.
4
12006-07-20 Jay Belanger <belanger@truman.edu> 52006-07-20 Jay Belanger <belanger@truman.edu>
2 6
3 * calc.el (calc-previous-alg-entry): Remove variable. 7 * calc.el (calc-previous-alg-entry): Remove variable.
@@ -12,7 +16,7 @@
12 (calcAlg-previous): Use `previous-history-element' instead of 16 (calcAlg-previous): Use `previous-history-element' instead of
13 `calc-previous-alg-entry'. 17 `calc-previous-alg-entry'.
14 (calc-do-alg-entry): Use history when calling `read-from-minibuffer'. 18 (calc-do-alg-entry): Use history when calling `read-from-minibuffer'.
15 Change keybinding for `calcAlg-plus-minus', add keybindings for 19 Change keybinding for `calcAlg-plus-minus', add keybindings for
16 `previous-history-element' and `next-history-element'. 20 `previous-history-element' and `next-history-element'.
17 21
18 * calc-rewr.el (calc-match): Remove reference to 22 * calc-rewr.el (calc-match): Remove reference to
@@ -35,14 +39,14 @@
35 39
362006-07-20 Alan Mackenzie <acm@muc.de> 402006-07-20 Alan Mackenzie <acm@muc.de>
37 41
38 * progmodes/cc-langs.el (c-emacs-variable-inits): new variable. 42 * progmodes/cc-langs.el (c-emacs-variable-inits): New variable.
39 (c-lang-setvar): new macro. 43 (c-lang-setvar): New macro.
40 (c-make-init-lang-vars-fun): Use the initialization forms in 44 (c-make-init-lang-vars-fun): Use the initialization forms in
41 c-emacs-variable-inits in addition to those in c-lang-variable-inits. 45 c-emacs-variable-inits in addition to those in c-lang-variable-inits.
42 (comment-start, comment-end, comment-start-skip): Change these from 46 (comment-start, comment-end, comment-start-skip): Change these from
43 c-lang-defvar's to c-lang-setvar's. 47 c-lang-defvar's to c-lang-setvar's.
44 48
45 * progmodes/cc-mode.el (c-make-emacs-variables-local): new macro, 49 * progmodes/cc-mode.el (c-make-emacs-variables-local): New macro,
46 which calls make-local-variable on the elements of 50 which calls make-local-variable on the elements of
47 c-emacs-variable-inits. 51 c-emacs-variable-inits.
48 (c-init-language-vars-for): Call this new macro. 52 (c-init-language-vars-for): Call this new macro.
diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el
index 6e933d087e2..6098c8be067 100644
--- a/lisp/progmodes/sh-script.el
+++ b/lisp/progmodes/sh-script.el
@@ -980,54 +980,55 @@ Point is at the beginning of the next line."
980 (re-search-forward sh-here-doc-re limit t)) 980 (re-search-forward sh-here-doc-re limit t))
981 981
982(defun sh-quoted-subshell (limit) 982(defun sh-quoted-subshell (limit)
983 "Search for a subshell embedded in a string. Find all the unescaped 983 "Search for a subshell embedded in a string.
984\" characters within said subshell, remembering that subshells can nest." 984Find all the unescaped \" characters within said subshell, remembering that
985subshells can nest."
985 ;; FIXME: This can (and often does) match multiple lines, yet it makes no 986 ;; FIXME: This can (and often does) match multiple lines, yet it makes no
986 ;; effort to handle multiline cases correctly, so it ends up being 987 ;; effort to handle multiline cases correctly, so it ends up being
987 ;; rather flakey. 988 ;; rather flakey.
988 (if (re-search-forward "\"\\(?:\\(?:.\\|\n\\)*?[^\\]\\(\\\\\\\\\\)*\\)??\\(\\$(\\|`\\)" limit t) 989 (when (re-search-forward "\"\\(?:\\(?:.\\|\n\\)*?[^\\]\\(?:\\\\\\\\\\)*\\)??\\(\\$(\\|`\\)" limit t)
989 ;; bingo we have a $( or a ` inside a "" 990 ;; bingo we have a $( or a ` inside a ""
990 (let ((char (char-after (point))) 991 (let ((char (char-after (point)))
991 (continue t) 992 (continue t)
992 (pos (point)) 993 (pos (point))
993 (data nil) ;; value to put into match-data (and return) 994 (data nil) ;; value to put into match-data (and return)
994 (last nil) ;; last char seen 995 (last nil) ;; last char seen
995 (bq (equal (match-string 1) "`")) ;; ` state flip-flop 996 (bq (equal (match-string 1) "`")) ;; ` state flip-flop
996 (seen nil) ;; list of important positions 997 (seen nil) ;; list of important positions
997 (nest 1)) ;; subshell nesting level 998 (nest 1)) ;; subshell nesting level
998 (while (and continue char (<= pos limit)) 999 (while (and continue char (<= pos limit))
999 ;; unescaped " inside a $( ... ) construct. 1000 ;; unescaped " inside a $( ... ) construct.
1000 ;; state machine time... 1001 ;; state machine time...
1001 ;; \ => ignore next char; 1002 ;; \ => ignore next char;
1002 ;; ` => increase or decrease nesting level based on bq flag 1003 ;; ` => increase or decrease nesting level based on bq flag
1003 ;; ) [where nesting > 0] => decrease nesting 1004 ;; ) [where nesting > 0] => decrease nesting
1004 ;; ( [where nesting > 0] => increase nesting 1005 ;; ( [where nesting > 0] => increase nesting
1005 ;; ( [preceeded by $ ] => increase nesting 1006 ;; ( [preceeded by $ ] => increase nesting
1006 ;; " [nesting <= 0 ] => terminate, we're done. 1007 ;; " [nesting <= 0 ] => terminate, we're done.
1007 ;; " [nesting > 0 ] => remember this, it's not a proper " 1008 ;; " [nesting > 0 ] => remember this, it's not a proper "
1008 ;; FIXME: don't count parens that appear within quotes. 1009 ;; FIXME: don't count parens that appear within quotes.
1009 (cond 1010 (cond
1010 ((eq ?\\ last) nil) 1011 ((eq ?\\ last) nil)
1011 ((eq ?\` char) (setq nest (+ nest (if bq -1 1)) bq (not bq))) 1012 ((eq ?\` char) (setq nest (+ nest (if bq -1 1)) bq (not bq)))
1012 ((and (> nest 0) (eq ?\) char)) (setq nest (1- nest))) 1013 ((and (> nest 0) (eq ?\) char)) (setq nest (1- nest)))
1013 ((and (eq ?$ last) (eq ?\( char)) (setq nest (1+ nest))) 1014 ((and (eq ?$ last) (eq ?\( char)) (setq nest (1+ nest)))
1014 ((and (> nest 0) (eq ?\( char)) (setq nest (1+ nest))) 1015 ((and (> nest 0) (eq ?\( char)) (setq nest (1+ nest)))
1015 ((eq char ?\") 1016 ((eq char ?\")
1016 (if (>= 0 nest) (setq continue nil) (push pos seen)))) 1017 (if (>= 0 nest) (setq continue nil) (push pos seen))))
1017 ;;(message "POS: %d [%d]" pos nest) 1018 ;;(message "POS: %d [%d]" pos nest)
1018 (setq last char 1019 (setq last char
1019 pos (1+ pos) 1020 pos (1+ pos)
1020 char (char-after pos)) ) 1021 char (char-after pos)) )
1021 ;; FIXME: why construct a costly match data to pass to 1022 ;; FIXME: why construct a costly match data to pass to
1022 ;; sh-apply-quoted-subshell rather than apply the highlight 1023 ;; sh-apply-quoted-subshell rather than apply the highlight
1023 ;; directly here? -- Stef 1024 ;; directly here? -- Stef
1024 (when seen 1025 (when seen
1025 ;;(message "SEEN: %S" seen) 1026 ;;(message "SEEN: %S" seen)
1026 (setq data (list (current-buffer))) 1027 (setq data (list (current-buffer)))
1027 (dolist(P seen) 1028 (dolist(P seen)
1028 (setq data (cons P (cons (1+ P) data)))) 1029 (setq data (cons P (cons (1+ P) data))))
1029 (store-match-data data)) 1030 (store-match-data data))
1030 data) )) 1031 data) ))
1031 1032
1032(defun sh-is-quoted-p (pos) 1033(defun sh-is-quoted-p (pos)
1033 (and (eq (char-before pos) ?\\) 1034 (and (eq (char-before pos) ?\\)