ruby_learner 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/docs/thesis/competing_services.org +21 -0
  4. data/docs/thesis/manual.org +55 -0
  5. data/docs/thesis/mid_term.pptx +0 -0
  6. data/lib/ruby_learner/common.rb +45 -0
  7. data/lib/ruby_learner/ruby_learner.rb +9 -17
  8. data/lib/ruby_learner/sequential_main.rb +146 -0
  9. data/lib/ruby_learner/typing_practice.rb +82 -10
  10. data/lib/ruby_learner/version.rb +1 -1
  11. data/workshop/emacs.d/init.el +1 -76
  12. data/workshop/emacs.d/ruby_learner_init.el +0 -76
  13. metadata +7 -83
  14. data/lib/ruby_learner/methods.rb +0 -290
  15. data/workshop/emacs.d/#init# +0 -1
  16. data/workshop/emacs.d/ac-comphist.dat +0 -50
  17. data/workshop/emacs.d/cp5022x.el +0 -156
  18. data/workshop/emacs.d/elpa/archives/gnu/archive-contents +0 -1240
  19. data/workshop/emacs.d/elpa/archives/melpa/archive-contents +0 -2
  20. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/auto-complete-autoloads.el +0 -65
  21. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/auto-complete-config.el +0 -551
  22. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/auto-complete-config.elc +0 -0
  23. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/auto-complete-pkg.el +0 -6
  24. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/auto-complete.el +0 -2164
  25. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/auto-complete.elc +0 -0
  26. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/ada-mode +0 -72
  27. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/c++-mode +0 -99
  28. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/c-mode +0 -55
  29. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/caml-mode +0 -231
  30. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/clojure-mode +0 -580
  31. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/clojurescript-mode +0 -475
  32. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/coq-mode +0 -278
  33. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/css-mode +0 -874
  34. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/erlang-mode +0 -216
  35. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/ess-julia-mode +0 -37
  36. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/go-mode +0 -25
  37. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/haskell-mode +0 -679
  38. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/java-mode +0 -53
  39. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/js-mode +0 -148
  40. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/julia-mode +0 -37
  41. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/lua-mode +0 -21
  42. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/nim-mode +0 -70
  43. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/objc-mode +0 -161
  44. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/octave-mode +0 -46
  45. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/php-mode +0 -6144
  46. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/python-mode +0 -379
  47. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/qml-mode +0 -183
  48. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/ruby-mode +0 -181
  49. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/scala-mode +0 -1347
  50. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/scheme-mode +0 -216
  51. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/sclang-mode +0 -1481
  52. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/sh-mode +0 -182
  53. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/swift-mode +0 -87
  54. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/tcl-mode +0 -172
  55. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/ts-mode +0 -797
  56. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/tuareg-mode +0 -231
  57. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/verilog-mode +0 -313
  58. data/workshop/emacs.d/elpa/better-defaults-20170613.2104/better-defaults-autoloads.el +0 -16
  59. data/workshop/emacs.d/elpa/better-defaults-20170613.2104/better-defaults-pkg.el +0 -2
  60. data/workshop/emacs.d/elpa/better-defaults-20170613.2104/better-defaults.el +0 -90
  61. data/workshop/emacs.d/elpa/better-defaults-20170613.2104/better-defaults.elc +0 -0
  62. data/workshop/emacs.d/elpa/haml-mode-20170923.2153/haml-mode-autoloads.el +0 -26
  63. data/workshop/emacs.d/elpa/haml-mode-20170923.2153/haml-mode-pkg.el +0 -2
  64. data/workshop/emacs.d/elpa/haml-mode-20170923.2153/haml-mode.el +0 -877
  65. data/workshop/emacs.d/elpa/haml-mode-20170923.2153/haml-mode.elc +0 -0
  66. data/workshop/emacs.d/elpa/haml-mode-readme.txt +0 -8
  67. data/workshop/emacs.d/elpa/material-theme-20171123.1040/material-light-theme.el +0 -918
  68. data/workshop/emacs.d/elpa/material-theme-20171123.1040/material-light-theme.elc +0 -0
  69. data/workshop/emacs.d/elpa/material-theme-20171123.1040/material-theme-autoloads.el +0 -32
  70. data/workshop/emacs.d/elpa/material-theme-20171123.1040/material-theme-pkg.el +0 -8
  71. data/workshop/emacs.d/elpa/material-theme-20171123.1040/material-theme.el +0 -912
  72. data/workshop/emacs.d/elpa/material-theme-20171123.1040/material-theme.elc +0 -0
  73. data/workshop/emacs.d/elpa/ox-bibtex-chinese-readme.txt +0 -21
  74. data/workshop/emacs.d/elpa/popup-20160709.729/popup-autoloads.el +0 -15
  75. data/workshop/emacs.d/elpa/popup-20160709.729/popup-pkg.el +0 -2
  76. data/workshop/emacs.d/elpa/popup-20160709.729/popup.el +0 -1432
  77. data/workshop/emacs.d/elpa/popup-20160709.729/popup.elc +0 -0
  78. data/workshop/emacs.d/elpa/yaml-mode-20180212.1556/yaml-mode-autoloads.el +0 -33
  79. data/workshop/emacs.d/elpa/yaml-mode-20180212.1556/yaml-mode-pkg.el +0 -2
  80. data/workshop/emacs.d/elpa/yaml-mode-20180212.1556/yaml-mode.el +0 -470
  81. data/workshop/emacs.d/elpa/yaml-mode-20180212.1556/yaml-mode.elc +0 -0
  82. data/workshop/emacs.d/elpa/yaml-mode-readme.txt +0 -25
  83. data/workshop/emacs.d/haml-mode-master/.gitignore +0 -1
  84. data/workshop/emacs.d/haml-mode-master/.mailmap +0 -2
  85. data/workshop/emacs.d/haml-mode-master/MIT-LICENSE +0 -20
  86. data/workshop/emacs.d/haml-mode-master/README.md +0 -47
  87. data/workshop/emacs.d/haml-mode-master/haml-mode.el +0 -887
  88. data/workshop/emacs.d/iceberg_theme.el +0 -202
  89. data/workshop/emacs.d/init-open-recentf.el +0 -133
  90. data/workshop/emacs.d/install-elisp.el +0 -366
  91. data/workshop/emacs.d/notes +0 -12
  92. data/workshop/emacs.d/processing-mode/processing-mode.el +0 -275
  93. data/workshop/emacs.d/recentf +0 -31
  94. data/workshop/emacs.d/wiki-mode/wiki.el +0 -976
@@ -1,33 +0,0 @@
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
@@ -1,2 +0,0 @@
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"))
@@ -1,470 +0,0 @@
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