зеркало из https://github.com/github/ruby.git
* misc/ruby-electric.el: Import ruby-electric.el 2.1 from
https://github.com/knu/ruby-electric.el. * Hitting the newline-and-indent key within a comment fires comment-indent-new-line. * Introduce a new feature `ruby-electric-autoindent-on-closing-char`. * Fix fallback behavior of ruby-electric-space/return that caused error with auto-complete. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43448 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
6cb24cee64
Коммит
3701549796
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
Mon Oct 28 14:41:27 2013 Akinori MUSHA <knu@iDaemons.org>
|
||||
|
||||
* misc/ruby-electric.el: Import ruby-electric.el 2.1 from
|
||||
https://github.com/knu/ruby-electric.el.
|
||||
|
||||
* Hitting the newline-and-indent key within a comment fires
|
||||
comment-indent-new-line.
|
||||
|
||||
* Introduce a new feature
|
||||
`ruby-electric-autoindent-on-closing-char`.
|
||||
|
||||
* Fix fallback behavior of ruby-electric-space/return that
|
||||
caused error with auto-complete.
|
||||
|
||||
Mon Oct 28 13:17:17 2013 Or Cohen <orc@fewbytes.com>
|
||||
|
||||
* error.c (name_err_to_s): remove no longer needed overriding, since
|
||||
|
|
|
@ -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.1
|
||||
;; Version: 2.1
|
||||
|
||||
;;; Commentary:
|
||||
;;
|
||||
|
@ -185,8 +185,8 @@ instead."
|
|||
"Keymap used in ruby-electric-mode")
|
||||
|
||||
(defcustom ruby-electric-expand-delimiters-list '(all)
|
||||
"*List of contexts where matching delimiter should be
|
||||
inserted. The word 'all' will do all insertions."
|
||||
"*List of contexts where matching delimiter should be inserted.
|
||||
The word 'all' will do all insertions."
|
||||
:type `(set :extra-offset 8
|
||||
(const :tag "Everything" all)
|
||||
,@(apply 'list
|
||||
|
@ -197,8 +197,13 @@ inserted. The word 'all' will do all insertions."
|
|||
:group 'ruby-electric)
|
||||
|
||||
(defcustom ruby-electric-newline-before-closing-bracket nil
|
||||
"*Controls whether a newline should be inserted before the
|
||||
closing bracket or not."
|
||||
"*Non-nil means a newline should be inserted before an
|
||||
automatically inserted closing bracket."
|
||||
:type 'boolean :group 'ruby-electric)
|
||||
|
||||
(defcustom ruby-electric-autoindent-on-closing-char nil
|
||||
"*Non-nil means the current line should be automatically
|
||||
indented when a closing character is manually typed in."
|
||||
:type 'boolean :group 'ruby-electric)
|
||||
|
||||
(defvar ruby-electric-mode-hook nil
|
||||
|
@ -227,6 +232,17 @@ enabled."
|
|||
(if ruby-electric-mode
|
||||
(run-hooks 'ruby-electric-mode-hook)))
|
||||
|
||||
(defun ruby-electric-space/return-fallback ()
|
||||
(if (or (eq this-original-command 'ruby-electric-space/return)
|
||||
(null (ignore-errors
|
||||
;; ac-complete may fail if there is nothing left to complete
|
||||
(call-interactively this-original-command)
|
||||
(setq this-command this-original-command))))
|
||||
;; fall back to a globally bound command
|
||||
(let ((command (global-key-binding (char-to-string last-command-event) t)))
|
||||
(and command
|
||||
(call-interactively (setq this-command command))))))
|
||||
|
||||
(defun ruby-electric-space/return (arg)
|
||||
(interactive "*P")
|
||||
(and (boundp 'sp-last-operation)
|
||||
|
@ -257,13 +273,12 @@ enabled."
|
|||
(ruby-insert-end)))
|
||||
((eq action 'reindent)
|
||||
(ruby-indent-line)))
|
||||
(if (char-equal last-command-event ?\s)
|
||||
(insert " ")
|
||||
(funcall this-original-command))))
|
||||
(ruby-electric-space/return-fallback)))
|
||||
((and (eq this-original-command 'newline-and-indent)
|
||||
(ruby-electric-comment-at-point-p))
|
||||
(call-interactively (setq this-command 'comment-indent-new-line)))
|
||||
(t
|
||||
(if (char-equal last-command-event ?\s)
|
||||
(insert " ")
|
||||
(funcall (setq this-command this-original-command))))))
|
||||
(ruby-electric-space/return-fallback))))
|
||||
|
||||
(defun ruby-electric-code-at-point-p()
|
||||
(and ruby-electric-mode
|
||||
|
@ -275,6 +290,10 @@ enabled."
|
|||
(and ruby-electric-mode
|
||||
(consp (memq 'font-lock-string-face (text-properties-at (point))))))
|
||||
|
||||
(defun ruby-electric-comment-at-point-p()
|
||||
(and ruby-electric-mode
|
||||
(consp (memq 'font-lock-comment-face (text-properties-at (point))))))
|
||||
|
||||
(defun ruby-electric-escaped-p()
|
||||
(let ((f nil))
|
||||
(save-excursion
|
||||
|
@ -413,7 +432,9 @@ enabled."
|
|||
(forward-char))
|
||||
(t
|
||||
(setq this-command 'self-insert-command)
|
||||
(self-insert-command 1))))
|
||||
(self-insert-command 1)
|
||||
(if ruby-electric-autoindent-on-closing-char
|
||||
(ruby-indent-line)))))
|
||||
|
||||
(defun ruby-electric-bar(arg)
|
||||
(interactive "*P")
|
||||
|
|
Загрузка…
Ссылка в новой задаче