ruby_learner 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (188) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -0
  3. data/.rspec +3 -0
  4. data/.travis.yml +5 -0
  5. data/CODE_OF_CONDUCT.md +74 -0
  6. data/Gemfile +6 -0
  7. data/Gemfile.lock +58 -0
  8. data/LICENSE.txt +21 -0
  9. data/README.md +65 -0
  10. data/Rakefile +6 -0
  11. data/bin/console +14 -0
  12. data/bin/new_terminal +25 -0
  13. data/bin/setup +8 -0
  14. data/docs/happy_ruby/RussOlsen_EloquentRuby_c1.pdf +0 -0
  15. data/docs/happy_ruby/RussOlsen_EloquentRuby_c5.pdf +0 -0
  16. data/docs/happy_ruby/TanoshiiRuby_v3_c23.pdf +0 -0
  17. data/docs/happy_ruby/TanoshiiRuby_v5_c1.pdf +0 -0
  18. data/docs/happy_ruby/TanoshiiRuby_v5_c2-3.pdf +0 -0
  19. data/docs/happy_ruby/c2.ipynb +479 -0
  20. data/docs/happy_ruby/c3_4.ipynb +237 -0
  21. data/docs/seminar/8-1.org +18 -0
  22. data/exe/ruby_learner +5 -0
  23. data/lib/ruby_learner/h.rb +14 -0
  24. data/lib/ruby_learner/methods.rb +131 -0
  25. data/lib/ruby_learner/random_h.rb +16 -0
  26. data/lib/ruby_learner/ruby_learner.rb +43 -0
  27. data/lib/ruby_learner/sequential_h.rb +15 -0
  28. data/lib/ruby_learner/typing_practice.rb +21 -0
  29. data/lib/ruby_learner/version.rb +3 -0
  30. data/questions/random_check/.rspec +1 -0
  31. data/questions/random_check/random_h.rb +16 -0
  32. data/questions/random_check/section_1/.rspec +1 -0
  33. data/questions/random_check/section_1/lib/answer.rb +15 -0
  34. data/questions/random_check/section_1/lib/sentence.org +9 -0
  35. data/questions/random_check/section_1/lib/workplace.rb +5 -0
  36. data/questions/random_check/section_1/spec/spec_helper.rb +100 -0
  37. data/questions/random_check/section_1/spec/workplace_spec.rb +10 -0
  38. data/questions/random_check/section_2/.rspec +1 -0
  39. data/questions/random_check/section_2/lib/answer.rb +17 -0
  40. data/questions/random_check/section_2/lib/sentence.org +12 -0
  41. data/questions/random_check/section_2/lib/workplace.rb +5 -0
  42. data/questions/random_check/section_2/spec/.rspec +1 -0
  43. data/questions/random_check/section_2/spec/spec_helper.rb +100 -0
  44. data/questions/random_check/section_2/spec/workplace_spec.rb +11 -0
  45. data/questions/sequential_check/section_1/part_1/lib/answer.rb +9 -0
  46. data/questions/sequential_check/section_1/part_1/lib/sentence.org +9 -0
  47. data/questions/sequential_check/section_1/part_1/lib/workplace.rb +5 -0
  48. data/questions/sequential_check/section_1/part_1/spec/spec_helper.rb +100 -0
  49. data/questions/sequential_check/section_1/part_1/spec/workplace_spec.rb +10 -0
  50. data/questions/sequential_check/section_1/part_2/lib/answer.rb +16 -0
  51. data/questions/sequential_check/section_1/part_2/lib/sentence.org +12 -0
  52. data/questions/sequential_check/section_1/part_2/lib/workplace.rb +5 -0
  53. data/questions/sequential_check/section_1/part_2/spec/.rspec +1 -0
  54. data/questions/sequential_check/section_1/part_2/spec/spec_helper.rb +100 -0
  55. data/questions/sequential_check/section_1/part_2/spec/workplace_spec.rb +11 -0
  56. data/ruby_learner.gemspec +41 -0
  57. data/takahashi/docs/README.org +139 -0
  58. data/takahashi/docs/drill.html +875 -0
  59. data/takahashi/docs/drill.html~ +877 -0
  60. data/takahashi/docs/drill.org +446 -0
  61. data/takahashi/docs/ruby_for_beginner.html +2642 -0
  62. data/takahashi/docs/ruby_for_beginner.org +1430 -0
  63. data/takahashi/sample_prog/answer/10_1.rb +5 -0
  64. data/takahashi/sample_prog/answer/11_1.rb +5 -0
  65. data/takahashi/sample_prog/answer/11_2.rb +4 -0
  66. data/takahashi/sample_prog/answer/1_1.rb +1 -0
  67. data/takahashi/sample_prog/answer/1_2.rb +1 -0
  68. data/takahashi/sample_prog/answer/1_3.rb +1 -0
  69. data/takahashi/sample_prog/answer/2_1.rb +5 -0
  70. data/takahashi/sample_prog/answer/2_2.rb +12 -0
  71. data/takahashi/sample_prog/answer/3_1.rb +10 -0
  72. data/takahashi/sample_prog/answer/4_1.rb +7 -0
  73. data/takahashi/sample_prog/answer/5_1.rb +6 -0
  74. data/takahashi/sample_prog/answer/5_2.rb +3 -0
  75. data/takahashi/sample_prog/answer/6_1.rb +3 -0
  76. data/takahashi/sample_prog/answer/6_2.rb +5 -0
  77. data/takahashi/sample_prog/answer/6_3.rb +5 -0
  78. data/takahashi/sample_prog/answer/6_4.rb +7 -0
  79. data/takahashi/sample_prog/answer/7_1.rb +3 -0
  80. data/takahashi/sample_prog/answer/7_2.rb +8 -0
  81. data/takahashi/sample_prog/answer/9_1.rb +3 -0
  82. data/takahashi/sample_prog/answer/9_2.rb +5 -0
  83. data/takahashi/sample_prog/answer/9_3.rb +10 -0
  84. data/takahashi/sample_prog/answer/hello.rb +3 -0
  85. data/workshop/.rspec +1 -0
  86. data/workshop/emacs.d/ac-comphist.dat +50 -0
  87. data/workshop/emacs.d/cp5022x.el +156 -0
  88. data/workshop/emacs.d/elpa/archives/gnu/archive-contents +1240 -0
  89. data/workshop/emacs.d/elpa/archives/melpa/archive-contents +2 -0
  90. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/auto-complete-autoloads.el +65 -0
  91. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/auto-complete-config.el +551 -0
  92. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/auto-complete-config.elc +0 -0
  93. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/auto-complete-pkg.el +6 -0
  94. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/auto-complete.el +2164 -0
  95. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/auto-complete.elc +0 -0
  96. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/ada-mode +72 -0
  97. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/c++-mode +99 -0
  98. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/c-mode +55 -0
  99. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/caml-mode +231 -0
  100. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/clojure-mode +580 -0
  101. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/clojurescript-mode +475 -0
  102. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/coq-mode +278 -0
  103. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/css-mode +874 -0
  104. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/erlang-mode +216 -0
  105. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/ess-julia-mode +37 -0
  106. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/go-mode +25 -0
  107. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/haskell-mode +679 -0
  108. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/java-mode +53 -0
  109. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/js-mode +148 -0
  110. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/julia-mode +37 -0
  111. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/lua-mode +21 -0
  112. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/nim-mode +70 -0
  113. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/objc-mode +161 -0
  114. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/octave-mode +46 -0
  115. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/php-mode +6144 -0
  116. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/python-mode +379 -0
  117. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/qml-mode +183 -0
  118. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/ruby-mode +181 -0
  119. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/scala-mode +1347 -0
  120. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/scheme-mode +216 -0
  121. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/sclang-mode +1481 -0
  122. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/sh-mode +182 -0
  123. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/swift-mode +87 -0
  124. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/tcl-mode +172 -0
  125. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/ts-mode +797 -0
  126. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/tuareg-mode +231 -0
  127. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/verilog-mode +313 -0
  128. data/workshop/emacs.d/elpa/better-defaults-20170613.2104/better-defaults-autoloads.el +16 -0
  129. data/workshop/emacs.d/elpa/better-defaults-20170613.2104/better-defaults-pkg.el +2 -0
  130. data/workshop/emacs.d/elpa/better-defaults-20170613.2104/better-defaults.el +90 -0
  131. data/workshop/emacs.d/elpa/better-defaults-20170613.2104/better-defaults.elc +0 -0
  132. data/workshop/emacs.d/elpa/haml-mode-20170923.2153/haml-mode-autoloads.el +26 -0
  133. data/workshop/emacs.d/elpa/haml-mode-20170923.2153/haml-mode-pkg.el +2 -0
  134. data/workshop/emacs.d/elpa/haml-mode-20170923.2153/haml-mode.el +877 -0
  135. data/workshop/emacs.d/elpa/haml-mode-20170923.2153/haml-mode.elc +0 -0
  136. data/workshop/emacs.d/elpa/haml-mode-readme.txt +8 -0
  137. data/workshop/emacs.d/elpa/material-theme-20171123.1040/material-light-theme.el +918 -0
  138. data/workshop/emacs.d/elpa/material-theme-20171123.1040/material-light-theme.elc +0 -0
  139. data/workshop/emacs.d/elpa/material-theme-20171123.1040/material-theme-autoloads.el +32 -0
  140. data/workshop/emacs.d/elpa/material-theme-20171123.1040/material-theme-pkg.el +8 -0
  141. data/workshop/emacs.d/elpa/material-theme-20171123.1040/material-theme.el +912 -0
  142. data/workshop/emacs.d/elpa/material-theme-20171123.1040/material-theme.elc +0 -0
  143. data/workshop/emacs.d/elpa/ox-bibtex-chinese-readme.txt +21 -0
  144. data/workshop/emacs.d/elpa/popup-20160709.729/popup-autoloads.el +15 -0
  145. data/workshop/emacs.d/elpa/popup-20160709.729/popup-pkg.el +2 -0
  146. data/workshop/emacs.d/elpa/popup-20160709.729/popup.el +1432 -0
  147. data/workshop/emacs.d/elpa/popup-20160709.729/popup.elc +0 -0
  148. data/workshop/emacs.d/elpa/yaml-mode-20180212.1556/yaml-mode-autoloads.el +33 -0
  149. data/workshop/emacs.d/elpa/yaml-mode-20180212.1556/yaml-mode-pkg.el +2 -0
  150. data/workshop/emacs.d/elpa/yaml-mode-20180212.1556/yaml-mode.el +470 -0
  151. data/workshop/emacs.d/elpa/yaml-mode-20180212.1556/yaml-mode.elc +0 -0
  152. data/workshop/emacs.d/elpa/yaml-mode-readme.txt +25 -0
  153. data/workshop/emacs.d/haml-mode-master/.gitignore +1 -0
  154. data/workshop/emacs.d/haml-mode-master/.mailmap +2 -0
  155. data/workshop/emacs.d/haml-mode-master/MIT-LICENSE +20 -0
  156. data/workshop/emacs.d/haml-mode-master/README.md +47 -0
  157. data/workshop/emacs.d/haml-mode-master/haml-mode.el +887 -0
  158. data/workshop/emacs.d/iceberg_theme.el +202 -0
  159. data/workshop/emacs.d/init-open-recentf.el +133 -0
  160. data/workshop/emacs.d/init.el +229 -0
  161. data/workshop/emacs.d/inits/line-num.el +264 -0
  162. data/workshop/emacs.d/install-elisp.el +366 -0
  163. data/workshop/emacs.d/markdown-mode/markdown-mode.el +5978 -0
  164. data/workshop/emacs.d/notes +12 -0
  165. data/workshop/emacs.d/processing-mode/processing-mode.el +275 -0
  166. data/workshop/emacs.d/recentf +31 -0
  167. data/workshop/emacs.d/ruby-mode/inf-ruby.el +416 -0
  168. data/workshop/emacs.d/ruby-mode/rdoc-mode.el +130 -0
  169. data/workshop/emacs.d/ruby-mode/ruby-electric.el +205 -0
  170. data/workshop/emacs.d/ruby-mode/ruby-mode.el +1496 -0
  171. data/workshop/emacs.d/ruby-mode/ruby-style.el +78 -0
  172. data/workshop/emacs.d/ruby-mode/rubydb2x.el +104 -0
  173. data/workshop/emacs.d/ruby-mode/rubydb3x.el +115 -0
  174. data/workshop/emacs.d/ruby_learner_init.el +244 -0
  175. data/workshop/emacs.d/themes/dracula-theme.el +431 -0
  176. data/workshop/emacs.d/themes/iceberg-theme.el +205 -0
  177. data/workshop/emacs.d/themes/my-misterioso-theme.el +109 -0
  178. data/workshop/emacs.d/themes/my-wombat-theme.el +121 -0
  179. data/workshop/emacs.d/wiki-mode/wiki.el +976 -0
  180. data/workshop/emacs_help.org +34 -0
  181. data/workshop/lib/answer.rb +1 -0
  182. data/workshop/lib/sentence.org +1 -0
  183. data/workshop/lib/workplace.rb +1 -0
  184. data/workshop/restore/empty.rb +0 -0
  185. data/workshop/spec/spec_helper.rb +100 -0
  186. data/workshop/spec/workplace_spec.rb +1 -0
  187. data/workshop/training_data.txt +3 -0
  188. metadata +343 -0
