ruby_learner 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +58 -0
- data/LICENSE.txt +21 -0
- data/README.md +65 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/new_terminal +25 -0
- data/bin/setup +8 -0
- data/docs/happy_ruby/RussOlsen_EloquentRuby_c1.pdf +0 -0
- data/docs/happy_ruby/RussOlsen_EloquentRuby_c5.pdf +0 -0
- data/docs/happy_ruby/TanoshiiRuby_v3_c23.pdf +0 -0
- data/docs/happy_ruby/TanoshiiRuby_v5_c1.pdf +0 -0
- data/docs/happy_ruby/TanoshiiRuby_v5_c2-3.pdf +0 -0
- data/docs/happy_ruby/c2.ipynb +479 -0
- data/docs/happy_ruby/c3_4.ipynb +237 -0
- data/docs/seminar/8-1.org +18 -0
- data/exe/ruby_learner +5 -0
- data/lib/ruby_learner/h.rb +14 -0
- data/lib/ruby_learner/methods.rb +131 -0
- data/lib/ruby_learner/random_h.rb +16 -0
- data/lib/ruby_learner/ruby_learner.rb +43 -0
- data/lib/ruby_learner/sequential_h.rb +15 -0
- data/lib/ruby_learner/typing_practice.rb +21 -0
- data/lib/ruby_learner/version.rb +3 -0
- data/questions/random_check/.rspec +1 -0
- data/questions/random_check/random_h.rb +16 -0
- data/questions/random_check/section_1/.rspec +1 -0
- data/questions/random_check/section_1/lib/answer.rb +15 -0
- data/questions/random_check/section_1/lib/sentence.org +9 -0
- data/questions/random_check/section_1/lib/workplace.rb +5 -0
- data/questions/random_check/section_1/spec/spec_helper.rb +100 -0
- data/questions/random_check/section_1/spec/workplace_spec.rb +10 -0
- data/questions/random_check/section_2/.rspec +1 -0
- data/questions/random_check/section_2/lib/answer.rb +17 -0
- data/questions/random_check/section_2/lib/sentence.org +12 -0
- data/questions/random_check/section_2/lib/workplace.rb +5 -0
- data/questions/random_check/section_2/spec/.rspec +1 -0
- data/questions/random_check/section_2/spec/spec_helper.rb +100 -0
- data/questions/random_check/section_2/spec/workplace_spec.rb +11 -0
- data/questions/sequential_check/section_1/part_1/lib/answer.rb +9 -0
- data/questions/sequential_check/section_1/part_1/lib/sentence.org +9 -0
- data/questions/sequential_check/section_1/part_1/lib/workplace.rb +5 -0
- data/questions/sequential_check/section_1/part_1/spec/spec_helper.rb +100 -0
- data/questions/sequential_check/section_1/part_1/spec/workplace_spec.rb +10 -0
- data/questions/sequential_check/section_1/part_2/lib/answer.rb +16 -0
- data/questions/sequential_check/section_1/part_2/lib/sentence.org +12 -0
- data/questions/sequential_check/section_1/part_2/lib/workplace.rb +5 -0
- data/questions/sequential_check/section_1/part_2/spec/.rspec +1 -0
- data/questions/sequential_check/section_1/part_2/spec/spec_helper.rb +100 -0
- data/questions/sequential_check/section_1/part_2/spec/workplace_spec.rb +11 -0
- data/ruby_learner.gemspec +41 -0
- data/takahashi/docs/README.org +139 -0
- data/takahashi/docs/drill.html +875 -0
- data/takahashi/docs/drill.html~ +877 -0
- data/takahashi/docs/drill.org +446 -0
- data/takahashi/docs/ruby_for_beginner.html +2642 -0
- data/takahashi/docs/ruby_for_beginner.org +1430 -0
- data/takahashi/sample_prog/answer/10_1.rb +5 -0
- data/takahashi/sample_prog/answer/11_1.rb +5 -0
- data/takahashi/sample_prog/answer/11_2.rb +4 -0
- data/takahashi/sample_prog/answer/1_1.rb +1 -0
- data/takahashi/sample_prog/answer/1_2.rb +1 -0
- data/takahashi/sample_prog/answer/1_3.rb +1 -0
- data/takahashi/sample_prog/answer/2_1.rb +5 -0
- data/takahashi/sample_prog/answer/2_2.rb +12 -0
- data/takahashi/sample_prog/answer/3_1.rb +10 -0
- data/takahashi/sample_prog/answer/4_1.rb +7 -0
- data/takahashi/sample_prog/answer/5_1.rb +6 -0
- data/takahashi/sample_prog/answer/5_2.rb +3 -0
- data/takahashi/sample_prog/answer/6_1.rb +3 -0
- data/takahashi/sample_prog/answer/6_2.rb +5 -0
- data/takahashi/sample_prog/answer/6_3.rb +5 -0
- data/takahashi/sample_prog/answer/6_4.rb +7 -0
- data/takahashi/sample_prog/answer/7_1.rb +3 -0
- data/takahashi/sample_prog/answer/7_2.rb +8 -0
- data/takahashi/sample_prog/answer/9_1.rb +3 -0
- data/takahashi/sample_prog/answer/9_2.rb +5 -0
- data/takahashi/sample_prog/answer/9_3.rb +10 -0
- data/takahashi/sample_prog/answer/hello.rb +3 -0
- data/workshop/.rspec +1 -0
- data/workshop/emacs.d/ac-comphist.dat +50 -0
- data/workshop/emacs.d/cp5022x.el +156 -0
- data/workshop/emacs.d/elpa/archives/gnu/archive-contents +1240 -0
- data/workshop/emacs.d/elpa/archives/melpa/archive-contents +2 -0
- data/workshop/emacs.d/elpa/auto-complete-20170124.1845/auto-complete-autoloads.el +65 -0
- data/workshop/emacs.d/elpa/auto-complete-20170124.1845/auto-complete-config.el +551 -0
- data/workshop/emacs.d/elpa/auto-complete-20170124.1845/auto-complete-config.elc +0 -0
- data/workshop/emacs.d/elpa/auto-complete-20170124.1845/auto-complete-pkg.el +6 -0
- data/workshop/emacs.d/elpa/auto-complete-20170124.1845/auto-complete.el +2164 -0
- data/workshop/emacs.d/elpa/auto-complete-20170124.1845/auto-complete.elc +0 -0
- data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/ada-mode +72 -0
- data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/c++-mode +99 -0
- data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/c-mode +55 -0
- data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/caml-mode +231 -0
- data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/clojure-mode +580 -0
- data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/clojurescript-mode +475 -0
- data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/coq-mode +278 -0
- data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/css-mode +874 -0
- data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/erlang-mode +216 -0
- data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/ess-julia-mode +37 -0
- data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/go-mode +25 -0
- data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/haskell-mode +679 -0
- data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/java-mode +53 -0
- data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/js-mode +148 -0
- data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/julia-mode +37 -0
- data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/lua-mode +21 -0
- data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/nim-mode +70 -0
- data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/objc-mode +161 -0
- data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/octave-mode +46 -0
- data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/php-mode +6144 -0
- data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/python-mode +379 -0
- data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/qml-mode +183 -0
- data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/ruby-mode +181 -0
- data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/scala-mode +1347 -0
- data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/scheme-mode +216 -0
- data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/sclang-mode +1481 -0
- data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/sh-mode +182 -0
- data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/swift-mode +87 -0
- data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/tcl-mode +172 -0
- data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/ts-mode +797 -0
- data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/tuareg-mode +231 -0
- data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/verilog-mode +313 -0
- data/workshop/emacs.d/elpa/better-defaults-20170613.2104/better-defaults-autoloads.el +16 -0
- data/workshop/emacs.d/elpa/better-defaults-20170613.2104/better-defaults-pkg.el +2 -0
- data/workshop/emacs.d/elpa/better-defaults-20170613.2104/better-defaults.el +90 -0
- data/workshop/emacs.d/elpa/better-defaults-20170613.2104/better-defaults.elc +0 -0
- data/workshop/emacs.d/elpa/haml-mode-20170923.2153/haml-mode-autoloads.el +26 -0
- data/workshop/emacs.d/elpa/haml-mode-20170923.2153/haml-mode-pkg.el +2 -0
- data/workshop/emacs.d/elpa/haml-mode-20170923.2153/haml-mode.el +877 -0
- data/workshop/emacs.d/elpa/haml-mode-20170923.2153/haml-mode.elc +0 -0
- data/workshop/emacs.d/elpa/haml-mode-readme.txt +8 -0
- data/workshop/emacs.d/elpa/material-theme-20171123.1040/material-light-theme.el +918 -0
- data/workshop/emacs.d/elpa/material-theme-20171123.1040/material-light-theme.elc +0 -0
- data/workshop/emacs.d/elpa/material-theme-20171123.1040/material-theme-autoloads.el +32 -0
- data/workshop/emacs.d/elpa/material-theme-20171123.1040/material-theme-pkg.el +8 -0
- data/workshop/emacs.d/elpa/material-theme-20171123.1040/material-theme.el +912 -0
- data/workshop/emacs.d/elpa/material-theme-20171123.1040/material-theme.elc +0 -0
- data/workshop/emacs.d/elpa/ox-bibtex-chinese-readme.txt +21 -0
- data/workshop/emacs.d/elpa/popup-20160709.729/popup-autoloads.el +15 -0
- data/workshop/emacs.d/elpa/popup-20160709.729/popup-pkg.el +2 -0
- data/workshop/emacs.d/elpa/popup-20160709.729/popup.el +1432 -0
- data/workshop/emacs.d/elpa/popup-20160709.729/popup.elc +0 -0
- data/workshop/emacs.d/elpa/yaml-mode-20180212.1556/yaml-mode-autoloads.el +33 -0
- data/workshop/emacs.d/elpa/yaml-mode-20180212.1556/yaml-mode-pkg.el +2 -0
- data/workshop/emacs.d/elpa/yaml-mode-20180212.1556/yaml-mode.el +470 -0
- data/workshop/emacs.d/elpa/yaml-mode-20180212.1556/yaml-mode.elc +0 -0
- data/workshop/emacs.d/elpa/yaml-mode-readme.txt +25 -0
- data/workshop/emacs.d/haml-mode-master/.gitignore +1 -0
- data/workshop/emacs.d/haml-mode-master/.mailmap +2 -0
- data/workshop/emacs.d/haml-mode-master/MIT-LICENSE +20 -0
- data/workshop/emacs.d/haml-mode-master/README.md +47 -0
- data/workshop/emacs.d/haml-mode-master/haml-mode.el +887 -0
- data/workshop/emacs.d/iceberg_theme.el +202 -0
- data/workshop/emacs.d/init-open-recentf.el +133 -0
- data/workshop/emacs.d/init.el +229 -0
- data/workshop/emacs.d/inits/line-num.el +264 -0
- data/workshop/emacs.d/install-elisp.el +366 -0
- data/workshop/emacs.d/markdown-mode/markdown-mode.el +5978 -0
- data/workshop/emacs.d/notes +12 -0
- data/workshop/emacs.d/processing-mode/processing-mode.el +275 -0
- data/workshop/emacs.d/recentf +31 -0
- data/workshop/emacs.d/ruby-mode/inf-ruby.el +416 -0
- data/workshop/emacs.d/ruby-mode/rdoc-mode.el +130 -0
- data/workshop/emacs.d/ruby-mode/ruby-electric.el +205 -0
- data/workshop/emacs.d/ruby-mode/ruby-mode.el +1496 -0
- data/workshop/emacs.d/ruby-mode/ruby-style.el +78 -0
- data/workshop/emacs.d/ruby-mode/rubydb2x.el +104 -0
- data/workshop/emacs.d/ruby-mode/rubydb3x.el +115 -0
- data/workshop/emacs.d/ruby_learner_init.el +244 -0
- data/workshop/emacs.d/themes/dracula-theme.el +431 -0
- data/workshop/emacs.d/themes/iceberg-theme.el +205 -0
- data/workshop/emacs.d/themes/my-misterioso-theme.el +109 -0
- data/workshop/emacs.d/themes/my-wombat-theme.el +121 -0
- data/workshop/emacs.d/wiki-mode/wiki.el +976 -0
- data/workshop/emacs_help.org +34 -0
- data/workshop/lib/answer.rb +1 -0
- data/workshop/lib/sentence.org +1 -0
- data/workshop/lib/workplace.rb +1 -0
- data/workshop/restore/empty.rb +0 -0
- data/workshop/spec/spec_helper.rb +100 -0
- data/workshop/spec/workplace_spec.rb +1 -0
- data/workshop/training_data.txt +3 -0
- metadata +343 -0
@@ -0,0 +1,205 @@
|
|
1
|
+
;; -*-Emacs-Lisp-*-
|
2
|
+
;;
|
3
|
+
;; ruby-electric.el --- electric editing commands for ruby files
|
4
|
+
;;
|
5
|
+
;; Copyright (C) 2005 by Dee Zsombor <dee dot zsombor at gmail dot com>.
|
6
|
+
;; Released under same license terms as Ruby.
|
7
|
+
;;
|
8
|
+
;; Due credit: this work was inspired by a code snippet posted by
|
9
|
+
;; Frederick Ros at http://rubygarden.org/ruby?EmacsExtensions.
|
10
|
+
;;
|
11
|
+
;; Following improvements where added:
|
12
|
+
;;
|
13
|
+
;; - handling of strings of type 'here document'
|
14
|
+
;; - more keywords, with special handling for 'do'
|
15
|
+
;; - packaged into a minor mode
|
16
|
+
;;
|
17
|
+
;; Usage:
|
18
|
+
;;
|
19
|
+
;; 0) copy ruby-electric.el into directory where emacs can find it.
|
20
|
+
;;
|
21
|
+
;; 1) modify your startup file (.emacs or whatever) by adding
|
22
|
+
;; following line:
|
23
|
+
;;
|
24
|
+
;; (require 'ruby-electric)
|
25
|
+
;;
|
26
|
+
;; note that you need to have font lock enabled beforehand.
|
27
|
+
;;
|
28
|
+
;; 2) toggle Ruby Electric Mode on/off with ruby-electric-mode.
|
29
|
+
;;
|
30
|
+
;; Changelog:
|
31
|
+
;;
|
32
|
+
;; 2005/Jan/14: inserts matching pair delimiters like {, [, (, ', ",
|
33
|
+
;; ' and | .
|
34
|
+
;;
|
35
|
+
;; 2005/Jan/14: added basic Custom support for configuring keywords
|
36
|
+
;; with electric closing.
|
37
|
+
;;
|
38
|
+
;; 2005/Jan/18: more Custom support for configuring characters for
|
39
|
+
;; which matching expansion should occur.
|
40
|
+
;;
|
41
|
+
;; 2005/Jan/18: no longer uses 'looking-back' or regexp character
|
42
|
+
;; classes like [:space:] since they are not implemented on XEmacs.
|
43
|
+
;;
|
44
|
+
;; 2005/Feb/01: explicitly provide default argument of 1 to
|
45
|
+
;; 'backward-word' as it requires it on Emacs 21.3
|
46
|
+
;;
|
47
|
+
;; 2005/Mar/06: now stored inside ruby CVS; customize pages now have
|
48
|
+
;; ruby as parent; cosmetic fixes.
|
49
|
+
|
50
|
+
|
51
|
+
(require 'ruby-mode)
|
52
|
+
|
53
|
+
(defgroup ruby-electric nil
|
54
|
+
"Minor mode providing electric editing commands for ruby files"
|
55
|
+
:group 'ruby)
|
56
|
+
|
57
|
+
(defconst ruby-electric-expandable-do-re
|
58
|
+
"do\\s-$")
|
59
|
+
|
60
|
+
(defconst ruby-electric-expandable-bar
|
61
|
+
"\\s-\\(do\\|{\\)\\s-+|")
|
62
|
+
|
63
|
+
(defvar ruby-electric-matching-delimeter-alist
|
64
|
+
'((?\[ . ?\])
|
65
|
+
(?\( . ?\))
|
66
|
+
(?\' . ?\')
|
67
|
+
(?\` . ?\`)
|
68
|
+
(?\" . ?\")))
|
69
|
+
|
70
|
+
(defcustom ruby-electric-simple-keywords-re
|
71
|
+
(regexp-opt '("def" "if" "class" "module" "unless" "case" "while" "do" "until" "for" "begin") t)
|
72
|
+
"*Regular expresion matching keywords for which closing 'end'
|
73
|
+
is to be inserted."
|
74
|
+
:type 'regexp :group 'ruby-electric)
|
75
|
+
|
76
|
+
(defcustom ruby-electric-expand-delimiters-list '(all)
|
77
|
+
"*List of contexts where matching delimiter should be
|
78
|
+
inserted. The word 'all' will do all insertions."
|
79
|
+
:type '(set :extra-offset 8
|
80
|
+
(const :tag "Everything" all )
|
81
|
+
(const :tag "Curly brace" ?\{ )
|
82
|
+
(const :tag "Square brace" ?\[ )
|
83
|
+
(const :tag "Round brace" ?\( )
|
84
|
+
(const :tag "Quote" ?\' )
|
85
|
+
(const :tag "Double quote" ?\" )
|
86
|
+
(const :tag "Back quote" ?\` )
|
87
|
+
(const :tag "Vertical bar" ?\| ))
|
88
|
+
:group 'ruby-electric)
|
89
|
+
|
90
|
+
(defcustom ruby-electric-newline-before-closing-bracket nil
|
91
|
+
"*Controls whether a newline should be inserted before the
|
92
|
+
closing bracket or not."
|
93
|
+
:type 'boolean :group 'ruby-electric)
|
94
|
+
|
95
|
+
(define-minor-mode ruby-electric-mode
|
96
|
+
"Toggle Ruby Electric minor mode.
|
97
|
+
With no argument, this command toggles the mode. Non-null prefix
|
98
|
+
argument turns on the mode. Null prefix argument turns off the
|
99
|
+
mode.
|
100
|
+
|
101
|
+
When Ruby Electric mode is enabled, an indented 'end' is
|
102
|
+
heuristicaly inserted whenever typing a word like 'module',
|
103
|
+
'class', 'def', 'if', 'unless', 'case', 'until', 'for', 'begin',
|
104
|
+
'do'. Simple, double and back quotes as well as braces are paired
|
105
|
+
auto-magically. Expansion does not occur inside comments and
|
106
|
+
strings. Note that you must have Font Lock enabled."
|
107
|
+
;; initial value.
|
108
|
+
nil
|
109
|
+
;;indicator for the mode line.
|
110
|
+
" REl"
|
111
|
+
;;keymap
|
112
|
+
ruby-mode-map
|
113
|
+
(ruby-electric-setup-keymap))
|
114
|
+
|
115
|
+
(defun ruby-electric-setup-keymap()
|
116
|
+
(define-key ruby-mode-map " " 'ruby-electric-space)
|
117
|
+
(define-key ruby-mode-map "{" 'ruby-electric-curlies)
|
118
|
+
(define-key ruby-mode-map "(" 'ruby-electric-matching-char)
|
119
|
+
(define-key ruby-mode-map "[" 'ruby-electric-matching-char)
|
120
|
+
(define-key ruby-mode-map "\"" 'ruby-electric-matching-char)
|
121
|
+
(define-key ruby-mode-map "\'" 'ruby-electric-matching-char)
|
122
|
+
(define-key ruby-mode-map "|" 'ruby-electric-bar))
|
123
|
+
|
124
|
+
(defun ruby-electric-space (arg)
|
125
|
+
(interactive "P")
|
126
|
+
(self-insert-command (prefix-numeric-value arg))
|
127
|
+
(if (ruby-electric-space-can-be-expanded-p)
|
128
|
+
(save-excursion
|
129
|
+
(ruby-indent-line t)
|
130
|
+
(newline)
|
131
|
+
(ruby-insert-end))))
|
132
|
+
|
133
|
+
(defun ruby-electric-code-at-point-p()
|
134
|
+
(and ruby-electric-mode
|
135
|
+
(let* ((properties (text-properties-at (point))))
|
136
|
+
(and (null (memq 'font-lock-string-face properties))
|
137
|
+
(null (memq 'font-lock-comment-face properties))))))
|
138
|
+
|
139
|
+
(defun ruby-electric-string-at-point-p()
|
140
|
+
(and ruby-electric-mode
|
141
|
+
(consp (memq 'font-lock-string-face (text-properties-at (point))))))
|
142
|
+
|
143
|
+
(defun ruby-electric-is-last-command-char-expandable-punct-p()
|
144
|
+
(or (memq 'all ruby-electric-expand-delimiters-list)
|
145
|
+
(memq last-command-char ruby-electric-expand-delimiters-list)))
|
146
|
+
|
147
|
+
(defun ruby-electric-space-can-be-expanded-p()
|
148
|
+
(if (ruby-electric-code-at-point-p)
|
149
|
+
(let* ((ruby-electric-keywords-re
|
150
|
+
(concat ruby-electric-simple-keywords-re "\\s-$"))
|
151
|
+
(ruby-electric-single-keyword-in-line-re
|
152
|
+
(concat "\\s-*" ruby-electric-keywords-re)))
|
153
|
+
(save-excursion
|
154
|
+
(backward-word 1)
|
155
|
+
(or (looking-at ruby-electric-expandable-do-re)
|
156
|
+
(and (looking-at ruby-electric-keywords-re)
|
157
|
+
(not (string= "do" (match-string 1)))
|
158
|
+
(progn
|
159
|
+
(beginning-of-line)
|
160
|
+
(looking-at ruby-electric-single-keyword-in-line-re))))))))
|
161
|
+
|
162
|
+
|
163
|
+
(defun ruby-electric-curlies(arg)
|
164
|
+
(interactive "P")
|
165
|
+
(self-insert-command (prefix-numeric-value arg))
|
166
|
+
(if (ruby-electric-is-last-command-char-expandable-punct-p)
|
167
|
+
(cond ((ruby-electric-code-at-point-p)
|
168
|
+
(insert " ")
|
169
|
+
(save-excursion
|
170
|
+
(if ruby-electric-newline-before-closing-bracket
|
171
|
+
(newline))
|
172
|
+
(insert "}")))
|
173
|
+
((ruby-electric-string-at-point-p)
|
174
|
+
(if (eq last-command-event ?{)
|
175
|
+
(save-excursion
|
176
|
+
(when (not (char-equal ?\# (preceding-char)))
|
177
|
+
(delete-backward-char)
|
178
|
+
(insert "#"))))
|
179
|
+
(save-excursion
|
180
|
+
(backward-char 1)
|
181
|
+
(when (char-equal ?\# (preceding-char))
|
182
|
+
(forward-char 1)
|
183
|
+
(insert "}")))))))
|
184
|
+
|
185
|
+
(defun ruby-electric-matching-char(arg)
|
186
|
+
(interactive "P")
|
187
|
+
(self-insert-command (prefix-numeric-value arg))
|
188
|
+
(and (ruby-electric-is-last-command-char-expandable-punct-p)
|
189
|
+
(ruby-electric-code-at-point-p)
|
190
|
+
(save-excursion
|
191
|
+
(insert (cdr (assoc last-command-char
|
192
|
+
ruby-electric-matching-delimeter-alist))))))
|
193
|
+
|
194
|
+
(defun ruby-electric-bar(arg)
|
195
|
+
(interactive "P")
|
196
|
+
(self-insert-command (prefix-numeric-value arg))
|
197
|
+
(and (ruby-electric-is-last-command-char-expandable-punct-p)
|
198
|
+
(ruby-electric-code-at-point-p)
|
199
|
+
(and (save-excursion (re-search-backward ruby-electric-expandable-bar nil t))
|
200
|
+
(= (point) (match-end 0))) ;looking-back is missing on XEmacs
|
201
|
+
(save-excursion
|
202
|
+
(insert "|"))))
|
203
|
+
|
204
|
+
|
205
|
+
(provide 'ruby-electric)
|