textbringer 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '009c68bcdc928faff20b7ca1b75f92b21641dc6d29e392a05a279267418983d1'
4
- data.tar.gz: cad85dfebd2dc1b70cdbf9212bcda296bcde8204e529b0d82ce1663434a05d4b
3
+ metadata.gz: 57f1c5253fdfca677d4cf620a4577823054202a3f58c7dcb42fd2575cbf69110
4
+ data.tar.gz: 4aaea98c3f0e310c94dd339a0f8ef15e0168aff3166606cb117592c96bcf9401
5
5
  SHA512:
6
- metadata.gz: 4923385439037b9ce5aa099a029f9ca6a3bc87205f85a74febaf165c3e512501303ad25c86cdc73191bf1fcd9cf9faa15b9633996bd1efdc69bb231fba781afe
7
- data.tar.gz: 9a624d55143b47100a6fc9a538d29c9f1151d7c6c38d3fdb4865739fd8d2b7a9c76bda2f8a29a6921ddc9e9e8cd8e5c73f1c25031fc9244e81da3547946559a4
6
+ metadata.gz: 8a15f03fc588b2f6cb8f8ed899273903ad0433ea01cfab84223df60afe6bc8afc01a2dcef543730f4704783becdefcd4ab00538c63bd37017c4a7cd6e78b5f57
7
+ data.tar.gz: d1f7f90da2441ff8112f3289dcebb928201060bd3841fb8be82876a4dfeda057cab9e9153c9f69ff588716fa5ce4b65d9880229e5a2d056aab44ece893d39279
data/CHANGES.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## 1.0.2
2
+
3
+ * Add isearch_quoted_insert.
4
+ * Use M- notation instead of ESC in define_key and help.
5
+ * Add indent_new_comment_line_command.
6
+ * Add find_alternate_file.
7
+ * Fix indentation bugs in the Ruby mode.
8
+
1
9
  ## 1.0.1
2
10
 
3
11
  * Support pattern matching in the Ruby mode.
@@ -11,12 +11,12 @@ module Commands
11
11
  (ENV["DISPLAY"] && system("which xclip > /dev/null 2>&1"))
12
12
 
13
13
  if CLIPBOARD_AVAILABLE
14
- GLOBAL_MAP.define_key("\ew", :clipboard_copy_region)
14
+ GLOBAL_MAP.define_key("\M-w", :clipboard_copy_region)
15
15
  GLOBAL_MAP.define_key("\C-w", :clipboard_kill_region)
16
16
  GLOBAL_MAP.define_key(?\C-k, :clipboard_kill_line)
17
- GLOBAL_MAP.define_key("\ed", :clipboard_kill_word)
17
+ GLOBAL_MAP.define_key("\M-d", :clipboard_kill_word)
18
18
  GLOBAL_MAP.define_key("\C-y", :clipboard_yank)
19
- GLOBAL_MAP.define_key("\ey", :clipboard_yank_pop)
19
+ GLOBAL_MAP.define_key("\M-y", :clipboard_yank_pop)
20
20
  end
21
21
 
22
22
  define_command(:clipboard_copy_region, doc: <<~EOD) do
@@ -49,12 +49,12 @@ module Commands
49
49
  when /\A\d+\z/
50
50
  push_tag_mark_and_find_file(file)
51
51
  goto_line(addr.to_i)
52
- when %r'\A/\^(.*)\$/\z'
52
+ when %r'\A/\^(.*?)(\$)?/\z'
53
+ re = "^" + Regexp.quote($1.gsub(/\\([\\\/])/, "\\1")) + $2.to_s
53
54
  push_tag_mark_and_find_file(file)
54
55
  beginning_of_buffer
55
56
  n.times do
56
- s = Regexp.quote($1.gsub(/\\([\\\/])/, "\\1"))
57
- re_search_forward("^" + s + "$")
57
+ re_search_forward(re)
58
58
  end
59
59
  beginning_of_line
