lib/textbringer/commands/windows.rb in textbringer-0.1.9 vs lib/textbringer/commands/windows.rb in textbringer-0.2.0

- old
+ new

@@ -80,24 +80,38 @@ else raise EditorError, "No such buffer: #{buffer}" end end + define_command(:bury_buffer, doc: <<~EOD) do + Put buffer at the end of the buffer list. + EOD + |buffer = Buffer.current| + if buffer.is_a?(String) + buffer = Buffer[buffer] + end + Buffer.bury(buffer) + Window.current.buffer = Buffer.current + end + + define_command(:unbury_buffer, doc: <<~EOD) do + Switch to the last buffer in the buffer list. + EOD + switch_to_buffer(Buffer.last) + end + define_command(:kill_buffer, doc: "Kill buffer.") do |buffer = read_buffer("Kill buffer: ", default: Buffer.current.name)| if buffer.is_a?(String) buffer = Buffer[buffer] end if buffer.modified? next unless yes_or_no?("The last change is not saved; kill anyway?") message("Arioch! Arioch! Blood and souls for my Lord Arioch!") end buffer.kill - if Buffer.count == 0 - buffer = Buffer.new_buffer("*scratch*") - switch_to_buffer(buffer) - elsif Buffer.current.nil? - switch_to_buffer(Buffer.last) + if Buffer.current.nil? + switch_to_buffer(Buffer.other) end end end end