lib/textbringer/commands/misc.rb in textbringer-0.1.8 vs lib/textbringer/commands/misc.rb in textbringer-0.1.9
- old
+ new
@@ -160,12 +160,11 @@
def current_prefix_arg
Controller.current.current_prefix_arg
end
- def number_prefix_arg
- arg = current_prefix_arg
+ def prefix_numeric_value(arg)
case arg
when Integer
arg
when Array
arg.first
@@ -174,10 +173,14 @@
else
1
end
end
+ def number_prefix_arg
+ prefix_numeric_value(current_prefix_arg)
+ end
+
define_command(:digit_argument) do
|arg = current_prefix_arg|
n = Controller.current.last_key.to_i
Controller.current.prefix_arg =
case arg
@@ -221,9 +224,47 @@
end
end
define_command(:recursive_edit) do
Controller.current.recursive_edit
+ end
+
+ def goto_global_mark
+ global_mark_ring = Buffer.global_mark_ring
+ mark = yield(global_mark_ring)
+ if mark.buffer&.current? && Buffer.current.point_at_mark?(mark)
+ mark = yield(global_mark_ring)
+ end
+ if mark.detached?
+ find_file(mark.file_name)
+ goto_char(mark.location)
+ else
+ switch_to_buffer(mark.buffer)
+ mark.buffer.point_to_mark(mark)
+ end
+ end
+ private :goto_global_mark
+
+ define_command(:next_global_mark) do
+ if Buffer.global_mark_ring.empty?
+ raise EditorError, "Global mark ring is empty"
+ end
+ if Buffer.current.push_global_mark
+ Buffer.global_mark_ring.pop
+ end
+ goto_global_mark do |mark_ring|
+ mark_ring.pop
+ end
+ end
+
+ define_command(:previous_global_mark) do
+ if Buffer.global_mark_ring.empty?
+ raise EditorError, "Global mark ring is empty"
+ end
+ Buffer.current.push_global_mark
+ goto_global_mark do |mark_ring|
+ mark_ring.rotate(-1)
+ end
end
define_command(:shell_execute) do
|cmd = read_from_minibuffer("Shell execute: "),
buffer_name: "*Shell output*",