60
60
  when %r'\A\?\^(.*)\$\?\z'
@@ -91,7 +91,7 @@ def dabbrev_regexp(stem, candidates)
91
91
  using DabbrevExtension
92
92
 
93
93
  module Commands
94
- GLOBAL_MAP.define_key("\e/", :dabbrev_expand_command)
94
+ GLOBAL_MAP.define_key("\M-/", :dabbrev_expand_command)
95
95
 
96
96
  define_command(:dabbrev_expand_command) do
97
97
  contd = Controller.current.last_command == :dabbrev_expand_command
@@ -124,5 +124,11 @@ module Commands
124
124
  File.dirname(Buffer.current.file_name))|
125
125
  Dir.chdir(dir_name)
126
126
  end
127
+
128
+ define_command(:find_alternate_file, doc: "Find an alternate file.") do
129
+ |file_name = read_file_name("Find alternate file: ",
130
+ default: Buffer.current.file_name)|
131
+ find_file(file_name)
132
+ end
127
133
  end
128
134
  end
@@ -1,6 +1,6 @@
1
1
  module Textbringer
2
2
  module Commands
3
- ISEARCH_MODE_MAP = Keymap.new
3
+ define_keymap :ISEARCH_MODE_MAP
4
4
  (?\x20..?\x7e).each do |c|
5
5
  ISEARCH_MODE_MAP.define_key(c, :isearch_printing_char)
6
6
  end
@@ -19,6 +19,7 @@ module Commands
19
19
  ISEARCH_MODE_MAP.define_key(?\C-w, :isearch_yank_word_or_char)
20
20
  ISEARCH_MODE_MAP.define_key(?\C-m, :isearch_exit)
21
21
  ISEARCH_MODE_MAP.define_key(?\C-g, :isearch_abort)
22
+ ISEARCH_MODE_MAP.define_key(?\C-q, :isearch_quoted_insert)
22
23
 
