lib/textbringer/commands/buffers.rb in textbringer-0.3.2 vs lib/textbringer/commands/buffers.rb in textbringer-1.0.0
- old
+ new
@@ -242,7 +242,29 @@
buffer.skip_re_backward(/[ \t]/)
buffer.delete_region(buffer.point, pos)
buffer.insert(" ")
buffer.backward_char
end
+
+ define_command(:mark_whole_buffer,
+ doc: <<~EOD) do
+ Put point at beginning and mark at end of buffer.
+ EOD
+ buffer = Buffer.current
+ buffer.push_mark
+ buffer.push_mark(buffer.point_max)
+ buffer.beginning_of_buffer
+ end
+
+ define_command(:zap_to_char,
+ doc: <<~EOD) do
+ Kill up to and including count-th occurrence of char.
+ EOD
+ |char = read_char, count: number_prefix_arg|
+
+ buffer = Buffer.current
+ s = buffer.point
+ e = buffer.re_search_forward(Regexp.quote(char), count: count)
+ buffer.kill_region(s, e)
+ end
end
end