mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
c4b4e77c72
commit
e59f453e88
2 changed files with 27 additions and 17 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
||||||
|
Thu Sep 26 21:07:49 2013 Akinori MUSHA <knu@iDaemons.org>
|
||||||
|
|
||||||
|
* 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@sorah.jp>
|
Thu Sep 26 16:51:00 2013 Shota Fukumori <her@sorah.jp>
|
||||||
|
|
||||||
* insns.def (opt_regexpmatch2): Check String#=~ hasn't overridden
|
* insns.def (opt_regexpmatch2): Check String#=~ hasn't overridden
|
||||||
|
|
|
@ -179,22 +179,23 @@ strings. Note that you must have Font Lock enabled."
|
||||||
(beginning-of-line)
|
(beginning-of-line)
|
||||||
(looking-at ruby-electric-single-keyword-in-line-re))))))))
|
(looking-at ruby-electric-single-keyword-in-line-re))))))))
|
||||||
|
|
||||||
(defun ruby-electric-cua-replace-region-p()
|
(defun ruby-electric-cua-replace-region-maybe()
|
||||||
(eq (key-binding "a") 'cua-replace-region))
|
(let ((func (key-binding [remap self-insert-command])))
|
||||||
|
(when (memq func '(cua-replace-region
|
||||||
(defun ruby-electric-cua-replace-region()
|
sp--cua-replace-region))
|
||||||
(setq this-original-command 'self-insert-command)
|
(setq this-original-command 'self-insert-command)
|
||||||
(setq this-command 'cua-replace-region)
|
(funcall (setq this-command func))
|
||||||
(cua-replace-region))
|
t)))
|
||||||
|
|
||||||
(defun ruby-electric-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)
|
(setq this-original-command 'delete-backward-char)
|
||||||
(setq this-command 'cua-delete-region)
|
(funcall (setq this-command func))
|
||||||
(cua-delete-region))
|
t)))
|
||||||
|
|
||||||
(defmacro ruby-electric-insert (arg &rest body)
|
(defmacro ruby-electric-insert (arg &rest body)
|
||||||
`(cond ((ruby-electric-cua-replace-region-p)
|
`(cond ((ruby-electric-cua-replace-region-maybe))
|
||||||
(ruby-electric-cua-replace-region))
|
|
||||||
((and
|
((and
|
||||||
(null ,arg)
|
(null ,arg)
|
||||||
(ruby-electric-is-last-command-char-expandable-punct-p))
|
(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)
|
(defun ruby-electric-closing-char(arg)
|
||||||
(interactive "P")
|
(interactive "P")
|
||||||
(cond
|
(cond
|
||||||
((ruby-electric-cua-replace-region-p)
|
((ruby-electric-cua-replace-region-maybe))
|
||||||
(ruby-electric-cua-replace-region))
|
|
||||||
(arg
|
(arg
|
||||||
(setq this-command 'self-insert-command)
|
(setq this-command 'self-insert-command)
|
||||||
(insert (make-string (prefix-numeric-value arg) last-command-event)))
|
(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)
|
(defun ruby-electric-delete-backward-char(arg)
|
||||||
(interactive "P")
|
(interactive "P")
|
||||||
(if (ruby-electric-cua-replace-region-p)
|
(unless (ruby-electric-cua-delete-region-maybe)
|
||||||
(ruby-electric-cua-delete-region)
|
|
||||||
(cond ((memq last-command '(ruby-electric-matching-char
|
(cond ((memq last-command '(ruby-electric-matching-char
|
||||||
ruby-electric-bar))
|
ruby-electric-bar))
|
||||||
(delete-char 1))
|
(delete-char 1))
|
||||||
|
|
Loading…
Reference in a new issue