23
24
  ISEARCH_STATUS = {
24
25
  forward: true,
@@ -114,6 +115,14 @@ def isearch_done
114
115
  end
115
116
  end
116
117
 
118
+ define_command(:isearch_quoted_insert, doc: <<~EOD) do
119
+ Read a character, and add it to the search string and search.
120
+ EOD
121
+ c = Controller.current.read_event
122
+ ISEARCH_STATUS[:string].concat(c)
123
+ isearch_search
124
+ end
125
+
117
126
  def isearch_search
118
127
  forward = ISEARCH_STATUS[:forward]
119
128
  options = if /\A[A-Z]/.match?(ISEARCH_STATUS[:string])
@@ -139,7 +139,7 @@ def complete_minibuffer_with_string(s)
139
139
  end
140
140
  end
141
141
 
142
- UNIVERSAL_ARGUMENT_MAP = Keymap.new
142
+ define_keymap :UNIVERSAL_ARGUMENT_MAP
143
143
  (?0..?9).each do |c|
144
144
  UNIVERSAL_ARGUMENT_MAP.define_key(c, :digit_argument)
145
145
  GLOBAL_MAP.define_key("\e#{c}", :digit_argument)
@@ -1,3 +1,11 @@
1
+ class Module
2
+ def define_keymap(name)
3
+ unless const_defined?(name, false)
4
+ const_set(name, Textbringer::Keymap.new)
5
+ end
6
+ end
7
+ end
8
+
1
9
  module Textbringer
2
10
  class Keymap
3
11
  include Enumerable
@@ -72,7 +80,16 @@ def self.key_name(key)
72
80
  end
73
81
 
74
82
  def self.key_sequence_string(key_sequence)
75
- key_sequence.map { |key| key_name(key) }.join(" ")
83
+ ks = key_sequence.dup
84
+ key_names = []
85
+ while key = ks.shift
86
+ if key == "\e" && !ks.empty?
87
+ key_names.push("M-" + key_name(ks.shift))
88
+ else
89
+ key_names.push(key_name(key))
90
+ end
91
+ end
92
+ key_names.join(" ")
76
93
  end
77
94
 
78
95
  private
@@ -82,7 +99,7 @@ def kbd(key)
82
99
  when Symbol
83
100
  [key]
84
101
  when String
85
- key.chars
102
+ key.b.gsub(/[\x80-\xff]/n) { |c| "\e" + (c.ord & 0x7f).chr }.chars
86
103
  when Array
87
104
  key
88
105
  else
@@ -91,17 +108,17 @@ def kbd(key)
91
108
  end
92
109
  end
93
110
 
94
- GLOBAL_MAP = Keymap.new
111
+ define_keymap :GLOBAL_MAP
95
112
  GLOBAL_MAP.define_key(:resize, :resize_window)
96
113
  GLOBAL_MAP.define_key(:right, :forward_char)
97
114
  GLOBAL_MAP.define_key(?\C-f, :forward_char)
98
115
  GLOBAL_MAP.define_key(:left, :backward_char)
99
116
  GLOBAL_MAP.define_key(?\C-b, :backward_char)
100
- GLOBAL_MAP.define_key("\ef", :forward_word)
101
- GLOBAL_MAP.define_key("\eb", :backward_word)
102
- GLOBAL_MAP.define_key("\egc", :goto_char)
103
- GLOBAL_MAP.define_key("\egg", :goto_line)
104
- GLOBAL_MAP.define_key("\eg\eg", :goto_line)
117
+ GLOBAL_MAP.define_key("\M-f", :forward_word)
118
+ GLOBAL_MAP.define_key("\M-b", :backward_word)
119
+ GLOBAL_MAP.define_key("\M-gc", :goto_char)
120
+ GLOBAL_MAP.define_key("\M-gg", :goto_line)
121
+ GLOBAL_MAP.define_key("\M-g\M-g", :goto_line)
105
122
  GLOBAL_MAP.define_key(:down, :next_line)
106
123
  GLOBAL_MAP.define_key(?\C-n, :next_line)
107
124
  GLOBAL_MAP.define_key(:up, :previous_line)
@@ -115,8 +132,8 @@ def kbd(key)
115
132
  GLOBAL_MAP.define_key(:home, :beginning_of_line)
116
133
  GLOBAL_MAP.define_key(?\C-e, :end_of_line)
117
134
  GLOBAL_MAP.define_key(:end, :end_of_line)
118
- GLOBAL_MAP.define_key("\e<", :beginning_of_buffer)
119
- GLOBAL_MAP.define_key("\e>", :end_of_buffer)
135
+ GLOBAL_MAP.define_key("\M-<", :beginning_of_buffer)
136
+ GLOBAL_MAP.define_key("\M->", :end_of_buffer)
120
137
  (?\x20..?\x7e).each do |c|
121
138
  GLOBAL_MAP.define_key(c, :self_insert)
122
139
  end
@@ -124,15 +141,15 @@ def kbd(key)
124
141
  GLOBAL_MAP.define_key(?\C-q, :quoted_insert)
125
142
  GLOBAL_MAP.define_key("\C-@", :set_mark_command)
126
143
  GLOBAL_MAP.define_key("\C-x\C-@", :pop_global_mark)
127
- GLOBAL_MAP.define_key("\e*", :next_global_mark)
128
- GLOBAL_MAP.define_key("\e?", :previous_global_mark)
144
+ GLOBAL_MAP.define_key("\M-*", :next_global_mark)
145
+ GLOBAL_MAP.define_key("\M-?", :previous_global_mark)
129
146
  GLOBAL_MAP.define_key("\C-x\C-x", :exchange_point_and_mark)
130
- GLOBAL_MAP.define_key("\ew", :copy_region)
147
+ GLOBAL_MAP.define_key("\M-w", :copy_region)
131
148
  GLOBAL_MAP.define_key(?\C-w, :kill_region)
132
149
  GLOBAL_MAP.define_key(?\C-k, :kill_line)
133
- GLOBAL_MAP.define_key("\ed", :kill_word)
150
+ GLOBAL_MAP.define_key("\M-d", :kill_word)
134
151
  GLOBAL_MAP.define_key(?\C-y, :yank)
135
- GLOBAL_MAP.define_key("\ey", :yank_pop)
152
+ GLOBAL_MAP.define_key("\M-y", :yank_pop)
136
153
  GLOBAL_MAP.define_key(?\C-_, :undo)
137
154
  GLOBAL_MAP.define_key("\C-xu", :undo)
138
155
  GLOBAL_MAP.define_key("\C-x\C-_", :redo_command)
@@ -140,14 +157,14 @@ def kbd(key)
140
157
  GLOBAL_MAP.define_key("\C-j", :newline)
141
158
  GLOBAL_MAP.define_key("\C-m", :newline)
142
159
  GLOBAL_MAP.define_key("\C-o", :open_line)
143
- GLOBAL_MAP.define_key("\em", :back_to_indentation)
144
- GLOBAL_MAP.define_key("\e^", :delete_indentation)
160
+ GLOBAL_MAP.define_key("\M-m", :back_to_indentation)
161
+ GLOBAL_MAP.define_key("\M-^", :delete_indentation)
145
162
  GLOBAL_MAP.define_key("\C-xh", :mark_whole_buffer)
146
- GLOBAL_MAP.define_key("\ez", :zap_to_char)
163
+ GLOBAL_MAP.define_key("\M-z", :zap_to_char)
147
164
  GLOBAL_MAP.define_key("\C-l", :recenter)
148
165
  GLOBAL_MAP.define_key("\C-v", :scroll_up)
149
166
  GLOBAL_MAP.define_key(:npage, :scroll_up)
150
- GLOBAL_MAP.define_key("\ev", :scroll_down)
167
+ GLOBAL_MAP.define_key("\M-v", :scroll_down)
151
168
  GLOBAL_MAP.define_key(:ppage, :scroll_down)
152
169
  GLOBAL_MAP.define_key("\C-x0", :delete_window)
153
170
  GLOBAL_MAP.define_key("\C-x1", :delete_other_windows)
@@ -158,6 +175,7 @@ def kbd(key)
158
175
  GLOBAL_MAP.define_key("\C-x\C-c", :exit_textbringer)
159
176
  GLOBAL_MAP.define_key("\C-z", :suspend_textbringer)
160
177
  GLOBAL_MAP.define_key("\C-x\C-f", :find_file)
178
+ GLOBAL_MAP.define_key("\C-x\C-v", :find_alternate_file)
161
179
  GLOBAL_MAP.define_key("\C-xb", :switch_to_buffer)
162
180
  GLOBAL_MAP.define_key("\C-x\C-b", :list_buffers)
163
181
  GLOBAL_MAP.define_key("\C-x\C-s", :save_buffer)
@@ -166,15 +184,15 @@ def kbd(key)
166
184
  GLOBAL_MAP.define_key("\C-x\C-mf", :set_buffer_file_encoding)
167
185
  GLOBAL_MAP.define_key("\C-x\C-mn", :set_buffer_file_format)
168
186
  GLOBAL_MAP.define_key("\C-x\C-mr", :revert_buffer_with_encoding)
169
- GLOBAL_MAP.define_key("\e.", :find_tag)
170
- GLOBAL_MAP.define_key("\ex", :execute_command)
171
- GLOBAL_MAP.define_key("\e:", :eval_expression)
187
+ GLOBAL_MAP.define_key("\M-.", :find_tag)
188
+ GLOBAL_MAP.define_key("\M-x", :execute_command)
189
+ GLOBAL_MAP.define_key("\M-:", :eval_expression)
172
190
  GLOBAL_MAP.define_key(?\C-u, :universal_argument)
173
191
  GLOBAL_MAP.define_key(?\C-g, :keyboard_quit)
174
192
  GLOBAL_MAP.define_key(?\C-s, :isearch_forward)
175
193
  GLOBAL_MAP.define_key(?\C-r, :isearch_backward)
176
- GLOBAL_MAP.define_key("\e%", :query_replace_regexp)
177
- GLOBAL_MAP.define_key("\e!", :shell_execute)
194
+ GLOBAL_MAP.define_key("\M-%", :query_replace_regexp)
195
+ GLOBAL_MAP.define_key("\M-!", :shell_execute)
178
196
  GLOBAL_MAP.define_key("\C-xr ", :point_to_register)
179
197
  GLOBAL_MAP.define_key("\C-xrj", :jump_to_register)
180
198
  GLOBAL_MAP.define_key("\C-xrx", :copy_to_register)
@@ -188,7 +206,7 @@ def kbd(key)
188
206
  GLOBAL_MAP.define_key("\C-x)", :end_keyboard_macro)
189
207
  GLOBAL_MAP.define_key("\C-xe", :end_and_call_keyboard_macro)
190
208
  GLOBAL_MAP.define_key(:f4, :end_or_call_keyboard_macro)
191
- GLOBAL_MAP.define_key("\eq", :fill_paragraph)
209
+ GLOBAL_MAP.define_key("\M-q", :fill_paragraph)
192
210
  GLOBAL_MAP.define_key([:f1, "b"], :describe_bindings)
193
211
  GLOBAL_MAP.define_key([:f1, "f"], :describe_command)
194
212
  GLOBAL_MAP.define_key([:f1, "k"], :describe_key)
@@ -201,7 +219,7 @@ def kbd(key)
201
219
  end
202
220
  end
203
221
 
204
- MINIBUFFER_LOCAL_MAP = Keymap.new
222
+ define_keymap :MINIBUFFER_LOCAL_MAP
205
223
  MINIBUFFER_LOCAL_MAP.define_key("\C-j", :exit_recursive_edit)
206
224
  MINIBUFFER_LOCAL_MAP.define_key("\C-m", :exit_recursive_edit)
207
225
  MINIBUFFER_LOCAL_MAP.define_key(?\t, :complete_minibuffer)
@@ -2,7 +2,7 @@ module Textbringer
2
2
  class BacktraceMode < Mode
3
3
  define_generic_command :jump_to_source_location
4
4
 
5
- BACKTRACE_MODE_MAP = Keymap.new
5
+ define_keymap :BACKTRACE_MODE_MAP
6
6
  BACKTRACE_MODE_MAP.define_key("\C-m", :jump_to_source_location_command)
7
7
 
8
8
  define_syntax :link, /^\S*?:\d+:(?:\d+:)?/
@@ -1,6 +1,6 @@
1
1
  module Textbringer
2
2
  class BufferListMode < Mode
3
- BUFFER_LIST_MODE_MAP = Keymap.new
3
+ define_keymap :BUFFER_LIST_MODE_MAP
4
4
  BUFFER_LIST_MODE_MAP.define_key("\C-m", :this_window_command)
5
5
 
6
6
  def initialize(buffer)
@@ -34,6 +34,10 @@ class CMode < ProgrammingMode
34
34
  (?: ' (?: [^\\'] | \\ (?:.|\n) )* ' )