@@ -0,0 +1,78 @@
1
+ ;;; -*- emacs-lisp -*-
2
+ ;;;
3
+ ;;; ruby-style.el -
4
+ ;;;
5
+ ;;; C/C++ mode style for Ruby.
6
+ ;;;
7
+ ;;; $Author: nobu $
8
+ ;;; created at: Thu Apr 26 13:54:01 JST 2007
9
+ ;;;
10
+ ;;; To switch to the "ruby" style automatically if it looks like a
11
+ ;;; source file of ruby, add ruby-style-c-mode to c-mode-hook:
12
+ ;;;
13
+ ;;; (require 'ruby-style)
14
+ ;;; (add-hook 'c-mode-hook 'ruby-style-c-mode)
15
+ ;;; (add-hook 'c++-mode-hook 'ruby-style-c-mode)
16
+ ;;;
17
+ ;;; Customize the c-default-style variable to set the default style
18
+ ;;; for each CC major mode.
19
+
20
+ (defconst ruby-style-revision "$Revision: 30485 $"
21
+ "Ruby style revision string.")
22
+
23
+ (defconst ruby-style-version
24
+ (and
25
+ (string-match "[0-9.]+" ruby-style-revision)
26
+ (substring ruby-style-revision (match-beginning 0) (match-end 0)))
27
+ "Ruby style version number.")
28
+
29
+ (defun ruby-style-case-indent (x)
30
+ (save-excursion
31
+ (back-to-indentation)
32
+ (unless (progn (backward-up-list) (back-to-indentation)
33
+ (> (point) (cdr x)))
34
+ (goto-char (cdr x))
35
+ (if (looking-at "\\<case\\|default\\>") '*))))
36
+
37
+ (defun ruby-style-label-indent (x)
38
+ (save-excursion
39
+ (back-to-indentation)
40
+ (unless (progn (backward-up-list) (back-to-indentation)
41
+ (>= (point) (cdr x)))
42
+ (goto-char (cdr x))
43
+ (condition-case ()
44
+ (progn
45
+ (backward-up-list)
46
+ (backward-sexp 2)
47
+ (if (looking-at "\\<switch\\>") '/))
48
+ (error)))))
49
+
50
+ (require 'cc-styles)
51
+ (c-add-style
52
+ "ruby"
53
+ '("bsd"
54
+ (c-basic-offset . 4)
55
+ (tab-width . 8)
56
+ (indent-tabs-mode . t)
57
+ (setq show-trailing-whitespace t)
58
+ (c-offsets-alist
59
+ (case-label . *)
60
+ (label . (ruby-style-label-indent *))
61
+ (statement-case-intro . *)
62
+ (statement-case-open . *)
63
+ (statement-block-intro . (ruby-style-case-indent +))
64
+ (access-label /)
65
+ )))
66
+
67
+ (defun ruby-style-c-mode ()
68
+ (interactive)
69
+ (if (or (let ((name (buffer-file-name))) (and name (string-match "/ruby\\>" name)))
70
+ (save-excursion
71
+ (goto-char (point-min))
72
+ (let ((head (progn (forward-line 100) (point)))
73
+ (case-fold-search nil))
74
+ (goto-char (point-min))
75
+ (re-search-forward "Copyright (C) .* Yukihiro Matsumoto" head t))))
76
+ (c-set-style "ruby")))
77
+
78
+ (provide 'ruby-style)
@@ -0,0 +1,104 @@
1
+ (require 'gud)
2
+ (provide 'rubydb)
3
+
4
+ ;; ======================================================================
5
+ ;; rubydb functions
6
+
7
+ ;;; History of argument lists passed to rubydb.
8
+ (defvar gud-rubydb-history nil)
9
+
10
+ (defun gud-rubydb-massage-args (file args)
11
+ (cons "-I" (cons "." (cons "-r" (cons "debug" (cons file args))))))
12
+
13
+ ;; There's no guarantee that Emacs will hand the filter the entire
14
+ ;; marker at once; it could be broken up across several strings. We
15
+ ;; might even receive a big chunk with several markers in it. If we
16
+ ;; receive a chunk of text which looks like it might contain the
17
+ ;; beginning of a marker, we save it here between calls to the
18
+ ;; filter.
19
+ (defvar gud-rubydb-marker-acc "")
20
+
21
+ (defun gud-rubydb-marker-filter (string)
22
+ (save-match-data
23
+ (setq gud-marker-acc (concat gud-marker-acc string))
24
+ (let ((output ""))
25
+
26
+ ;; Process all the complete markers in this chunk.
27
+ (while (string-match "\032\032\\([^:\n]*\\):\\([0-9]*\\):.*\n"
28
+ gud-marker-acc)
29
+ (setq
30
+
31
+ ;; Extract the frame position from the marker.
32
+ gud-last-frame
33
+ (cons (substring gud-marker-acc (match-beginning 1) (match-end 1))
34
+ (string-to-int (substring gud-marker-acc
35
+ (match-beginning 2)
36
+ (match-end 2))))
37
+
38
+ ;; Append any text before the marker to the output we're going
39
+ ;; to return - we don't include the marker in this text.
40
+ output (concat output
41
+ (substring gud-marker-acc 0 (match-beginning 0)))
42
+
43
+ ;; Set the accumulator to the remaining text.
44
+ gud-marker-acc (substring gud-marker-acc (match-end 0))))
45
+
46
+ ;; Does the remaining text look like it might end with the
47
+ ;; beginning of another marker? If it does, then keep it in
48
+ ;; gud-marker-acc until we receive the rest of it. Since we
49
+ ;; know the full marker regexp above failed, it's pretty simple to
50
+ ;; test for marker starts.
51
+ (if (string-match "\032.*\\'" gud-marker-acc)
52
+ (progn
53
+ ;; Everything before the potential marker start can be output.
54
+ (setq output (concat output (substring gud-marker-acc
55
+ 0 (match-beginning 0))))
56
+
57
+ ;; Everything after, we save, to combine with later input.
58
+ (setq gud-marker-acc
59
+ (substring gud-marker-acc (match-beginning 0))))
60
+
61
+ (setq output (concat output gud-marker-acc)
62
+ gud-marker-acc ""))
63
+
64
+ output)))
65
+
66
+ (defun gud-rubydb-find-file (f)
67
+ (find-file-noselect f))
68
+
69
+ (defvar rubydb-command-name "ruby"
70
+ "File name for executing ruby.")
71
+
72
+ ;;;###autoload
73
+ (defun rubydb (command-line)
74
+ "Run rubydb on program FILE in buffer *gud-FILE*.
75
+ The directory containing FILE becomes the initial working directory
76
+ and source-file directory for your debugger."
77
+ (interactive
78
+ (list (read-from-minibuffer "Run rubydb (like this): "
79
+ (if (consp gud-rubydb-history)
80
+ (car gud-rubydb-history)
81
+ (concat rubydb-command-name " "))
82
+ nil nil
83
+ '(gud-rubydb-history . 1))))
84
+
85
+ (gud-overload-functions '((gud-massage-args . gud-rubydb-massage-args)
86
+ (gud-marker-filter . gud-rubydb-marker-filter)
87
+ (gud-find-file . gud-rubydb-find-file)
88
+ ))
89
+ (gud-common-init command-line)
90
+
91
+ (gud-def gud-break "b %l" "\C-b" "Set breakpoint at current line.")
92
+ ; (gud-def gud-remove "clear %l" "\C-d" "Remove breakpoint at current line")
93
+ (gud-def gud-step "s" "\C-s" "Step one source line with display.")
94
+ (gud-def gud-next "n" "\C-n" "Step one line (skip functions).")
95
+ (gud-def gud-cont "c" "\C-r" "Continue with display.")
96
+ (gud-def gud-finish "finish" "\C-f" "Finish executing current function.")
97
+ (gud-def gud-up "up %p" "<" "Up N stack frames (numeric arg).")
98
+ (gud-def gud-down "down %p" ">" "Down N stack frames (numeric arg).")
99
+ (gud-def gud-print "p %e" "\C-p" "Evaluate ruby expression at point.")
100
+
101
+ (setq comint-prompt-regexp "^(rdb:-) ")
102
+ (setq paragraph-start comint-prompt-regexp)
103
+ (run-hooks 'rubydb-mode-hook)
104
+ )
@@ -0,0 +1,115 @@
1
+ (require 'gud)
2
+ (provide 'rubydb)
3
+
4
+ ;; ======================================================================
5
+ ;; rubydb functions
6
+
7
+ ;;; History of argument lists passed to rubydb.
8
+ (defvar gud-rubydb-history nil)
9
+
10
+ (if (fboundp 'gud-overload-functions)
11
+ (defun gud-rubydb-massage-args (file args)
12
+ (cons "-r" (cons "debug" (cons file args))))
13
+ (defun gud-rubydb-massage-args (file args)
14
+ (cons "-r" (cons "debug" args))))
15
+
16
+ ;; There's no guarantee that Emacs will hand the filter the entire
17
+ ;; marker at once; it could be broken up across several strings. We
18
+ ;; might even receive a big chunk with several markers in it. If we
19
+ ;; receive a chunk of text which looks like it might contain the
20
+ ;; beginning of a marker, we save it here between calls to the
21
+ ;; filter.
22
+ (defvar gud-rubydb-marker-acc "")
23
+ (make-variable-buffer-local 'gud-rubydb-marker-acc)
24
+
25
+ (defun gud-rubydb-marker-filter (string)
26
+ (setq gud-rubydb-marker-acc (concat gud-rubydb-marker-acc string))
27
+ (let ((output ""))
28
+
29
+ ;; Process all the complete markers in this chunk.
30
+ (while (string-match "\032\032\\([^:\n]*\\):\\([0-9]*\\):.*\n"
31
+ gud-rubydb-marker-acc)
32
+ (setq
33
+
34
+ ;; Extract the frame position from the marker.
35
+ gud-last-frame
36
+ (cons (substring gud-rubydb-marker-acc (match-beginning 1) (match-end 1))
37
+ (string-to-int (substring gud-rubydb-marker-acc
38
+ (match-beginning 2)
39
+ (match-end 2))))
40
+
41
+ ;; Append any text before the marker to the output we're going
42
+ ;; to return - we don't include the marker in this text.
43
+ output (concat output
44
+ (substring gud-rubydb-marker-acc 0 (match-beginning 0)))
45
+
46
+ ;; Set the accumulator to the remaining text.
47
+ gud-rubydb-marker-acc (substring gud-rubydb-marker-acc (match-end 0))))
48
+
49
+ ;; Does the remaining text look like it might end with the
50
+ ;; beginning of another marker? If it does, then keep it in
51
+ ;; gud-rubydb-marker-acc until we receive the rest of it. Since we
52
+ ;; know the full marker regexp above failed, it's pretty simple to
53
+ ;; test for marker starts.
54
+ (if (string-match "\032.*\\'" gud-rubydb-marker-acc)
55
+ (progn
56
+ ;; Everything before the potential marker start can be output.
57
+ (setq output (concat output (substring gud-rubydb-marker-acc
58
+ 0 (match-beginning 0))))
59
+
60
+ ;; Everything after, we save, to combine with later input.
61
+ (setq gud-rubydb-marker-acc
62
+ (substring gud-rubydb-marker-acc (match-beginning 0))))
63
+
64
+ (setq output (concat output gud-rubydb-marker-acc)
65
+ gud-rubydb-marker-acc ""))
66
+
67
+ output))
68
+
69
+ (defun gud-rubydb-find-file (f)
70
+ (save-excursion
71
+ (let ((buf (find-file-noselect f)))
72
+ (set-buffer buf)
73
+ ;; (gud-make-debug-menu)
74
+ buf)))
75
+
76
+ (defvar rubydb-command-name "ruby"
77
+ "File name for executing ruby.")
78
+
79
+ ;;;###autoload
80
+ (defun rubydb (command-line)
81
+ "Run rubydb on program FILE in buffer *gud-FILE*.
82
+ The directory containing FILE becomes the initial working directory
83
+ and source-file directory for your debugger."
84
+ (interactive
85
+ (list (read-from-minibuffer "Run rubydb (like this): "
86
+ (if (consp gud-rubydb-history)
87
+ (car gud-rubydb-history)
88
+ (concat rubydb-command-name " "))
89
+ nil nil
90
+ '(gud-rubydb-history . 1))))
91
+
92
+ (if (not (fboundp 'gud-overload-functions))
93
+ (gud-common-init command-line 'gud-rubydb-massage-args
94
+ 'gud-rubydb-marker-filter 'gud-rubydb-find-file)
95
+ (gud-overload-functions '((gud-massage-args . gud-rubydb-massage-args)
96
+ (gud-marker-filter . gud-rubydb-marker-filter)
97
+ (gud-find-file . gud-rubydb-find-file)))
98
+ (gud-common-init command-line rubydb-command-name))
99
+
100
+ (gud-def gud-break "b %l" "\C-b" "Set breakpoint at current line.")
101
+ ; (gud-def gud-remove "clear %l" "\C-d" "Remove breakpoint at current line")
102
+ (gud-def gud-step "s" "\C-s" "Step one source line with display.")
103
+ (gud-def gud-next "n" "\C-n" "Step one line (skip functions).")
104
+ (gud-def gud-cont "c" "\C-r" "Continue with display.")
105
+ (gud-def gud-finish "finish" "\C-f" "Finish executing current function.")
106
+ (gud-def gud-up "up %p" "<" "Up N stack frames (numeric arg).")
107
+ (gud-def gud-down "down %p" ">" "Down N stack frames (numeric arg).")
108
+ (gud-def gud-print "p %e" "\C-p" "Evaluate ruby expression at point.")
109
+
110
+ (setq comint-prompt-regexp "^(rdb:-) ")
111
+ (if (boundp 'comint-last-output-start)
112
+ (set-marker comint-last-output-start (point)))
113
+ (set (make-local-variable 'paragraph-start) comint-prompt-regexp)
114
+ (run-hooks 'rubydb-mode-hook)
115
+ )
@@ -0,0 +1,244 @@
1
+ ;; るびきちのyaml-modeの説明従って..
2
+ ;; http://emacs.rubikitch.com/yaml-mode/
3
+ ;; 学内からはsetproxyを忘れぬように.
4
+ (require 'package)
5
+ (add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/") t)
6
+ (add-to-list 'package-archives '("marmalade" . "http://maramalae-repo.org/packages/"))
7
+ (add-to-list 'package-archives '("org" . "http:/orgmode.org/elpa/") t)
8
+ (add-to-list 'package-archives '("org-plus-contrib" . "https:/orgmode.org/elpa/contrib") t)
9
+
10
+ (fset 'package-desc-vers 'package--ac-desc-version)
11
+ (package-initialize)
12
+
13
+ ;; '(("gnu" . "http://elpa.gnu.org/packages/")
14
+
15
+ ;; るびきちのemacs lispテクニックバイブルに従ってdefaultの色つけを活性化
16
+ ;; (require 'generic-x)
17
+ ;; tabの自動生成がうっとおしいからやめた
18
+
19
+ ;; elファイルの置き場所を設定
20
+ (setq load-path (cons "~/ruby_learner/workshop/emacs.d/inits" load-path))
21
+ (setq load-path (cons "~/ruby_learner/workshop/emacs.d/ruby-mode" load-path))
22
+ (setq load-path (cons "~/ruby_learner/workshop/emacs.d/processing-mode" load-path))
23
+ (setq load-path (cons "~/ruby_learner/workshop/emacs.d/haml-mode-master" load-path))
24
+ (setq load-path (cons "~/ruby_learner/workshop/emacs.d/org-mode" load-path))
25
+ (setq load-path (cons "~/ruby_learner/workshop/emacs.d/themes" load-path))
26
+
27
+ ;; 画面分割
28
+ (setq w (selected-window))
29
+ (setq w3 (split-window w nil t))
30
+ ;; 画面移動
31
+ ;; (setq windmove-wrap-around t)
32
+ (setq w2 (split-window w nil nil))
33
+ ;; scratch文字
34
+ (setq initial-scratch-message "ctrl x & ctrl f 後に answer.rb を入力。")
35
+ (insert-file-contents "~/ruby_learner/workshop/lib/answer.rb" nil 0 500)
36
+ (ruby-mode)
37
+ (find-file "~/ruby_learner/workshop/lib/answer.rb")
38
+ ;;setting_theme
39
+ (add-to-list 'custom-theme-load-path "~/ruby_learner/workshop/emacs.d/themes")
40
+ (setq custom-theme-directory "~/ruby_learner/workshop/emacs.d/themes")
41
+ ;;(load-theme 'iceberg t)
42
+ ;;(load-theme 'dracula t)
43
+ ;;(load-theme 'my-misterioso t)
44
+ (load-theme 'my-wombat t)
45
+
46
+ ;; 起動時にスタートアップ画面を表示しない
47
+ (setq inhibit-startup-message t)
48
+ ;; 1 行ずつスムーズにスクロールする
49
+ (setq scroll-step 1)
50
+ ;; 行数を記載する
51
+ (global-linum-mode t)
52
+ (setq linum-format "%d")
53
+ (set-face-attribute 'linum nil
54
+ :foreground "#999999"
55
+ :background "#000000"
56
+ :height 0.9)
57
+ ;; 括弧補完
58
+ ;;(electric-pair-mode 1)
59
+ ;; 行数を指定してジャンプする (goto-line)
60
+ ;;(global-set-key "\C-l" 'goto-line)
61
+ ;; 言語を日本語に設定
62
+ (set-language-environment 'Japanese)
63
+ ;; 極力UTF-8とする
64
+ (prefer-coding-system 'utf-8)
65
+
66
+ ;; エンコード方式をUTF-8に
67
+ (set-default-coding-systems 'utf-8)
68
+
69
+ (setq coding-system-for-read 'utf-8)
70
+ (setq coding-system-for-write 'utf-8)
71
+ (require 'ruby-mode)
72
+ (defun ruby-mode-set-encoding () nil)
73
+ ;; C-zでUndo
74
+ ;;(global-set-key "\C-z" 'undo)
75
+ ;; 行番号をデフォルトで表示
76
+ ;;(require 'line-num)
77
+ ;;(global-linum-mode 1)
78
+ ;; 対応する括弧を光らせる
79
+ (show-paren-mode 1)
80
+ ;; 最近使ったファイルの一覧
81
+ (recentf-mode 1)
82
+ ;; タイトルバーに開いているバッファのパスを表示
83
+ (setq frame-title-format (format "%%f - Emacs@%s" (system-name)))
84
+ ;; 現在行を目立たせる
85
+ ;; (global-hl-line-mode)
86
+ ;; バックアップファイルを作らない
87
+ ;; (setq backup-inhibited t)
88
+ ;; モードラインに時間を表示する
89
+ (display-time)
90
+ ;; 現在の関数名をモードラインに表示
91
+ (which-function-mode 1)
92
+ ;; 選択部分のインデント
93
+ (global-set-key "\C-x\C-i" 'indent-region)
94
+
95
+ (defun linux-c-mode ()
96
+ "C mode with adjusted defaults for use with the Linux kernel."
97
+ (interactive)
98
+ (c-mode)
99
+ (setq c-indent-level 8)
100
+ (setq c-brace-imaginary-offset 0)
101
+ (setq c-brace-offset -8)
102
+ (setq c-argdecl-indent 8)
103
+ (setq c-label-offset -8)
104
+ (setq c-continued-statement-offset 8)
105
+ (setq indent-tabs-mode nil)
106
+ (setq tab-width 8)
107
+ )
108
+
109
+ ;; ======================================================================
110
+ ;; Ruby mode
111
+ ;; ======================================================================
112
+ (add-to-list 'auto-mode-alist '("\\.rake$" . ruby-mode))
113
+ (add-to-list 'auto-mode-alist '("Rakefile$" . ruby-mode))
114
+ (add-to-list 'auto-mode-alist '("\\.gemspec$" . ruby-mode))
115
+ (add-to-list 'auto-mode-alist '("\\.ru$" . ruby-mode))
116
+ (add-to-list 'auto-mode-alist '("Gemfile$" . ruby-mode))
117
+ (add-to-list 'auto-mode-alist '("Guardfile$" . ruby-mode))
118
+ (add-to-list 'auto-mode-alist '("Guardfile$" . ruby-mode))
119
+
120
+ (autoload 'ruby-mode "ruby-mode"
121
+ "Mode for editing ruby source files" t)
122
+ (setq auto-mode-alist (append '(("\\.rb$" . ruby-mode)) auto-mode-alist))
123
+ (setq auto-mode-alist (append '(("\\.ru$" . ruby-mode)) auto-mode-alist))
124
+ (setq auto-mode-alist (append '(("\\.ru$" . ruby-mode)) auto-mode-alist))
125
+ (setq interpreter-mode-alist (append '(("ruby" . ruby-mode))
126
+ interpreter-mode-alist))
127
+ (prefer-coding-system 'utf-8)
128
+ (setq coding-system-for-read 'utf-8)
129
+ (setq coding-system-for-write 'utf-8)
130
+ (autoload 'run-ruby "inf-ruby"
131
+ "Run an inferior Ruby process")
132
+ (autoload 'inf-ruby-keys "inf-ruby"
133
+ "Set local key defs for inf-ruby in ruby-mode")
134
+ (add-hook 'ruby-mode-hook
135
+ '(lambda ()
136
+ (inf-ruby-keys)))
137
+ (global-font-lock-mode 1)
138
+
139
+ ;;;ruby-electric.el --- electric editing commands for ruby files
140
+ ;;(require 'ruby-electric)
141
+ ;;(add-hook 'ruby-mode-hook '(lambda () (ruby-electric-mode t)))
142
+
143
+ (setq ruby-indent-level 2)
144
+ (setq ruby-indent-tabs-mode nil)
145
+
146
+ ;; ruby code folding from https://coderwall.com/p/u-l0ra/ruby-code-folding-in-emacs
147
+ (add-hook 'ruby-mode-hook
148
+ (lambda () (hs-minor-mode)))
149
+
150
+ (eval-after-load "hideshow"
151
+ '(add-to-list 'hs-special-modes-alist
152
+ `(ruby-mode
153
+ ,(rx (or "def" "class" "module" "do" "{" "[")) ; Block start
154
+ ,(rx (or "}" "]" "end")) ; Block end
155
+ ,(rx (or "#" "=begin")) ; Comment start
156
+ ruby-forward-sexp nil)))
157
+
158
+ (global-set-key (kbd "C-c h") 'hs-hide-block)
159
+ (global-set-key (kbd "C-c s") 'hs-show-block)
160
+
161
+ ;; ======================================================================
162
+ ;; Processing mode
163
+ ;; ======================================================================
164
+ ;;(add-to-list 'load-path "/Users/bob/ruby-processing/processing2-emacs")
165
+ (autoload 'processing-mode "processing-mode" "Processing mode" t)
166
+ (add-to-list 'auto-mode-alist '("\\.pde$" . processing-mode))
167
+ (setq processing-indent-level 2)
168
+
169
+ (setq processing-location "/Users/bob/bin/processing-java")
170
+ (setq processing-application-dir "/Applications/Processing.app")
171
+ (setq processing-sketch-dir "~/Documents/Processing")
172
+
173
+ (setq-default indent-tabs-mode nil)
174
+ (setq tab-width 2)
175
+
176
+ ;; =======================
177
+ ;; haml mode
178
+ ;; =======================
179
+ ;;``` lisp
180
+ (require 'haml-mode)
181
+ ;;```
182
+ (autoload 'haml-mode "haml-mode" "haml mode" t)
183
+ (add-to-list 'auto-mode-alist '("\\.haml$" . haml-mode))
184
+ (setq-default indent-tabs-mode t)
185
+ (setq tab-width 2)
186
+
187
+ ;; =======================
188
+ ;; yaml mode
189
+ ;; =======================
190
+ (require 'yaml-mode)
191
+ (add-to-list 'auto-mode-alist '("\\.ya?ml$" . yaml-mode))
192
+ (define-key yaml-mode-map "\C-m" 'newline-and-indent)
193
+
194
+ ;; =======================
195
+ ;; org mode
196
+ ;; =======================
197
+ (require 'ox-latex)
198
+ ;; (require 'ox-bibtex) こいつは無くなったんかな.イランで.
199
+
200
+ ;; org-modeで行末で折り返しをする
201
+ (setq org-startup-truncated nil)
202
+ (unless (boundp 'org-latex-classes)
203
+ (setq org-latex-classes nil))
204
+ (add-to-list 'org-latex-classes
205
+ '("article"
206
+ "
207
+ \\documentclass{jsarticle}
208
+ \\usepackage[dvipdfmx]{graphicx}
209
+ \\usepackage[utf8]{inputenc}
210
+ \\usepackage[T1]{fontenc}
211
+ "
212
+ ("\\section{%s}" . "\\section*{%s}")
213
+ ("\\subsection{%s}" . "\\subsection*{%s}")
214
+ ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
215
+ ("\\paragraph{%s}" . "\\paragraph*{%s}")
216
+ ("\\subparagraph{%s}" . "\\subparagraph*{%s}")
217
+ ))
218
+
219
+ ;;; LaTeX 形式のファイル PDF に変換するためのコマンド
220
+ (setq org-latex-pdf-process
221
+ '("platex %f"
222
+ "bibtex %b"
223
+ "platex %f"
224
+ "platex %f"
225
+ "dvipdfmx %b.dvi"))
226
+
227
+ (custom-set-variables
228
+ ;; custom-set-variables was added by Custom.
229
+ ;; If you edit it by hand, you could mess it up, so be careful.
230
+ ;; Your init file should contain only one such instance.
231
+ ;; If there is more than one, they won't work right.
232
+ '(org-latex-pdf-process
233
+ (quote
234
+ ("pdflatex -interaction nonstopmode -output-directory %o %f"
235
+ "bibtex %o"
236
+ "pdflatex -interaction nonstopmode -output-directory %o %f"
237
+ "pdflatex -interaction nonstopmode -output-directory %o %f")))
238
+ '(package-selected-packages (quote (haml-mode yaml-mode))))
239
+ (custom-set-faces
240
+ ;; custom-set-faces was added by Custom.
241
+ ;; If you edit it by hand, you could mess it up, so be careful.
242
+ ;; Your init file should contain only one such instance.
243
+ ;; If there is more than one, they won't work right.
244
+ )