From: Stefan Monnier Date: Fri, 8 Nov 2013 04:33:32 +0000 (-0500) Subject: * lisp/progmodes/sh-script.el (sh-smie--sh-keyword-in-p): Don't inf-loop X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~907 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=43668fb19624696232355161ea2ab11f91a23ab4;p=emacs.git * lisp/progmodes/sh-script.el (sh-smie--sh-keyword-in-p): Don't inf-loop at bobp. (sh-smie--sh-keyword-in-p): Recognize keywords at bobp. Fixes: debbugs:15826 --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 7cc658d9e24..6b941c67fce 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2013-11-08 Stefan Monnier + + * progmodes/sh-script.el (sh-smie--sh-keyword-in-p): Don't inf-loop + at bobp (bug#15826). + (sh-smie--sh-keyword-in-p): Recognize keywords at bobp. + 2013-11-08 Darren Hoo * man.el (Man-start-calling): New macro, extracted from diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index 9f5486a08df..2cc43419f2b 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -1730,7 +1730,7 @@ A keyword position is one where if we're looking at something that looks like a keyword, then it is a keyword." (let ((prev (funcall smie-backward-token-function))) (if (zerop (length prev)) - (looking-back "\\s(" (1- (point))) + (looking-back "\\`\\|\\s(" (1- (point))) (assoc prev smie-grammar)))) (defun sh-smie--newline-semi-p (&optional tok) @@ -1804,12 +1804,14 @@ Does not preserve point." (setq prev (funcall smie-backward-token-function)) (cond ((zerop (length prev)) - (if newline - (progn (cl-assert words) (setq res 'word)) + (cond + (newline (cl-assert words) (setq res 'word)) + ((bobp) (setq res 'word)) + (t (setq words t) (condition-case nil (forward-sexp -1) - (scan-error (setq res 'unknown))))) + (scan-error (setq res 'unknown)))))) ((equal prev ";") (if words (setq newline t) (setq res 'keyword)))