35
35
  /x
36
36
 
37
+ def comment_start
38
+ "//"
39
+ end
40
+
37
41
  def initialize(buffer)
38
42
  super(buffer)
39
43
  @buffer[:indent_level] = CONFIG[:c_indent_level]
@@ -2,7 +2,7 @@ module Textbringer
2
2
  class CompletionListMode < Mode
3
3
  define_generic_command :choose_completion
4
4
 
5
- COMPLETION_LIST_MODE_MAP = Keymap.new
5
+ define_keymap :COMPLETION_LIST_MODE_MAP
6
6
  COMPLETION_LIST_MODE_MAP.define_key("\C-m", :choose_completion_command)
7
7
 
8
8
  define_syntax :link, /^.+$/
@@ -2,7 +2,7 @@ module Textbringer
2
2
  class HelpMode < Mode
3
3
  define_generic_command :jump_to_link
4
4
 
5
- HELP_MODE_MAP = Keymap.new
5
+ define_keymap :HELP_MODE_MAP
6
6
  HELP_MODE_MAP.define_key(?\C-m, :jump_to_link_command)
7
7
  HELP_MODE_MAP.define_key(?l, :help_go_back)
8
8
  HELP_MODE_MAP.define_key("\C-c\C-b", :help_go_back)
@@ -10,16 +10,18 @@ class ProgrammingMode < FundamentalMode
10
10
  define_generic_command :backward_definition
