From: Stefan Monnier Date: Mon, 29 Oct 2012 00:06:39 +0000 (-0400) Subject: * lisp/progmodes/sh-script.el (sh-font-lock-paren): Also put punctuation X-Git-Tag: emacs-24.2.90~209^2~30 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b3871e59da478e32561f9c09e61ed1383d51a0c5;p=emacs.git * lisp/progmodes/sh-script.el (sh-font-lock-paren): Also put punctuation syntax to the matching opener, if any. (sh-smie-sh-forward-token, sh-smie-sh-backward-token): Recognize this matching open as a "case-(". (sh-smie-rc-grammar): Add a corresponding rule for it. Fixes: debbugs:12547 --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 999a06648ac..3265f8acf41 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,11 @@ +2012-10-29 Stefan Monnier + + * progmodes/sh-script.el (sh-font-lock-paren): Also put punctuation + syntax to the matching opener, if any (bug#12547). + (sh-smie-sh-forward-token, sh-smie-sh-backward-token): Recognize this + matching open as a "case-(". + (sh-smie-rc-grammar): Add a corresponding rule for it. + 2012-10-28 Daniel Hackney * emacs-lisp/package.el (package-generate-autoloads): Kill buffer diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index 06ded5fb53d..daa83620051 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -1033,51 +1033,57 @@ subshells can nest." (defun sh-font-lock-paren (start) (unless (nth 8 (syntax-ppss)) (save-excursion - (goto-char start) - ;; Skip through all patterns - (while - (progn - (while - (progn - (forward-comment (- (point-max))) - (when (and (eolp) (sh-is-quoted-p (point))) - (forward-char -1) - t))) - ;; Skip through one pattern - (while - (or (/= 0 (skip-syntax-backward "w_")) - (/= 0 (skip-chars-backward "-$=?[]*@/\\\\")) - (and (sh-is-quoted-p (1- (point))) - (goto-char (- (point) 2))) - (when (memq (char-before) '(?\" ?\' ?\})) - (condition-case nil (progn (backward-sexp 1) t) - (error nil))))) - ;; Patterns can be preceded by an open-paren (Bug#1320). - (if (eq (char-before (point)) ?\() + (let ((open nil)) + (goto-char start) + ;; Skip through all patterns + (while + (progn + (while + (progn + (forward-comment (- (point-max))) + (when (and (eolp) (sh-is-quoted-p (point))) + (forward-char -1) + t))) + ;; Skip through one pattern + (while + (or (/= 0 (skip-syntax-backward "w_")) + (/= 0 (skip-chars-backward "-$=?[]*@/\\\\")) + (and (sh-is-quoted-p (1- (point))) + (goto-char (- (point) 2))) + (when (memq (char-before) '(?\" ?\' ?\})) + (condition-case nil (progn (backward-sexp 1) t) + (error nil))))) + ;; Patterns can be preceded by an open-paren (bug#1320). + (when (eq (char-before (point)) ?\() + (backward-char 1) + (setq open (point))) + (while (progn + (forward-comment (- (point-max))) + ;; Maybe we've bumped into an escaped newline. + (sh-is-quoted-p (point))) (backward-char 1)) - (while (progn - (forward-comment (- (point-max))) - ;; Maybe we've bumped into an escaped newline. - (sh-is-quoted-p (point))) - (backward-char 1)) - (when (eq (char-before) ?|) - (backward-char 1) t))) - (and (> (point) (1+ (point-min))) - (progn (backward-char 2) - (if (> start (line-end-position)) - (put-text-property (point) (1+ start) - 'syntax-multiline t)) - ;; FIXME: The `in' may just be a random argument to - ;; a normal command rather than the real `in' keyword. - ;; I.e. we should look back to try and find the - ;; corresponding `case'. - (and (looking-at ";[;&]\\|\\_ (point) (1+ (point-min))) + (progn (backward-char 2) + (if (> start (line-end-position)) + (put-text-property (point) (1+ start) + 'syntax-multiline t)) + ;; FIXME: The `in' may just be a random argument to + ;; a normal command rather than the real `in' keyword. + ;; I.e. we should look back to try and find the + ;; corresponding `case'. + (and (looking-at ";[;&]\\|\\_