* misc/ruby-electric.el (ruby-electric-delete-backward-char):

Introduce electric DEL that deletes what the previous electric
  command has input.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40817 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
knu 2013-05-18 17:38:04 +00:00
Родитель 30034b5536
Коммит 616084fd97
2 изменённых файлов: 35 добавлений и 2 удалений

Просмотреть файл

@ -1,4 +1,8 @@
Sun May 19 02:27:21 2013 Akinori MUSHA <knu@iDaemons.org>
Sun May 19 02:30:00 2013 Akinori MUSHA <knu@iDaemons.org>
* misc/ruby-electric.el (ruby-electric-delete-backward-char):
Introduce electric DEL that deletes what the previous electric
command has input.
* misc/ruby-electric.el (ruby-electric-matching-char): Make
electric quotes work again at the end of buffer.

Просмотреть файл

@ -124,7 +124,8 @@ strings. Note that you must have Font Lock enabled."
(define-key ruby-mode-map ")" 'ruby-electric-closing-char)
(define-key ruby-mode-map "]" 'ruby-electric-closing-char)
(define-key ruby-mode-map "|" 'ruby-electric-bar)
(define-key ruby-mode-map "#" 'ruby-electric-hash))
(define-key ruby-mode-map "#" 'ruby-electric-hash)
(define-key ruby-mode-map (kbd "DEL") 'ruby-electric-delete-backward-char))
(defun ruby-electric-space (arg)
(interactive "P")
@ -184,6 +185,11 @@ strings. Note that you must have Font Lock enabled."
(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))
(defmacro ruby-electric-insert (arg &rest body)
`(cond ((ruby-electric-cua-replace-region-p)
(ruby-electric-cua-replace-region))
@ -312,5 +318,28 @@ strings. Note that you must have Font Lock enabled."
(save-excursion
(insert "|")))))
(defun ruby-electric-delete-backward-char(arg)
(interactive "P")
(if (ruby-electric-cua-replace-region-p)
(ruby-electric-cua-delete-region)
(cond ((memq last-command '(ruby-electric-matching-char
ruby-electric-bar))
(delete-char 1))
((eq last-command 'ruby-electric-curlies)
(cond ((eolp)
(cond ((char-equal (preceding-char) ?\s)
(setq this-command last-command))
((char-equal (preceding-char) ?{)
(and (looking-at "[ \t\n]*}")
(delete-char (- (match-end 0) (match-beginning 0)))))))
((char-equal (following-char) ?\s)
(setq this-command last-command)
(delete-char 1))
((char-equal (following-char) ?})
(delete-char 1))))
((eq last-command 'ruby-electric-hash)
(and (char-equal (preceding-char) ?{)
(delete-char 1))))
(delete-backward-char 1)))
(provide 'ruby-electric)