aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2013-11-03 17:56:03 -0500
committerStefan Monnier2013-11-03 17:56:03 -0500
commite61845c1db42405938b9dca7dfff73b4ab6aa52a (patch)
tree5dcf9ea81d4015156240064276f4b85715f7bd40
parent295559b0fda938555055d0e7769d823428d99865 (diff)
downloademacs-e61845c1db42405938b9dca7dfff73b4ab6aa52a.tar.gz
emacs-e61845c1db42405938b9dca7dfff73b4ab6aa52a.zip
* lisp/emacs-lisp/smie.el (smie-rule-parent): Always call
smie-indent-virtual rather than only for hanging tokens. (smie--next-indent-change): New helper command. * lisp/progmodes/ruby-mode.el (ruby-smie--rule-parent-skip-assign): Remove. (ruby-smie-rules): Use smie-rule-parent instead.
-rw-r--r--lisp/ChangeLog17
-rw-r--r--lisp/emacs-lisp/smie.el19
-rw-r--r--lisp/progmodes/ruby-mode.el14
3 files changed, 25 insertions, 25 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 7930c7d5eda..4f1b2142a69 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,12 @@
12013-11-03 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * progmodes/ruby-mode.el (ruby-smie--rule-parent-skip-assign): Remove.
4 (ruby-smie-rules): Use smie-rule-parent instead.
5
6 * emacs-lisp/smie.el (smie-rule-parent): Always call
7 smie-indent-virtual rather than only for hanging tokens.
8 (smie--next-indent-change): New helper command.
9
12013-11-03 Glenn Morris <rgm@gnu.org> 102013-11-03 Glenn Morris <rgm@gnu.org>
2 11
3 * Makefile.in (abs_srcdir): Remove. 12 * Makefile.in (abs_srcdir): Remove.
@@ -25,8 +34,8 @@
25 34
262013-11-02 Bozhidar Batsov <bozhidar@batsov.com> 352013-11-02 Bozhidar Batsov <bozhidar@batsov.com>
27 36
28 * emacs-lisp/package.el (package-version-join): Recognize 37 * emacs-lisp/package.el (package-version-join):
29 snapshot versions. 38 Recognize snapshot versions.
30 39
312013-11-02 Bozhidar Batsov <bozhidar@batsov.com> 402013-11-02 Bozhidar Batsov <bozhidar@batsov.com>
32 41
@@ -34,8 +43,8 @@
34 43
352013-11-02 Dmitry Gutov <dgutov@yandex.ru> 442013-11-02 Dmitry Gutov <dgutov@yandex.ru>
36 45
37 * progmodes/ruby-mode.el (ruby-smie--rule-parent-skip-assign): New 46 * progmodes/ruby-mode.el (ruby-smie--rule-parent-skip-assign):
38 function, replacement for `smie-rule-parent' for when we want to 47 New function, replacement for `smie-rule-parent' for when we want to
39 skip over our direct parent if it's an assignment token.. 48 skip over our direct parent if it's an assignment token..
40 (ruby-smie-rules): Use it. 49 (ruby-smie-rules): Use it.
41 50
diff --git a/lisp/emacs-lisp/smie.el b/lisp/emacs-lisp/smie.el
index c4daa7a853f..26a72d7f3a7 100644
--- a/lisp/emacs-lisp/smie.el
+++ b/lisp/emacs-lisp/smie.el
@@ -1236,15 +1236,7 @@ Only meaningful when called from within `smie-rules-function'."
1236 (goto-char (cadr (smie-indent--parent))) 1236 (goto-char (cadr (smie-indent--parent)))
1237 (cons 'column 1237 (cons 'column
1238 (+ (or offset 0) 1238 (+ (or offset 0)
1239 ;; Use smie-indent-virtual when indenting relative to an opener: 1239 (smie-indent-virtual)))))
1240 ;; this will also by default use current-column unless
1241 ;; that opener is hanging, but will additionally consult
1242 ;; rules-function, so it gives it a chance to tweak
1243 ;; indentation (e.g. by forcing indentation relative to
1244 ;; its own parent, as in fn a => fn b => fn c =>).
1245 (if (or (not (numberp (car smie--parent)))
1246 (smie-indent--hanging-p))
1247 (smie-indent-virtual) (current-column))))))
1248 1240
1249(defvar smie-rule-separator-outdent 2) 1241(defvar smie-rule-separator-outdent 2)
1250 1242
@@ -1837,6 +1829,15 @@ KEYWORDS are additional arguments, which can use the following keywords:
1837 (edebug-instrument-function smie-rules-function) 1829 (edebug-instrument-function smie-rules-function)
1838 (error "Sorry, don't know how to instrument a lambda expression"))) 1830 (error "Sorry, don't know how to instrument a lambda expression")))
1839 1831
1832(defun smie--next-indent-change ()
1833 "Go to the next line that needs to be reindented (and reindent it)."
1834 (interactive)
1835 (while
1836 (let ((tick (buffer-modified-tick)))
1837 (indent-according-to-mode)
1838 (eq tick (buffer-modified-tick)))
1839 (forward-line 1)))
1840
1840;;; User configuration 1841;;; User configuration
1841 1842
1842;; This is designed to be a completely independent "module", so we can play 1843;; This is designed to be a completely independent "module", so we can play
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index 36aa8eeae96..75c59ebe1fd 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -467,16 +467,6 @@ explicitly declared in magic comment."
467 (t ";"))) 467 (t ";")))
468 (t tok))))))) 468 (t tok)))))))
469 469
470(defun ruby-smie--rule-parent-skip-assign ()
471 (let* ((parent (smie-indent--parent))
472 (tok (caddr parent)))
473 (if (and (stringp tok) (string-match-p "[+-*&|^]?=\\'" tok))
474 (progn
475 (goto-char (cadr parent))
476 (let (smie--parent)
477 (smie-rule-parent)))
478 (smie-rule-parent))))
479
480(defun ruby-smie-rules (kind token) 470(defun ruby-smie-rules (kind token)
481 (pcase (cons kind token) 471 (pcase (cons kind token)
482 (`(:elem . basic) ruby-indent-level) 472 (`(:elem . basic) ruby-indent-level)
@@ -499,7 +489,7 @@ explicitly declared in magic comment."
499 ((and (equal token "{") 489 ((and (equal token "{")
500 (not (smie-rule-prev-p "(" "{" "[" "," "=>" "=" "return" ";"))) 490 (not (smie-rule-prev-p "(" "{" "[" "," "=>" "=" "return" ";")))
501 ;; Curly block opener. 491 ;; Curly block opener.
502 (ruby-smie--rule-parent-skip-assign)) 492 (smie-rule-parent))
503 ((smie-rule-hanging-p) 493 ((smie-rule-hanging-p)
504 ;; Treat purely syntactic block-constructs as being part of their parent, 494 ;; Treat purely syntactic block-constructs as being part of their parent,
505 ;; when the opening statement is hanging. 495 ;; when the opening statement is hanging.
@@ -508,7 +498,7 @@ explicitly declared in magic comment."
508 (cons 'column (smie-indent-virtual))))) 498 (cons 'column (smie-indent-virtual)))))
509 (`(:after . ,(or "=" "iuwu-mod")) 2) 499 (`(:after . ,(or "=" "iuwu-mod")) 2)
510 (`(:after . " @ ") (smie-rule-parent)) 500 (`(:after . " @ ") (smie-rule-parent))
511 (`(:before . "do") (ruby-smie--rule-parent-skip-assign)) 501 (`(:before . "do") (smie-rule-parent))
512 (`(,(or :before :after) . ".") 502 (`(,(or :before :after) . ".")
513 (unless (smie-rule-parent-p ".") 503 (unless (smie-rule-parent-p ".")
514 (smie-rule-parent ruby-indent-level))) 504 (smie-rule-parent ruby-indent-level)))