From 73e014407f6a464284ac76c44a6985ea64a089e1 Mon Sep 17 00:00:00 2001 From: knu Date: Fri, 11 Oct 2013 10:31:03 +0000 Subject: 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 --- misc/ruby-electric.el | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'misc/ruby-electric.el') diff --git a/misc/ruby-electric.el b/misc/ruby-electric.el index 419d83afd7..669eaee2ea 100644 --- a/misc/ruby-electric.el +++ b/misc/ruby-electric.el @@ -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))) -- cgit v1.2.3