11
11
  define_generic_command :compile
12
12
  define_generic_command :toggle_test
13
+ define_generic_command :indent_new_comment_line
13
14
 
14
- PROGRAMMING_MODE_MAP = Keymap.new
15
+ define_keymap :PROGRAMMING_MODE_MAP
15
16
  PROGRAMMING_MODE_MAP.define_key("\t", :indent_line_command)
16
17
  PROGRAMMING_MODE_MAP.define_key("\C-m",
17
18
  :reindent_then_newline_and_indent_command)
18
- PROGRAMMING_MODE_MAP.define_key("\e\C-\\", :indent_region_command)
19
+ PROGRAMMING_MODE_MAP.define_key("\M-\C-\\", :indent_region_command)
19
20
  PROGRAMMING_MODE_MAP.define_key("\C-c\C-n", :forward_definition_command)
20
21
  PROGRAMMING_MODE_MAP.define_key("\C-c\C-p", :backward_definition_command)
21
22
  PROGRAMMING_MODE_MAP.define_key("\C-c\C-c", :compile_command)
22
23
  PROGRAMMING_MODE_MAP.define_key("\C-c\C-t", :toggle_test_command)
24
+ PROGRAMMING_MODE_MAP.define_key("\ej", :indent_new_comment_line_command)
23
25
 
