mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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:
parent
33ab98f9e6
commit
73e014407f
2 changed files with 29 additions and 14 deletions
14
ChangeLog
14
ChangeLog
|
@ -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>
|
Fri Oct 11 18:12:47 2013 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
* ext/objspace/gc_hook.c: prohibit reentrant.
|
* ext/objspace/gc_hook.c: prohibit reentrant.
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
;; URL: https://github.com/knu/ruby-electric.el
|
;; URL: https://github.com/knu/ruby-electric.el
|
||||||
;; Keywords: languages ruby
|
;; Keywords: languages ruby
|
||||||
;; License: The same license terms as Ruby
|
;; License: The same license terms as Ruby
|
||||||
;; Version: 2.0
|
;; Version: 2.0.1
|
||||||
|
|
||||||
;;; Commentary:
|
;;; Commentary:
|
||||||
;;
|
;;
|
||||||
|
@ -79,15 +79,16 @@
|
||||||
(defun ruby-electric--modifier-keyword-at-point-p ()
|
(defun ruby-electric--modifier-keyword-at-point-p ()
|
||||||
"Test if there is a modifier keyword at point."
|
"Test if there is a modifier keyword at point."
|
||||||
(and (looking-at ruby-modifier-beg-symbol-re)
|
(and (looking-at ruby-modifier-beg-symbol-re)
|
||||||
|
(let ((end (match-end 1)))
|
||||||
(not (looking-back "\\."))
|
(not (looking-back "\\."))
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(let ((indent1 (ruby-electric--try-insert-and-do "\n"
|
(let ((indent1 (ruby-electric--try-insert-and-do "\n"
|
||||||
(ruby-calculate-indent)))
|
(ruby-calculate-indent)))
|
||||||
(indent2 (save-excursion
|
(indent2 (save-excursion
|
||||||
(ruby-forward-sexp 1)
|
(goto-char end)
|
||||||
(ruby-electric--try-insert-and-do " x\n"
|
(ruby-electric--try-insert-and-do " x\n"
|
||||||
(ruby-calculate-indent)))))
|
(ruby-calculate-indent)))))
|
||||||
(= indent1 indent2)))))
|
(= indent1 indent2))))))
|
||||||
|
|
||||||
(defconst ruby-block-mid-symbol-re
|
(defconst ruby-block-mid-symbol-re
|
||||||
(regexp-opt ruby-block-mid-keywords 'symbols))
|
(regexp-opt ruby-block-mid-keywords 'symbols))
|
||||||
|
@ -105,7 +106,7 @@
|
||||||
(and (looking-at ruby-block-beg-symbol-re)
|
(and (looking-at ruby-block-beg-symbol-re)
|
||||||
(if (string= (match-string 1) "do")
|
(if (string= (match-string 1) "do")
|
||||||
(looking-back "\\s-")
|
(looking-back "\\s-")
|
||||||
(not (looking-back "[^.]")))
|
(not (looking-back "\\.")))
|
||||||
;; (not (ruby-electric--modifier-keyword-at-point-p)) ;; implicit assumption
|
;; (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 keywords (cons keyword keywords)))))
|
||||||
(setq ruby-electric-expandable-keyword-re
|
(setq ruby-electric-expandable-keyword-re
|
||||||
(concat (regexp-opt keywords 'symbols)
|
(concat (regexp-opt keywords 'symbols)
|
||||||
"\\s-*$"))))
|
"$"))))
|
||||||
:group 'ruby-electric)
|
:group 'ruby-electric)
|
||||||
|
|
||||||
(defcustom ruby-electric-simple-keywords-re nil
|
(defcustom ruby-electric-simple-keywords-re nil
|
||||||
|
@ -232,7 +233,7 @@ enabled."
|
||||||
(setq sp-delayed-pair nil))
|
(setq sp-delayed-pair nil))
|
||||||
(cond (arg
|
(cond (arg
|
||||||
(insert (make-string (prefix-numeric-value arg) last-command-event)))
|
(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)
|
(let (action)
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(goto-char (match-beginning 0))
|
(goto-char (match-beginning 0))
|
||||||
|
@ -286,7 +287,7 @@ enabled."
|
||||||
(or (memq 'all ruby-electric-expand-delimiters-list)
|
(or (memq 'all ruby-electric-expand-delimiters-list)
|
||||||
(memq char 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)
|
(and (ruby-electric-code-at-point-p)
|
||||||
(looking-back ruby-electric-expandable-keyword-re)))
|
(looking-back ruby-electric-expandable-keyword-re)))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue