]> code.delx.au - gnu-emacs/commitdiff
* lisp/progmodes/sh-script.el (sh-smie--sh-keyword-in-p): Don't inf-loop
authorStefan Monnier <monnier@iro.umontreal.ca>
Fri, 8 Nov 2013 04:33:32 +0000 (23:33 -0500)
committerStefan Monnier <monnier@iro.umontreal.ca>
Fri, 8 Nov 2013 04:33:32 +0000 (23:33 -0500)
at bobp.
(sh-smie--sh-keyword-in-p): Recognize keywords at bobp.

Fixes: debbugs:15826
lisp/ChangeLog
lisp/progmodes/sh-script.el

index 7cc658d9e24fede69c5077fb86db8cb98db5b89a..6b941c67fce025483890bbd50a2248a472540ebe 100644 (file)
@@ -1,3 +1,9 @@
+2013-11-08  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * 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  <darren.hoo@gmail.com>
 
        * man.el (Man-start-calling): New macro, extracted from
index 9f5486a08df49e5698358d2910fdf1dcdd048c67..2cc43419f2b7c898bece95fb1a51bb368a2fb87e 100644 (file)
@@ -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)))