summaryrefslogtreecommitdiff
path: root/misc/ruby-electric.el
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-09-26 12:16:22 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-09-26 12:16:22 +0000
commite59f453e880d5a9e400785122f30fc504a622c33 (patch)
tree9333764b1b45c3d9c66736816e21f11fe16b0285 /misc/ruby-electric.el
parentc4b4e77c72b42f0a69c6a825954ec768d1b2375b (diff)
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43053 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'misc/ruby-electric.el')
-rw-r--r--misc/ruby-electric.el33
1 files changed, 16 insertions, 17 deletions
diff --git a/misc/ruby-electric.el b/misc/ruby-electric.el
index 04eb149..b1812bc 100644
--- a/misc/ruby-electric.el
+++ b/misc/ruby-electric.el
@@ -179,22 +179,23 @@ strings. Note that you must have Font Lock enabled."
(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-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-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-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 Lock enabled."
(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 Lock enabled."
(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))