From 98fded61f83f75b0c64806ef1c27a1c200868a47 Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 3 Sep 2012 09:31:37 +0000 Subject: [PATCH] ruby-additional.el * misc/ruby-additional.el: missing functions in Emacs 24. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36888 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- misc/ruby-additional.el | 59 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 misc/ruby-additional.el diff --git a/misc/ruby-additional.el b/misc/ruby-additional.el new file mode 100644 index 0000000000..aabf0a6888 --- /dev/null +++ b/misc/ruby-additional.el @@ -0,0 +1,59 @@ +;; missing functions in Emacs 24. + +(eval-after-load "\\(\\`\\|/\\)ruby-mode\\.elc?\\(\\.gz\\)?\\'" + (progn + (define-key ruby-mode-map "\C-c\C-e" 'ruby-insert-end) + (define-key ruby-mode-map "\C-c{" 'ruby-toggle-block) + + (defun ruby-insert-end () + (interactive) + (if (eq (char-syntax (char-before)) ?w) + (insert " ")) + (insert "end") + (save-excursion + (if (eq (char-syntax (char-after)) ?w) + (insert " ")) + (ruby-indent-line t) + (end-of-line))) + + (defun ruby-brace-to-do-end () + (when (looking-at "{") + (let ((orig (point)) (end (progn (ruby-forward-sexp) (point)))) + (when (eq (char-before) ?\}) + (delete-char -1) + (if (eq (char-syntax (char-before)) ?w) + (insert " ")) + (insert "end") + (if (eq (char-syntax (char-after)) ?w) + (insert " ")) + (goto-char orig) + (delete-char 1) + (if (eq (char-syntax (char-before)) ?w) + (insert " ")) + (insert "do") + (when (looking-at "\\sw\\||") + (insert " ") + (backward-char)) + t)))) + + (defun ruby-do-end-to-brace () + (when (and (or (bolp) + (not (memq (char-syntax (char-before)) '(?w ?_)))) + (looking-at "\\