24
26
  def initialize(buffer)
25
27
  super(buffer)
@@ -86,6 +88,26 @@ def indent_region(s = @buffer.mark, e = @buffer.point)
86
88
  end
87
89
  end
88
90
 
91
+ def indent_new_comment_line
92
+ if comment_start.nil?
93
+ @buffer.newline
94
+ return
95
+ end
96
+ s = @buffer.save_excursion {
97
+ @buffer.beginning_of_line
98
+ if @buffer.looking_at?(/[ \t]*#{comment_start}+[ \t]*/)
99
+ @buffer.match_string(0)
100
+ else
101
+ ""
102
+ end
103
+ }
104
+ @buffer.insert("\n" + s)
105
+ end
106
+
107
+ def comment_start
108
+ nil
109
+ end
110
+
89
111
  private
90
112
 
91
113
  def calculate_indentation
@@ -85,6 +85,10 @@ class | module | def | undef | begin | rescue | ensure | end |
85
85
  )
86
86
  /x
87
87
 
88
+ def comment_start
89
+ "#"
90
+ end
91
+
88
92
  def initialize(buffer)
89
93
  super(buffer)
90
94
  @buffer[:indent_level] = CONFIG[:ruby_indent_level]
@@ -173,7 +177,7 @@ def toggle_test
173
177
 
174
178
  private
175
179
 
176
- INDENT_BEG_RE = /^([ \t]*)(class|module|def|if|unless|case|while|until|for|begin|end)\b/
180
+ INDENT_BEG_RE = /^([ \t]*)(class|module|def|if|unless|case|while|until|for|begin)\b/
177
181
 
178
182
  def space_width(s)
179
183
  s.gsub(/\t/, " " * @buffer[:tab_width]).size
@@ -194,6 +198,22 @@ def beginning_of_indentation
194
198
  0
195
199
  end
196
200
 
