* 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.
This commit is contained in:
parent
295559b0fd
commit
e61845c1db
3 changed files with 25 additions and 25 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2013-11-03 Stefan Monnier <monnier@iro.umontreal.ca>
|
||||||
|
|
||||||
|
* progmodes/ruby-mode.el (ruby-smie--rule-parent-skip-assign): Remove.
|
||||||
|
(ruby-smie-rules): Use smie-rule-parent instead.
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
2013-11-03 Glenn Morris <rgm@gnu.org>
|
2013-11-03 Glenn Morris <rgm@gnu.org>
|
||||||
|
|
||||||
* Makefile.in (abs_srcdir): Remove.
|
* Makefile.in (abs_srcdir): Remove.
|
||||||
|
@ -25,8 +34,8 @@
|
||||||
|
|
||||||
2013-11-02 Bozhidar Batsov <bozhidar@batsov.com>
|
2013-11-02 Bozhidar Batsov <bozhidar@batsov.com>
|
||||||
|
|
||||||
* emacs-lisp/package.el (package-version-join): Recognize
|
* emacs-lisp/package.el (package-version-join):
|
||||||
snapshot versions.
|
Recognize snapshot versions.
|
||||||
|
|
||||||
2013-11-02 Bozhidar Batsov <bozhidar@batsov.com>
|
2013-11-02 Bozhidar Batsov <bozhidar@batsov.com>
|
||||||
|
|
||||||
|
@ -34,8 +43,8 @@
|
||||||
|
|
||||||
2013-11-02 Dmitry Gutov <dgutov@yandex.ru>
|
2013-11-02 Dmitry Gutov <dgutov@yandex.ru>
|
||||||
|
|
||||||
* progmodes/ruby-mode.el (ruby-smie--rule-parent-skip-assign): New
|
* progmodes/ruby-mode.el (ruby-smie--rule-parent-skip-assign):
|
||||||
function, replacement for `smie-rule-parent' for when we want to
|
New function, replacement for `smie-rule-parent' for when we want to
|
||||||
skip over our direct parent if it's an assignment token..
|
skip over our direct parent if it's an assignment token..
|
||||||
(ruby-smie-rules): Use it.
|
(ruby-smie-rules): Use it.
|
||||||
|
|
||||||
|
|
|
@ -1236,15 +1236,7 @@ Only meaningful when called from within `smie-rules-function'."
|
||||||
(goto-char (cadr (smie-indent--parent)))
|
(goto-char (cadr (smie-indent--parent)))
|
||||||
(cons 'column
|
(cons 'column
|
||||||
(+ (or offset 0)
|
(+ (or offset 0)
|
||||||
;; Use smie-indent-virtual when indenting relative to an opener:
|
(smie-indent-virtual)))))
|
||||||
;; this will also by default use current-column unless
|
|
||||||
;; that opener is hanging, but will additionally consult
|
|
||||||
;; rules-function, so it gives it a chance to tweak
|
|
||||||
;; indentation (e.g. by forcing indentation relative to
|
|
||||||
;; its own parent, as in fn a => fn b => fn c =>).
|
|
||||||
(if (or (not (numberp (car smie--parent)))
|
|
||||||
(smie-indent--hanging-p))
|
|
||||||
(smie-indent-virtual) (current-column))))))
|
|
||||||
|
|
||||||
(defvar smie-rule-separator-outdent 2)
|
(defvar smie-rule-separator-outdent 2)
|
||||||
|
|
||||||
|
@ -1837,6 +1829,15 @@ KEYWORDS are additional arguments, which can use the following keywords:
|
||||||
(edebug-instrument-function smie-rules-function)
|
(edebug-instrument-function smie-rules-function)
|
||||||
(error "Sorry, don't know how to instrument a lambda expression")))
|
(error "Sorry, don't know how to instrument a lambda expression")))
|
||||||
|
|
||||||
|
(defun smie--next-indent-change ()
|
||||||
|
"Go to the next line that needs to be reindented (and reindent it)."
|
||||||
|
(interactive)
|
||||||
|
(while
|
||||||
|
(let ((tick (buffer-modified-tick)))
|
||||||
|
(indent-according-to-mode)
|
||||||
|
(eq tick (buffer-modified-tick)))
|
||||||
|
(forward-line 1)))
|
||||||
|
|
||||||
;;; User configuration
|
;;; User configuration
|
||||||
|
|
||||||
;; This is designed to be a completely independent "module", so we can play
|
;; This is designed to be a completely independent "module", so we can play
|
||||||
|
|
|
@ -467,16 +467,6 @@ explicitly declared in magic comment."
|
||||||
(t ";")))
|
(t ";")))
|
||||||
(t tok)))))))
|
(t tok)))))))
|
||||||
|
|
||||||
(defun ruby-smie--rule-parent-skip-assign ()
|
|
||||||
(let* ((parent (smie-indent--parent))
|
|
||||||
(tok (caddr parent)))
|
|
||||||
(if (and (stringp tok) (string-match-p "[+-*&|^]?=\\'" tok))
|
|
||||||
(progn
|
|
||||||
(goto-char (cadr parent))
|
|
||||||
(let (smie--parent)
|
|
||||||
(smie-rule-parent)))
|
|
||||||
(smie-rule-parent))))
|
|
||||||
|
|
||||||
(defun ruby-smie-rules (kind token)
|
(defun ruby-smie-rules (kind token)
|
||||||
(pcase (cons kind token)
|
(pcase (cons kind token)
|
||||||
(`(:elem . basic) ruby-indent-level)
|
(`(:elem . basic) ruby-indent-level)
|
||||||
|
@ -499,7 +489,7 @@ explicitly declared in magic comment."
|
||||||
((and (equal token "{")
|
((and (equal token "{")
|
||||||
(not (smie-rule-prev-p "(" "{" "[" "," "=>" "=" "return" ";")))
|
(not (smie-rule-prev-p "(" "{" "[" "," "=>" "=" "return" ";")))
|
||||||
;; Curly block opener.
|
;; Curly block opener.
|
||||||
(ruby-smie--rule-parent-skip-assign))
|
(smie-rule-parent))
|
||||||
((smie-rule-hanging-p)
|
((smie-rule-hanging-p)
|
||||||
;; Treat purely syntactic block-constructs as being part of their parent,
|
;; Treat purely syntactic block-constructs as being part of their parent,
|
||||||
;; when the opening statement is hanging.
|
;; when the opening statement is hanging.
|
||||||
|
@ -508,7 +498,7 @@ explicitly declared in magic comment."
|
||||||
(cons 'column (smie-indent-virtual)))))
|
(cons 'column (smie-indent-virtual)))))
|
||||||
(`(:after . ,(or "=" "iuwu-mod")) 2)
|
(`(:after . ,(or "=" "iuwu-mod")) 2)
|
||||||
(`(:after . " @ ") (smie-rule-parent))
|
(`(:after . " @ ") (smie-rule-parent))
|
||||||
(`(:before . "do") (ruby-smie--rule-parent-skip-assign))
|
(`(:before . "do") (smie-rule-parent))
|
||||||
(`(,(or :before :after) . ".")
|
(`(,(or :before :after) . ".")
|
||||||
(unless (smie-rule-parent-p ".")
|
(unless (smie-rule-parent-p ".")
|
||||||
(smie-rule-parent ruby-indent-level)))
|
(smie-rule-parent ruby-indent-level)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue