Import ruby-electric.el 2.0.1, a bug fix release.

* misc/ruby-electric.el: Import ruby-electric.el 2.0.1 which fixes
  a bug and a flaw with auto-end introduced in the revamp.

  * ruby-forward-sexp is inappropriate here because it moves the
    cursor past the keyword.

  * Fix a reversed looking-back check in
    ruby-electric--block-beg-keyword-at-point-p.

  * Do not add end again if space or return is hit repeatedly
    after a block beginning keyword.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43254 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
knu 2013-10-11 10:31:03 +00:00
Родитель 33ab98f9e6
Коммит 73e014407f
2 изменённых файлов: 29 добавлений и 14 удалений

Просмотреть файл

@ -1,3 +1,17 @@
Fri Oct 11 19:27:22 2013 Akinori MUSHA <knu@iDaemons.org>
* misc/ruby-electric.el: Import ruby-electric.el 2.0.1 which fixes
a bug and a flaw with auto-end introduced in the revamp.
* ruby-forward-sexp is inappropriate here because it moves the
cursor past the keyword.
* Fix a reversed looking-back check in
ruby-electric--block-beg-keyword-at-point-p.
* Do not add end again if space or return is hit repeatedly
after a block beginning keyword.
Fri Oct 11 18:12:47 2013 Koichi Sasada <ko1@atdot.net>
* ext/objspace/gc_hook.c: prohibit reentrant.

Просмотреть файл

@ -10,7 +10,7 @@
;; URL: https://github.com/knu/ruby-electric.el
;; Keywords: languages ruby
;; License: The same license terms as Ruby
;; Version: 2.0
;; Version: 2.0.1
;;; Commentary:
;;
@ -79,15 +79,16 @@
(defun ruby-electric--modifier-keyword-at-point-p ()
"Test if there is a modifier keyword at point."
(and (looking-at ruby-modifier-beg-symbol-re)
(not (looking-back "\\."))
(save-excursion
(let ((indent1 (ruby-electric--try-insert-and-do "\n"
(ruby-calculate-indent)))
(indent2 (save-excursion
(ruby-forward-sexp 1)
(ruby-electric--try-insert-and-do " x\n"
(ruby-calculate-indent)))))
(= indent1 indent2)))))
(let ((end (match-end 1)))
(not (looking-back "\\."))
(save-excursion
(let ((indent1 (ruby-electric--try-insert-and-do "\n"
(ruby-calculate-indent)))
(indent2 (save-excursion
(goto-char end)
(ruby-electric--try-insert-and-do " x\n"
(ruby-calculate-indent)))))
(= indent1 indent2))))))
(defconst ruby-block-mid-symbol-re
(regexp-opt ruby-block-mid-keywords 'symbols))
@ -105,7 +106,7 @@
(and (looking-at ruby-block-beg-symbol-re)
(if (string= (match-string 1) "do")
(looking-back "\\s-")
(not (looking-back "[^.]")))
(not (looking-back "\\.")))
;; (not (ruby-electric--modifier-keyword-at-point-p)) ;; implicit assumption
))
@ -157,7 +158,7 @@ cons, ACTION can be set to one of the following values:
(setq keywords (cons keyword keywords)))))
(setq ruby-electric-expandable-keyword-re
(concat (regexp-opt keywords 'symbols)
"\\s-*$"))))
"$"))))
:group 'ruby-electric)
(defcustom ruby-electric-simple-keywords-re nil
@ -232,7 +233,7 @@ enabled."
(setq sp-delayed-pair nil))
(cond (arg
(insert (make-string (prefix-numeric-value arg) last-command-event)))
((ruby-electric-space-can-be-expanded-p)
((ruby-electric-space/return-can-be-expanded-p)
(let (action)
(save-excursion
(goto-char (match-beginning 0))
@ -286,7 +287,7 @@ enabled."
(or (memq 'all ruby-electric-expand-delimiters-list)
(memq char ruby-electric-expand-delimiters-list)))
(defun ruby-electric-space-can-be-expanded-p()
(defun ruby-electric-space/return-can-be-expanded-p()
(and (ruby-electric-code-at-point-p)
(looking-back ruby-electric-expandable-keyword-re)))