From 43668fb19624696232355161ea2ab11f91a23ab4 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Thu, 7 Nov 2013 23:33:32 -0500 Subject: [PATCH] * 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 --- lisp/ChangeLog | 6 ++++++ lisp/progmodes/sh-script.el | 10 ++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 7cc658d9e2..6b941c67fc 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 9f5486a08d..2cc43419f2 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))) -- 2.39.2