aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorStefan Monnier2013-03-14 10:48:03 -0400
committerStefan Monnier2013-03-14 10:48:03 -0400
commitefe8bf5d9bd5ec99867abe624ddb055236a882f4 (patch)
treef019dccf8633cfb73fc55dbb5dc06d4a810fa496 /lisp
parent95b43468a4958795cee5e7bd232239c5f61d2475 (diff)
downloademacs-efe8bf5d9bd5ec99867abe624ddb055236a882f4.tar.gz
emacs-efe8bf5d9bd5ec99867abe624ddb055236a882f4.zip
* lisp/emacs-lisp/smie.el (smie-auto-fill): Don't inf-loop if there's no
token before point. Fixes: debbugs:13942
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog17
-rw-r--r--lisp/emacs-lisp/smie.el53
2 files changed, 39 insertions, 31 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 993d9789bad..71460a3d7a7 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
12013-03-14 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * emacs-lisp/smie.el (smie-auto-fill): Don't inf-loop if there's no
4 token before point (bug#13942).
5
12013-03-14 Leo Liu <sdl.web@gmail.com> 62013-03-14 Leo Liu <sdl.web@gmail.com>
2 7
3 * thingatpt.el (end-of-sexp): Fix bug#13952. Use syntax-after. 8 * thingatpt.el (end-of-sexp): Fix bug#13952. Use syntax-after.
@@ -25,8 +30,8 @@
25 30
262013-02-20 Fabián Ezequiel Gallina <fgallina@cuca> 312013-02-20 Fabián Ezequiel Gallina <fgallina@cuca>
27 32
28 * progmodes/python.el (python-info-current-defun): Enhance 33 * progmodes/python.el (python-info-current-defun):
29 match-data cluttering prevention. 34 Enhance match-data cluttering prevention.
30 35
312013-02-19 Glenn Morris <rgm@gnu.org> 362013-02-19 Glenn Morris <rgm@gnu.org>
32 37
@@ -40,8 +45,8 @@
40 45
412013-02-19 Fabián Ezequiel Gallina <fgallina@cuca> 462013-02-19 Fabián Ezequiel Gallina <fgallina@cuca>
42 47
43 * progmodes/python.el (python-indent-context): Fix 48 * progmodes/python.el (python-indent-context):
44 python-info-line-ends-backslash-p call. 49 Fix python-info-line-ends-backslash-p call.
45 (python-info-line-ends-backslash-p) 50 (python-info-line-ends-backslash-p)
46 (python-info-beginning-of-backslash): Respect line-number 51 (python-info-beginning-of-backslash): Respect line-number
47 argument. 52 argument.
@@ -119,8 +124,8 @@
119 searching for its match. 124 searching for its match.
120 (c-invalidate-state-cache-1): Add HERE parameter to function call. 125 (c-invalidate-state-cache-1): Add HERE parameter to function call.
121 (c-parse-state-1): Don't narrow here for 'forward strategy, 126 (c-parse-state-1): Don't narrow here for 'forward strategy,
122 instead passing extra parameter HERE to several functions. Remove 127 instead passing extra parameter HERE to several functions.
123 'BOD strategy. 128 Remove 'BOD strategy.
124 129
1252013-02-01 Stefan Monnier <monnier@iro.umontreal.ca> 1302013-02-01 Stefan Monnier <monnier@iro.umontreal.ca>
126 131
diff --git a/lisp/emacs-lisp/smie.el b/lisp/emacs-lisp/smie.el
index eb3fa8f3b09..18cc0e811ce 100644
--- a/lisp/emacs-lisp/smie.el
+++ b/lisp/emacs-lisp/smie.el
@@ -1631,31 +1631,34 @@ to which that point should be aligned, if we were to reindent it.")
1631(defun smie-auto-fill () 1631(defun smie-auto-fill ()
1632 (let ((fc (current-fill-column))) 1632 (let ((fc (current-fill-column)))
1633 (while (and fc (> (current-column) fc)) 1633 (while (and fc (> (current-column) fc))
1634 (cond 1634 (or (unless (or (nth 8 (save-excursion
1635 ((not (or (nth 8 (save-excursion 1635 (syntax-ppss (line-beginning-position))))
1636 (syntax-ppss (line-beginning-position)))) 1636 (nth 8 (syntax-ppss)))
1637 (nth 8 (syntax-ppss)))) 1637 (save-excursion
1638 (save-excursion 1638 (let ((end (point))
1639 (beginning-of-line) 1639 (bsf (progn (beginning-of-line)
1640 (smie-indent-forward-token) 1640 (smie-indent-forward-token)
1641 (let ((bsf (point)) 1641 (point)))
1642 (gain 0) 1642 (gain 0)
1643 curcol) 1643 curcol)
1644 (while (<= (setq curcol (current-column)) fc) 1644 (while (and (<= (point) end)
1645 ;; FIXME? `smie-indent-calculate' can (and often will) 1645 (<= (setq curcol (current-column)) fc))
1646 ;; return a result that actually depends on the presence/absence 1646 ;; FIXME? `smie-indent-calculate' can (and often will)
1647 ;; of a newline, so the gain computed here may not be accurate, 1647 ;; return a result that actually depends on the
1648 ;; but in practice it seems to works well enough. 1648 ;; presence/absence of a newline, so the gain computed here
1649 (let* ((newcol (smie-indent-calculate)) 1649 ;; may not be accurate, but in practice it seems to works
1650 (newgain (- curcol newcol))) 1650 ;; well enough.
1651 (when (> newgain gain) 1651 (let* ((newcol (smie-indent-calculate))
1652 (setq gain newgain) 1652 (newgain (- curcol newcol)))
1653 (setq bsf (point)))) 1653 (when (> newgain gain)
1654 (smie-indent-forward-token)) 1654 (setq gain newgain)
1655 (when (> gain 0) 1655 (setq bsf (point))))
1656 (goto-char bsf) 1656 (smie-indent-forward-token))
1657 (newline-and-indent))))) 1657 (when (> gain 0)
1658 (t (do-auto-fill)))))) 1658 (goto-char bsf)
1659 (newline-and-indent)
1660 'done))))
1661 (do-auto-fill)))))
1659 1662
1660 1663
1661(defun smie-setup (grammar rules-function &rest keywords) 1664(defun smie-setup (grammar rules-function &rest keywords)