aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2012-05-15 09:25:03 -0400
committerStefan Monnier2012-05-15 09:25:03 -0400
commitfdb058c22800a2cce782c74ee3e3918b432b271c (patch)
tree6ac967135e6f0f58df22f60e721ce92d888403be
parent4f0f72be5614dcb411483aef62d7c9777a5ccb02 (diff)
downloademacs-fdb058c22800a2cce782c74ee3e3918b432b271c.tar.gz
emacs-fdb058c22800a2cce782c74ee3e3918b432b271c.zip
* lisp/emacs-lisp/smie.el (smie-indent--bolp-1): New function.
(smie-indent-keyword): Use it.
-rw-r--r--lisp/ChangeLog9
-rw-r--r--lisp/emacs-lisp/smie.el26
2 files changed, 31 insertions, 4 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index d91fc5d0b22..865bdd7c6a3 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
12012-05-15 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * emacs-lisp/smie.el (smie-indent--bolp-1): New function.
4 (smie-indent-keyword): Use it.
5
12012-05-14 Stefan Merten <smerten@oekonux.de> 62012-05-14 Stefan Merten <smerten@oekonux.de>
2 7
3 * textmodes/rst.el (rst-re-alist): Fix loading (bug#11462). 8 * textmodes/rst.el (rst-re-alist): Fix loading (bug#11462).
@@ -15,8 +20,8 @@
15 20
162012-05-14 Stefan Monnier <monnier@iro.umontreal.ca> 212012-05-14 Stefan Monnier <monnier@iro.umontreal.ca>
17 22
18 * shell.el (shell-parse-pcomplete-arguments): Obey 23 * shell.el (shell-parse-pcomplete-arguments):
19 pcomplete-arg-quote-list inside double-quoted args (Bug#11348). 24 Obey pcomplete-arg-quote-list inside double-quoted args (Bug#11348).
20 25
212012-05-14 Wolfgang Jenkner <wjenkner@inode.at> 262012-05-14 Wolfgang Jenkner <wjenkner@inode.at>
22 27
diff --git a/lisp/emacs-lisp/smie.el b/lisp/emacs-lisp/smie.el
index ae3e060034f..01274b7ba20 100644
--- a/lisp/emacs-lisp/smie.el
+++ b/lisp/emacs-lisp/smie.el
@@ -688,6 +688,7 @@ Possible return values:
688 is too high. FORW-LEVEL is the forw-level of TOKEN, 688 is too high. FORW-LEVEL is the forw-level of TOKEN,
689 POS is its start position in the buffer. 689 POS is its start position in the buffer.
690 (t POS TOKEN): same thing when we bump on the wrong side of a paren. 690 (t POS TOKEN): same thing when we bump on the wrong side of a paren.
691 Instead of t, the `car' can also be some other non-nil non-number value.
691 (nil POS TOKEN): we skipped over a paren-like pair. 692 (nil POS TOKEN): we skipped over a paren-like pair.
692 nil: we skipped over an identifier, matched parentheses, ..." 693 nil: we skipped over an identifier, matched parentheses, ..."
693 (catch 'return 694 (catch 'return
@@ -795,6 +796,7 @@ Possible return values:
795 is too high. LEFT-LEVEL is the left-level of TOKEN, 796 is too high. LEFT-LEVEL is the left-level of TOKEN,
796 POS is its start position in the buffer. 797 POS is its start position in the buffer.
797 (t POS TOKEN): same thing but for an open-paren or the beginning of buffer. 798 (t POS TOKEN): same thing but for an open-paren or the beginning of buffer.
799 Instead of t, the `car' can also be some other non-nil non-number value.
798 (nil POS TOKEN): we skipped over a paren-like pair. 800 (nil POS TOKEN): we skipped over a paren-like pair.
799 nil: we skipped over an identifier, matched parentheses, ..." 801 nil: we skipped over an identifier, matched parentheses, ..."
800 (smie-next-sexp 802 (smie-next-sexp
@@ -814,7 +816,8 @@ Possible return values:
814 (RIGHT-LEVEL POS TOKEN): we couldn't skip TOKEN because its left-level 816 (RIGHT-LEVEL POS TOKEN): we couldn't skip TOKEN because its left-level
815 is too high. RIGHT-LEVEL is the right-level of TOKEN, 817 is too high. RIGHT-LEVEL is the right-level of TOKEN,
816 POS is its end position in the buffer. 818 POS is its end position in the buffer.
817 (t POS TOKEN): same thing but for an open-paren or the beginning of buffer. 819 (t POS TOKEN): same thing but for a close-paren or the end of buffer.
820 Instead of t, the `car' can also be some other non-nil non-number value.
818 (nil POS TOKEN): we skipped over a paren-like pair. 821 (nil POS TOKEN): we skipped over a paren-like pair.
819 nil: we skipped over an identifier, matched parentheses, ..." 822 nil: we skipped over an identifier, matched parentheses, ..."
820 (smie-next-sexp 823 (smie-next-sexp
@@ -1076,6 +1079,16 @@ the beginning of a line."
1076 "Return non-nil if the current token is the first on the line." 1079 "Return non-nil if the current token is the first on the line."
1077 (save-excursion (skip-chars-backward " \t") (bolp))) 1080 (save-excursion (skip-chars-backward " \t") (bolp)))
1078 1081
1082(defun smie-indent--bolp-1 ()
1083 ;; Like smie-indent--bolp but also returns non-nil if it's the first
1084 ;; non-comment token. Maybe we should simply always use this?
1085 "Return non-nil if the current token is the first on the line.
1086Comments are treated as spaces."
1087 (let ((bol (line-beginning-position)))
1088 (save-excursion
1089 (forward-comment (- (point)))
1090 (<= (point) bol))))
1091
1079;; Dynamically scoped. 1092;; Dynamically scoped.
1080(defvar smie--parent) (defvar smie--after) (defvar smie--token) 1093(defvar smie--parent) (defvar smie--after) (defvar smie--token)
1081 1094
@@ -1352,9 +1365,12 @@ should not be computed on the basis of the following token."
1352 ;; - middle-of-line: "trust current position". 1365 ;; - middle-of-line: "trust current position".
1353 (cond 1366 (cond
1354 ((smie-indent--rule :before token)) 1367 ((smie-indent--rule :before token))
1355 ((smie-indent--bolp) ;I.e. non-virtual indent. 1368 ((smie-indent--bolp-1) ;I.e. non-virtual indent.
1356 ;; For an open-paren-like thingy at BOL, always indent only 1369 ;; For an open-paren-like thingy at BOL, always indent only
1357 ;; based on other rules (typically smie-indent-after-keyword). 1370 ;; based on other rules (typically smie-indent-after-keyword).
1371 ;; FIXME: we do the same if after a comment, since we may be trying
1372 ;; to compute the indentation of this comment and we shouldn't indent
1373 ;; based on the indentation of subsequent code.
1358 nil) 1374 nil)
1359 (t 1375 (t
1360 ;; By default use point unless we're hanging. 1376 ;; By default use point unless we're hanging.
@@ -1455,6 +1471,12 @@ should not be computed on the basis of the following token."
1455 (save-excursion 1471 (save-excursion
1456 (forward-comment (point-max)) 1472 (forward-comment (point-max))
1457 (skip-chars-forward " \t\r\n") 1473 (skip-chars-forward " \t\r\n")
1474 ;; FIXME: We assume here that smie-indent-calculate will compute the
1475 ;; indentation of the next token based on text before the comment, but
1476 ;; this is not guaranteed, so maybe we should let
1477 ;; smie-indent-calculate return some info about which buffer position
1478 ;; was used as the "indentation base" and check that this base is
1479 ;; before `pos'.
1458 (smie-indent-calculate)))) 1480 (smie-indent-calculate))))
1459 1481
1460(defun smie-indent-comment-continue () 1482(defun smie-indent-comment-continue ()