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,33 @@
1
+ ;;; yaml-mode-autoloads.el --- automatically extracted autoloads
2
+ ;;
3
+ ;;; Code:
4
+ (add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path))))
5
+
6
+ ;;;### (autoloads nil "yaml-mode" "yaml-mode.el" (23227 9393 469979
7
+ ;;;;;; 610000))
8
+ ;;; Generated autoloads from yaml-mode.el
9
+
10
+ (let ((loads (get 'yaml 'custom-loads))) (if (member '"yaml-mode" loads) nil (put 'yaml 'custom-loads (cons '"yaml-mode" loads))))
11
+
12
+ (autoload 'yaml-mode "yaml-mode" "\
13
+ Simple mode to edit YAML.
14
+
15
+ \\{yaml-mode-map}
16
+
17
+ \(fn)" t nil)
18
+
19
+ (add-to-list 'auto-mode-alist '("\\.\\(e?ya?\\|ra\\)ml\\'" . yaml-mode))
20
+
21
+ ;;;***
22
+
23
+ ;;;### (autoloads nil nil ("yaml-mode-pkg.el") (23227 9370 628956
24
+ ;;;;;; 786000))
25
+
26
+ ;;;***
27
+
28
+ ;; Local Variables:
29
+ ;; version-control: never
30
+ ;; no-byte-compile: t
31
+ ;; no-update-autoloads: t
32
+ ;; End:
33
+ ;;; yaml-mode-autoloads.el ends here
@@ -0,0 +1,2 @@
1
+ ;;; -*- no-byte-compile: t -*-
2
+ (define-package "yaml-mode" "20180212.1556" "Major mode for editing YAML files" '((emacs "24.1")) :commit "3fc5a33760b0bbb6e67adbce48ab3dc4ae34b847" :keywords '("data" "yaml"))
@@ -0,0 +1,470 @@
1
+ ;;; yaml-mode.el --- Major mode for editing YAML files
2
+
3
+ ;; Copyright (C) 2010-2014 Yoshiki Kurihara
4
+
5
+ ;; Author: Yoshiki Kurihara <clouder@gmail.com>
6
+ ;; Marshall T. Vandegrift <llasram@gmail.com>
7
+ ;; Maintainer: Vasilij Schneidermann <v.schneidermann@gmail.com>
8
+ ;; Package-Requires: ((emacs "24.1"))
9
+ ;; Package-Version: 20180212.1556
10
+ ;; Keywords: data yaml
11
+ ;; Version: 0.0.13
12
+
13
+ ;; This file is not part of Emacs
14
+
15
+ ;; This file is free software; you can redistribute it and/or modify
16
+ ;; it under the terms of the GNU General Public License as published by
17
+ ;; the Free Software Foundation; either version 2, or (at your option)
18
+ ;; any later version.
19
+
20
+ ;; This file is distributed in the hope that it will be useful,
21
+ ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ ;; GNU General Public License for more details.
24
+
25
+ ;; You should have received a copy of the GNU General Public License along
26
+ ;; with this program; if not, write to the Free Software Foundation, Inc.,
27
+ ;; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28
+
29
+ ;;; Commentary:
30
+
31
+ ;; This is a major mode for editing files in the YAML data
32
+ ;; serialization format. It was initially developed by Yoshiki
33
+ ;; Kurihara and many features were added by Marshall Vandegrift. As
34
+ ;; YAML and Python share the fact that indentation determines
35
+ ;; structure, this mode provides indentation and indentation command
36
+ ;; behavior very similar to that of python-mode.
37
+
38
+ ;;; Installation:
39
+
40
+ ;; To install, just drop this file into a directory in your
41
+ ;; `load-path' and (optionally) byte-compile it. To automatically
42
+ ;; handle files ending in '.yml', add something like:
43
+ ;;
44
+ ;; (require 'yaml-mode)
45
+ ;; (add-to-list 'auto-mode-alist '("\\.yml\\'" . yaml-mode))
46
+ ;;
47
+ ;; to your .emacs file.
48
+ ;;
49
+ ;; Unlike python-mode, this mode follows the Emacs convention of not
50
+ ;; binding the ENTER key to `newline-and-indent'. To get this
51
+ ;; behavior, add the key definition to `yaml-mode-hook':
52
+ ;;
53
+ ;; (add-hook 'yaml-mode-hook
54
+ ;; '(lambda ()
55
+ ;; (define-key yaml-mode-map "\C-m" 'newline-and-indent)))
56
+
57
+ ;;; Known Bugs:
58
+
59
+ ;; YAML is easy to write but complex to parse, and this mode doesn't
60
+ ;; even really try. Indentation and highlighting will break on
61
+ ;; abnormally complicated structures.
62
+
63
+ ;;; Code:
64
+
65
+
66
+ ;; User definable variables
67
+
68
+ ;;;###autoload
69
+ (defgroup yaml nil
70
+ "Support for the YAML serialization format"
71
+ :group 'languages
72
+ :prefix "yaml-")
73
+
74
+ (defcustom yaml-mode-hook nil
75
+ "*Hook run by `yaml-mode'."
76
+ :type 'hook
77
+ :group 'yaml)
78
+
79
+ (defcustom yaml-indent-offset 2
80
+ "*Amount of offset per level of indentation."
81
+ :type 'integer
82
+ :safe 'natnump
83
+ :group 'yaml)
84
+
85
+ (defcustom yaml-backspace-function 'backward-delete-char-untabify
86
+ "*Function called by `yaml-electric-backspace' when deleting backwards.
87
+ It will receive one argument, the numeric prefix value."
88
+ :type 'function
89
+ :group 'yaml)
90
+
91
+ (defcustom yaml-block-literal-search-lines 100
92
+ "*Maximum number of lines to search for start of block literals."
93
+ :type 'integer
94
+ :group 'yaml)
95
+
96
+ (defcustom yaml-block-literal-electric-alist
97
+ '((?| . "") (?> . "-"))
98
+ "*Characters for which to provide electric behavior.
99
+ The association list key should be a key code and the associated value
100
+ should be a string containing additional characters to insert when
101
+ that key is pressed to begin a block literal."
102
+ :type 'alist
103
+ :group 'yaml)
104
+
105
+ (defface yaml-tab-face
106
+ '((((class color)) (:background "red" :foreground "red" :bold t))
107
+ (t (:reverse-video t)))
108
+ "Face to use for highlighting tabs in YAML files."
109
+ :group 'faces
110
+ :group 'yaml)
111
+
112
+ (defcustom yaml-imenu-generic-expression
113
+ '((nil "^\\(:?[a-zA-Z_-]+\\):" 1))
114
+ "The imenu regex to parse an outline of the yaml file."
115
+ :type 'string
116
+ :group 'yaml)
117
+
118
+
119
+ ;; Constants
120
+
121
+ (defconst yaml-mode-version "0.0.13" "Version of `yaml-mode'.")
122
+
123
+ (defconst yaml-blank-line-re "^ *$"
124
+ "Regexp matching a line containing only (valid) whitespace.")
125
+
126
+ (defconst yaml-directive-re "^\\(?:--- \\)? *%\\(\\w+\\)"
127
+ "Regexp matching a line contatining a YAML directive.")
128
+
129
+ (defconst yaml-document-delimiter-re "^\\(?:---\\|[.][.][.]\\)"
130
+ "Rexexp matching a YAML document delimiter line.")
131
+
132
+ (defconst yaml-node-anchor-alias-re "[&*][a-zA-Z0-9_-]+"
133
+ "Regexp matching a YAML node anchor or alias.")
134
+
135
+ (defconst yaml-tag-re "!!?[^ \n]+"
136
+ "Rexexp matching a YAML tag.")
137
+
138
+ (defconst yaml-bare-scalar-re
139
+ "\\(?:[^-:,#!\n{\\[ ]\\|[^#!\n{\\[ ]\\S-\\)[^#\n]*?"
140
+ "Rexexp matching a YAML bare scalar.")
141
+
142
+ (defconst yaml-hash-key-re
143
+ (concat "\\(?:^\\(?:--- \\)?\\|{\\|\\(?:[-,] +\\)+\\) *"
144
+ "\\(?:" yaml-tag-re " +\\)?"
145
+ "\\(" yaml-bare-scalar-re "\\) *:"
146
+ "\\(?: +\\|$\\)")
147
+ "Regexp matching a single YAML hash key.")
148
+
149
+ (defconst yaml-scalar-context-re
150
+ (concat "\\(?:^\\(?:--- \\)?\\|{\\|\\(?: *[-,] +\\)+\\) *"
151
+ "\\(?:" yaml-bare-scalar-re " *: \\)?")
152
+ "Regexp indicating the beginning of a scalar context.")
153
+
154
+ (defconst yaml-nested-map-re
155
+ (concat ".*: *\\(?:&.*\\|{ *\\|" yaml-tag-re " *\\)?$")
156
+ "Regexp matching a line beginning a YAML nested structure.")
157
+
158
+ (defconst yaml-block-literal-base-re " *[>|][-+0-9]* *\\(?:\n\\|\\'\\)"
159
+ "Regexp matching the substring start of a block literal.")
160
+
161
+ (defconst yaml-block-literal-re
162
+ (concat yaml-scalar-context-re
163
+ "\\(?:" yaml-tag-re "\\)?"
164
+ yaml-block-literal-base-re)
165
+ "Regexp matching a line beginning a YAML block literal.")
166
+
167
+ (defconst yaml-nested-sequence-re
168
+ (concat "^\\(?:\\(?: *- +\\)+\\|\\(:? *-$\\)\\)"
169
+ "\\(?:" yaml-bare-scalar-re " *:\\(?: +.*\\)?\\)?$")
170
+ "Regexp matching a line containing one or more nested YAML sequences.")
171
+
172
+ (defconst yaml-constant-scalars-re
173
+ (concat "\\(?:^\\|\\(?::\\|-\\|,\\|{\\|\\[\\) +\\) *"
174
+ (regexp-opt
175
+ '("~" "null" "Null" "NULL"
176
+ ".nan" ".NaN" ".NAN"
177
+ ".inf" ".Inf" ".INF"
178
+ "-.inf" "-.Inf" "-.INF"
179
+ "y" "Y" "yes" "Yes" "YES" "n" "N" "no" "No" "NO"
180
+ "true" "True" "TRUE" "false" "False" "FALSE"
181
+ "on" "On" "ON" "off" "Off" "OFF") t)
182
+ " *$")
183
+ "Regexp matching certain scalar constants in scalar context.")
184
+
185
+
186
+ ;; Mode setup
187
+
188
+ (defvar yaml-mode-map
189
+ (let ((map (make-sparse-keymap)))
190
+ (define-key map "|" 'yaml-electric-bar-and-angle)
191
+ (define-key map ">" 'yaml-electric-bar-and-angle)
192
+ (define-key map "-" 'yaml-electric-dash-and-dot)
193
+ (define-key map "." 'yaml-electric-dash-and-dot)
194
+ (define-key map (kbd "DEL") 'yaml-electric-backspace)
195
+ map)
196
+ "Keymap used in `yaml-mode' buffers.")
197
+
198
+ (defvar yaml-mode-syntax-table
199
+ (let ((syntax-table (make-syntax-table)))
200
+ (modify-syntax-entry ?\' "\"" syntax-table)
201
+ (modify-syntax-entry ?\" "\"" syntax-table)
202
+ (modify-syntax-entry ?# "<" syntax-table)
203
+ (modify-syntax-entry ?\n ">" syntax-table)
204
+ (modify-syntax-entry ?\\ "\\" syntax-table)
205
+ (modify-syntax-entry ?- "_" syntax-table)
206
+ (modify-syntax-entry ?_ "_" syntax-table)
207
+ (modify-syntax-entry ?& "." syntax-table)
208
+ (modify-syntax-entry ?* "." syntax-table)
209
+ (modify-syntax-entry ?\( "." syntax-table)
210
+ (modify-syntax-entry ?\) "." syntax-table)
211
+ (modify-syntax-entry ?\{ "(}" syntax-table)
212
+ (modify-syntax-entry ?\} "){" syntax-table)
213
+ (modify-syntax-entry ?\[ "(]" syntax-table)
214
+ (modify-syntax-entry ?\] ")[" syntax-table)
215
+ syntax-table)
216
+ "Syntax table in use in `yaml-mode' buffers.")
217
+
218
+ ;;;###autoload
219
+ (define-derived-mode yaml-mode text-mode "YAML"
220
+ "Simple mode to edit YAML.
221
+
222
+ \\{yaml-mode-map}"
223
+ :syntax-table yaml-mode-syntax-table
224
+ (set (make-local-variable 'comment-start) "# ")
225
+ (set (make-local-variable 'comment-start-skip) "#+ *")
226
+ (set (make-local-variable 'indent-line-function) 'yaml-indent-line)
227
+ (set (make-local-variable 'indent-tabs-mode) nil)
228
+ (set (make-local-variable 'fill-paragraph-function) 'yaml-fill-paragraph)
229
+
230
+ (set (make-local-variable 'syntax-propertize-function)
231
+ 'yaml-mode-syntax-propertize-function)
232
+ (setq font-lock-defaults '(yaml-font-lock-keywords)))
233
+
234
+
235
+ ;; Font-lock support
236
+
237
+ (defvar yaml-font-lock-keywords
238
+ `((yaml-font-lock-block-literals 0 font-lock-string-face)
239
+ (,yaml-constant-scalars-re . (1 font-lock-constant-face))
240
+ (,yaml-tag-re . (0 font-lock-type-face))
241
+ (,yaml-node-anchor-alias-re . (0 font-lock-function-name-face))
242
+ (,yaml-hash-key-re . (1 font-lock-variable-name-face))
243
+ (,yaml-document-delimiter-re . (0 font-lock-comment-face))
244
+ (,yaml-directive-re . (1 font-lock-builtin-face))
245
+ ("^[\t]+" 0 'yaml-tab-face t))
246
+ "Additional expressions to highlight in YAML mode.")
247
+
248
+ (defun yaml-mode-syntax-propertize-function (beg end)
249
+ "Override buffer's syntax table for special syntactic constructs."
250
+ ;; Unhighlight foo#bar tokens between BEG and END.
251
+ (save-excursion
252
+ (goto-char beg)
253
+ (while (search-forward "#" end t)
254
+ (save-excursion
255
+ (forward-char -1)
256
+ ;; both ^# and [ \t]# are comments
257
+ (when (and (not (bolp))
258
+ (not (memq (preceding-char) '(?\s ?\t))))
259
+ (put-text-property (point) (1+ (point))
260
+ 'syntax-table (string-to-syntax "_"))))))
261
+
262
+ ;; If quote is detected as a syntactic string start but appeared
263
+ ;; after a non-whitespace character, then mark it as syntactic word.
264
+ (save-excursion
265
+ (goto-char beg)
266
+ (while (re-search-forward "['\"]" end t)
267
+ (when (get-text-property (point) 'yaml-block-literal)
268
+ (put-text-property (1- (point)) (point)
269
+ 'syntax-table (string-to-syntax "w")))
270
+ (when (nth 8 (syntax-ppss))
271
+ (save-excursion
272
+ (forward-char -1)
273
+ (cond ((and (char-equal ?' (char-before (point)))
274
+ (char-equal ?' (char-after (point)))
275
+ (put-text-property (1- (point)) (1+ (point))
276
+ 'syntax-table (string-to-syntax "w"))))
277
+ ((and (not (bolp))
278
+ (char-equal ?w (char-syntax (char-before (point)))))
279
+ (put-text-property (point) (1+ (point))
280
+ 'syntax-table (string-to-syntax "w")))))))))
281
+
282
+ (defun yaml-font-lock-block-literals (bound)
283
+ "Find lines within block literals.
284
+ Find the next line of the first (if any) block literal after point and
285
+ prior to BOUND. Returns the beginning and end of the block literal
286
+ line in the match data, as consumed by `font-lock-keywords' matcher
287
+ functions. The function begins by searching backwards to determine
288
+ whether or not the current line is within a block literal. This could
289
+ be time-consuming in large buffers, so the number of lines searched is
290
+ artificially limitted to the value of
291
+ `yaml-block-literal-search-lines'."
292
+ (if (eolp) (goto-char (1+ (point))))
293
+ (unless (or (eobp) (>= (point) bound))
294
+ (let ((begin (point))
295
+ (end (min (1+ (point-at-eol)) bound)))
296
+ (goto-char (point-at-bol))
297
+ (while (and (looking-at yaml-blank-line-re)
298
+ (not (bobp)))
299
+ (forward-line -1))
300
+ (let ((nlines yaml-block-literal-search-lines)
301
+ (min-level (current-indentation)))
302
+ (forward-line -1)
303
+ (while (and (/= nlines 0)
304
+ (/= min-level 0)
305
+ (not (looking-at yaml-block-literal-re))
306
+ (not (bobp)))
307
+ (setq nlines (1- nlines))
308
+ (unless (looking-at yaml-blank-line-re)
309
+ (setq min-level (min min-level (current-indentation))))
310
+ (forward-line -1))
311
+ (cond
312
+ ((and (< (current-indentation) min-level)
313
+ (looking-at yaml-block-literal-re))
314
+ (goto-char end)
315
+ (put-text-property begin end 'yaml-block-literal t)
316
+ (set-match-data (list begin end))
317
+ t)
318
+ ((progn
319
+ (goto-char begin)
320
+ (re-search-forward (concat yaml-block-literal-re
321
+ " *\\(.*\\)\n")
322
+ bound t))
323
+ (let ((range (nthcdr 2 (match-data))))
324
+ (put-text-property (car range) (cadr range) 'yaml-block-literal t)
325
+ (set-match-data range))
326
+ t))))))
327
+
328
+
329
+ ;; Indentation and electric keys
330
+
331
+ (defun yaml-compute-indentation ()
332
+ "Calculate the maximum sensible indentation for the current line."
333
+ (save-excursion
334
+ (beginning-of-line)
335
+ (if (looking-at yaml-document-delimiter-re) 0
336
+ (forward-line -1)
337
+ (while (and (looking-at yaml-blank-line-re)
338
+ (> (point) (point-min)))
339
+ (forward-line -1))
340
+ (+ (current-indentation)
341
+ (if (looking-at yaml-nested-map-re) yaml-indent-offset 0)
342
+ (if (looking-at yaml-nested-sequence-re) yaml-indent-offset 0)
343
+ (if (looking-at yaml-block-literal-re) yaml-indent-offset 0)))))
344
+
345
+ (defun yaml-indent-line ()
346
+ "Indent the current line.
347
+ The first time this command is used, the line will be indented to the
348
+ maximum sensible indentation. Each immediately subsequent usage will
349
+ back-dent the line by `yaml-indent-offset' spaces. On reaching column
350
+ 0, it will cycle back to the maximum sensible indentation."
351
+ (interactive "*")
352
+ (let ((ci (current-indentation))
353
+ (cc (current-column))
354
+ (need (yaml-compute-indentation)))
355
+ (save-excursion
356
+ (beginning-of-line)
357
+ (delete-horizontal-space)
358
+ (if (and (equal last-command this-command) (/= ci 0))
359
+ (indent-to (* (/ (- ci 1) yaml-indent-offset) yaml-indent-offset))
360
+ (indent-to need)))
361
+ (if (< (current-column) (current-indentation))
362
+ (forward-to-indentation 0))))
363
+
364
+ (defun yaml-electric-backspace (arg)
365
+ "Delete characters or back-dent the current line.
366
+ If invoked following only whitespace on a line, will back-dent to the
367
+ immediately previous multiple of `yaml-indent-offset' spaces."
368
+ (interactive "*p")
369
+ (if (or (/= (current-indentation) (current-column)) (bolp))
370
+ (funcall yaml-backspace-function arg)
371
+ (let ((ci (current-column)))
372
+ (beginning-of-line)
373
+ (delete-horizontal-space)
374
+ (indent-to (* (/ (- ci (* arg yaml-indent-offset))
375
+ yaml-indent-offset)
376
+ yaml-indent-offset)))))
377
+
378
+ (defun yaml-electric-bar-and-angle (arg)
379
+ "Insert the bound key and possibly begin a block literal.
380
+ Inserts the bound key. If inserting the bound key causes the current
381
+ line to match the initial line of a block literal, then inserts the
382
+ matching string from `yaml-block-literal-electric-alist', a newline,
383
+ and indents appropriately."
384
+ (interactive "*P")
385
+ (self-insert-command (prefix-numeric-value arg))
386
+ (let ((extra-chars
387
+ (assoc last-command-event
388
+ yaml-block-literal-electric-alist)))
389
+ (cond
390
+ ((and extra-chars (not arg) (eolp)
391
+ (save-excursion
392
+ (beginning-of-line)
393
+ (looking-at yaml-block-literal-re)))
394
+ (insert (cdr extra-chars))
395
+ (newline-and-indent)))))
396
+
397
+ (defun yaml-electric-dash-and-dot (arg)
398
+ "Insert the bound key and possibly de-dent line.
399
+ Inserts the bound key. If inserting the bound key causes the current
400
+ line to match a document delimiter, de-dent the line to the left
401
+ margin."
402
+ (interactive "*P")
403
+ (self-insert-command (prefix-numeric-value arg))
404
+ (save-excursion
405
+ (beginning-of-line)
406
+ (when (and (not arg) (looking-at yaml-document-delimiter-re))
407
+ (delete-horizontal-space))))
408
+
409
+ (defun yaml-narrow-to-block-literal ()
410
+ "Narrow the buffer to block literal if the point is in it,
411
+ otherwise do nothing."
412
+ (interactive)
413
+ (save-excursion
414
+ (goto-char (point-at-bol))
415
+ (while (and (looking-at-p yaml-blank-line-re) (not (bobp)))
416
+ (forward-line -1))
417
+ (let ((nlines yaml-block-literal-search-lines)
418
+ (min-level (current-indentation))
419
+ beg)
420
+ (forward-line -1)
421
+ (while (and (/= nlines 0)
422
+ (/= min-level 0)
423
+ (not (looking-at-p yaml-block-literal-re))
424
+ (not (bobp)))
425
+ (setq nlines (1- nlines))
426
+ (unless (looking-at-p yaml-blank-line-re)
427
+ (setq min-level (min min-level (current-indentation))))
428
+ (forward-line -1))
429
+ (when (and (< (current-indentation) min-level)
430
+ (looking-at-p yaml-block-literal-re))
431
+ (setq min-level (current-indentation))
432
+ (forward-line)
433
+ (setq beg (point))
434
+ (while (and (not (eobp))
435
+ (or (looking-at-p yaml-blank-line-re)
436
+ (> (current-indentation) min-level)))
437
+ (forward-line))
438
+ (narrow-to-region beg (point))))))
439
+
440
+ (defun yaml-fill-paragraph (&optional justify region)
441
+ "Fill paragraph.
442
+ This behaves as `fill-paragraph' except that filling does not
443
+ cross boundaries of block literals."
444
+ (interactive "*P")
445
+ (save-restriction
446
+ (yaml-narrow-to-block-literal)
447
+ (let ((fill-paragraph-function nil))
448
+ (fill-paragraph justify region))))
449
+
450
+ (defun yaml-set-imenu-generic-expression ()
451
+ (make-local-variable 'imenu-generic-expression)
452
+ (make-local-variable 'imenu-create-index-function)
453
+ (setq imenu-create-index-function 'imenu-default-create-index-function)
454
+ (setq imenu-generic-expression yaml-imenu-generic-expression))
455
+
456
+ (add-hook 'yaml-mode-hook 'yaml-set-imenu-generic-expression)
457
+
458
+
459
+ (defun yaml-mode-version ()
460
+ "Display version of `yaml-mode'."
461
+ (interactive)
462
+ (message "yaml-mode %s" yaml-mode-version)
463
+ yaml-mode-version)
464
+
465
+ ;;;###autoload
466
+ (add-to-list 'auto-mode-alist '("\\.\\(e?ya?\\|ra\\)ml\\'" . yaml-mode))
467
+
468
+ (provide 'yaml-mode)
469
+
470
+ ;;; yaml-mode.el ends here
@@ -0,0 +1,25 @@
1
+ This is a major mode for editing files in the YAML data
2
+ serialization format. It was initially developed by Yoshiki
3
+ Kurihara and many features were added by Marshall Vandegrift. As
4
+ YAML and Python share the fact that indentation determines
5
+ structure, this mode provides indentation and indentation command
6
+ behavior very similar to that of python-mode.
7
+
8
+ Installation:
9
+
10
+ To install, just drop this file into a directory in your
11
+ `load-path' and (optionally) byte-compile it. To automatically
12
+ handle files ending in '.yml', add something like:
13
+
14
+ (require 'yaml-mode)
15
+ (add-to-list 'auto-mode-alist '("\\.yml\\'" . yaml-mode))
16
+
17
+ to your .emacs file.
18
+
19
+ Unlike python-mode, this mode follows the Emacs convention of not
20
+ binding the ENTER key to `newline-and-indent'. To get this
21
+ behavior, add the key definition to `yaml-mode-hook':
22
+
23
+ (add-hook 'yaml-mode-hook
24
+ '(lambda ()
25
+ (define-key yaml-mode-map "\C-m" 'newline-and-indent)))
@@ -0,0 +1 @@
1
+ *.elc
@@ -0,0 +1,2 @@
1
+ Natalie Weizenbaum <nex342@gmail.com> Nathan Weizenbaum <nex342@gmail.com>
2
+ Natalie Weizenbaum <nex342@gmail.com> Nathan Weizenbaum <nweiz@google.com>
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2006-2009 Hampton Catlin, Natalie Weizenbaum, and Chris Eppstein
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,47 @@
1
+ # haml-mode for Emacs
2
+
3
+ `haml-mode` is an Emacs major mode for use with
4
+ [HAML](http://haml.info/) source files.
5
+
6
+ It provides syntax highlighting and support for syntax-aware
7
+ indentation.
8
+
9
+ Support for syntax checking via flymake is available separately: see
10
+ [flymake-haml](https://github.com/purcell/flymake-haml).
11
+
12
+ ## Installation
13
+
14
+ ### Via ELPA (recommended)
15
+
16
+ If you're an Emacs 24 user or you have a recent version of
17
+ `package.el` you can install `haml-mode` from the
18
+ [MELPA](http://melpa.org) or
19
+ [Marmalade](http://marmalade-repo.org) package repositories.
20
+
21
+ ### Manually
22
+
23
+ Ensure `haml-mode.el` is in a directory on your load-path, and
24
+ add the following to your `~/.emacs` or `~/.emacs.d/init.el`:
25
+
26
+ ``` lisp
27
+ (require 'haml-mode)
28
+ ```
29
+
30
+ You will also need to ensure `ruby-mode` is installed: the version in
31
+ Emacs 24 is sufficient.
32
+
33
+ ## Optional functionality
34
+
35
+ Certain nested `:filter` blocks are syntax-highlighted if additional
36
+ libraries are available. Emacs 24's `js` library will be used for
37
+ `:javascript` blocks, while `markdown-mode` and `textile-mode` will be
38
+ used for `:markdown` and `:textile` blocks respectively.
39
+
40
+
41
+ ## About
42
+
43
+ Author: Natalie Weizenbaum
44
+
45
+ Maintainer: [Steve Purcell](https://github.com/purcell) <steve at sanityinc dot com>
46
+
47
+ Homepage: https://github.com/nex3/haml-mode