[前][次][番号順一覧][スレッド一覧]

ruby-changes:30974

From: knu <ko1@a...>
Date: Thu, 26 Sep 2013 21:16:28 +0900 (JST)
Subject: [ruby-changes:30974] knu:r43053 (trunk): * misc/ruby-electric.el (ruby-electric-delete-backward-char): Add

knu	2013-09-26 21:16:22 +0900 (Thu, 26 Sep 2013)

  New Revision: 43053

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43053

  Log:
    * misc/ruby-electric.el (ruby-electric-delete-backward-char): Add
      support for smartparen-mode.
    
    * misc/ruby-electric.el (ruby-electric-cua-replace-region-maybe)
      (ruby-electric-cua-delete-region-maybe): New functions that
      combine `ruby-electric-cua-*-region` with
      `ruby-electric-cua-*-region-p`, using a slightly better way to
      detect if it is in cua-mode.

  Modified files:
    trunk/ChangeLog
    trunk/misc/ruby-electric.el
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 43052)
+++ ChangeLog	(revision 43053)
@@ -1,3 +1,14 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Sep 26 21:07:49 2013  Akinori MUSHA  <knu@i...>
+
+	* misc/ruby-electric.el (ruby-electric-delete-backward-char): Add
+	  support for smartparen-mode.
+
+	* misc/ruby-electric.el (ruby-electric-cua-replace-region-maybe)
+	  (ruby-electric-cua-delete-region-maybe): New functions that
+	  combine `ruby-electric-cua-*-region` with
+	  `ruby-electric-cua-*-region-p`, using a slightly better way to
+	  detect if it is in cua-mode.
+
 Thu Sep 26 16:51:00 2013  Shota Fukumori  <her@s...>
 
 	* insns.def (opt_regexpmatch2): Check String#=~ hasn't overridden
Index: misc/ruby-electric.el
===================================================================
--- misc/ruby-electric.el	(revision 43052)
+++ misc/ruby-electric.el	(revision 43053)
@@ -179,22 +179,23 @@ strings. Note that you must have Font Lo https://github.com/ruby/ruby/blob/trunk/misc/ruby-electric.el#L179
                      (beginning-of-line)
                      (looking-at ruby-electric-single-keyword-in-line-re))))))))
 
-(defun ruby-electric-cua-replace-region-p()
-  (eq (key-binding "a") 'cua-replace-region))
-
-(defun ruby-electric-cua-replace-region()
-  (setq this-original-command 'self-insert-command)
-  (setq this-command 'cua-replace-region)
-  (cua-replace-region))
-
-(defun ruby-electric-cua-delete-region()
-  (setq this-original-command 'delete-backward-char)
-  (setq this-command 'cua-delete-region)
-  (cua-delete-region))
+(defun ruby-electric-cua-replace-region-maybe()
+  (let ((func (key-binding [remap self-insert-command])))
+    (when (memq func '(cua-replace-region
+                       sp--cua-replace-region))
+      (setq this-original-command 'self-insert-command)
+      (funcall (setq this-command func))
+      t)))
+
+(defun ruby-electric-cua-delete-region-maybe()
+  (let ((func (key-binding [remap delete-backward-char])))
+    (when (eq func 'cua-delete-region)
+      (setq this-original-command 'delete-backward-char)
+      (funcall (setq this-command func))
+      t)))
 
 (defmacro ruby-electric-insert (arg &rest body)
-  `(cond ((ruby-electric-cua-replace-region-p)
-          (ruby-electric-cua-replace-region))
+  `(cond ((ruby-electric-cua-replace-region-maybe))
          ((and
            (null ,arg)
            (ruby-electric-is-last-command-char-expandable-punct-p))
@@ -290,8 +291,7 @@ strings. Note that you must have Font Lo https://github.com/ruby/ruby/blob/trunk/misc/ruby-electric.el#L291
 (defun ruby-electric-closing-char(arg)
   (interactive "P")
   (cond
-   ((ruby-electric-cua-replace-region-p)
-    (ruby-electric-cua-replace-region))
+   ((ruby-electric-cua-replace-region-maybe))
    (arg
     (setq this-command 'self-insert-command)
     (insert (make-string (prefix-numeric-value arg) last-command-event)))
@@ -322,8 +322,7 @@ strings. Note that you must have Font Lo https://github.com/ruby/ruby/blob/trunk/misc/ruby-electric.el#L322
 
 (defun ruby-electric-delete-backward-char(arg)
   (interactive "P")
-  (if (ruby-electric-cua-replace-region-p)
-      (ruby-electric-cua-delete-region)
+  (unless (ruby-electric-cua-delete-region-maybe)
     (cond ((memq last-command '(ruby-electric-matching-char
                                 ruby-electric-bar))
            (delete-char 1))

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]