201
+ def lex(source)
202
+ line_count = source.count("\n")
203
+ s = source
204
+ lineno = 1
205
+ tokens = []
206
+ loop do
207
+ lexer = Ripper::Lexer.new(s, "-", lineno)
208
+ tokens.concat(lexer.lex)
209
+ last_line = tokens.dig(-1, 0, 0)
210
+ return tokens if last_line.nil? || last_line >= line_count
211
+ s = source.sub(/(.*\n?){#{last_line}}/, "")
212
+ return tokens if last_line + 1 <= lineno
213
+ lineno = last_line + 1
214
+ end
215
+ end
216
+
197
217
  def calculate_indentation
198
218
  if @buffer.current_line == 1
199
219
  return 0
@@ -205,7 +225,7 @@ def calculate_indentation
205
225
  base_indentation = beginning_of_indentation
206
226
  start_pos = @buffer.point
207
227
  start_line = @buffer.current_line
208
- tokens = Ripper.lex(@buffer.substring(start_pos, bol_pos))
228
+ tokens = lex(@buffer.substring(start_pos, bol_pos))
209
229
  _, event, text = tokens.last
210
230
  if event == :on_nl
211
231
  _, event, text = tokens[-2]
@@ -217,7 +237,7 @@ def calculate_indentation
217
237
  event == :on_tstring_content
218
238
  return nil
219
239
  end
220
- i = find_nearest_beginning_token(tokens)
240
+ i, extra_end_count = find_nearest_beginning_token(tokens)
221
241
  (line, column), event, = i ? tokens[i] : nil
222
242
  if event == :on_lparen && tokens.dig(i + 1, 1) != :on_ignored_nl
223
243
  return column + 1
@@ -240,7 +260,8 @@ def calculate_indentation
240
260
  end
241
261
  @buffer.goto_char(bol_pos)
242
262
  if line.nil?
243
- indentation = base_indentation
263
+ indentation =
264
+ base_indentation - extra_end_count * @buffer[:indent_level]
244
265
  else
245
266
  indentation = base_indentation + @buffer[:indent_level]
246
267
  end
@@ -293,9 +314,9 @@ def find_nearest_beginning_token(tokens)
293
314
  when "end"
294
315
  stack.push(text)
295
316
  end
296
- when :on_rbrace, :on_rparen, :on_rbracket
317
+ when :on_rbrace, :on_rparen, :on_rbracket, :on_embexpr_end
297
318
  stack.push(text)
298
- when :on_lbrace, :on_lparen, :on_lbracket, :on_tlambeg
319
+ when :on_lbrace, :on_lparen, :on_lbracket, :on_tlambeg, :on_embexpr_beg
299
320
  if stack.empty?
300
321
  return i
301
322
  end
@@ -305,7 +326,7 @@ def find_nearest_beginning_token(tokens)
305
326
  stack.pop
306
327
  end
307
328
  end
308
- return nil
329
+ return nil, stack.size
309
330
  end
310
331
 
311
332
  def find_test_target_path(base, namespace, name)
@@ -238,7 +238,7 @@ def yes_or_no?(prompt)
238
238
  }
239
239
  end
240
240
 
241
- Y_OR_N_MAP = Keymap.new
241
+ define_keymap :Y_OR_N_MAP
242
242
  Y_OR_N_MAP.define_key(?y, :self_insert_and_exit_minibuffer)
243
243
  Y_OR_N_MAP.define_key(?n, :self_insert_and_exit_minibuffer)
244
244
  Y_OR_N_MAP.define_key(?\C-g, :abort_recursive_edit)
@@ -1,3 +1,3 @@
1
1
  module Textbringer
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: textbringer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shugo Maeda
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-11-07 00:00:00.000000000 Z
11
+ date: 2019-12-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: curses
@@ -253,7 +253,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
253
253
  - !ruby/object:Gem::Version
254
254
  version: '0'
255
255
  requirements: []
256
- rubygems_version: 3.1.0.pre2
256
+ rubygems_version: 3.1.2
257
257
  signing_key:
258
258
  specification_version: 4
259
259
  summary: An Emacs-like text editor