lib/textbringer/utils.rb in textbringer-1.0.3 vs lib/textbringer/utils.rb in textbringer-1.0.4
- old
+ new
@@ -106,11 +106,11 @@
def show_exception(e)
if e.is_a?(SystemExit) || e.is_a?(SignalException)
raise
end
- if Buffer.current&.name != "*Backtrace*"
+ if !e.is_a?(Quit) && Buffer.current&.name != "*Backtrace*"
buffer = Buffer.find_or_new("*Backtrace*", undo_limit: 0)
if !buffer.mode.is_a?(BacktraceMode)
buffer.apply_mode(BacktraceMode)
end
buffer.read_only = false
@@ -314,11 +314,11 @@
end
end
HOOKS = Hash.new { |h, k| h[k] = [] }
- def add_hook(name, func = Proc.new)
- HOOKS[name].unshift(func)
+ def add_hook(name, func = nil, &block)
+ HOOKS[name].unshift(func || block)
end
def remove_hook(name, func)
HOOKS[name].delete(func)
end