class Mournmail::SearchResultMode

Constants

SEARCH_RESULT_MODE_MAP

Public Class Methods

new(buffer) click to toggle source
Calls superclass method Mournmail::SummaryMode::new
# File lib/mournmail/search_result_mode.rb, line 24
def initialize(buffer)
  super(buffer)
  buffer.keymap = SEARCH_RESULT_MODE_MAP
end

Private Instance Methods

current_message() click to toggle source
# File lib/mournmail/search_result_mode.rb, line 135
def current_message
  message = @buffer[:messages][@buffer.current_line]
  if message.nil?
    raise EditorError, "No message found"
  end
  message
end
next_message() click to toggle source
# File lib/mournmail/search_result_mode.rb, line 127
def next_message
  @buffer.end_of_line
  if @buffer.end_of_buffer?
    raise EditorError, "No more mail"
  end
  @buffer.forward_line
end
read_current_mail() click to toggle source
# File lib/mournmail/search_result_mode.rb, line 119
def read_current_mail
  message = @buffer[:messages][@buffer.current_line]
  if message.nil?
    raise EditorError, "No message found"
  end
  [Mail.new(Mournmail.read_mail_cache(message._key)), false]
end
scroll_up_or_current_number() click to toggle source
# File lib/mournmail/search_result_mode.rb, line 96
def scroll_up_or_current_number
  begin
    num = @buffer.current_line
    if num == @buffer[:message_number]
      window = Mournmail.message_window
      if window.buffer.name == "*message*"
        old_window = Window.current
        begin
          Window.current = window
          scroll_up
          return nil
        ensure
          Window.current = old_window
        end
      end
    end
    num
  rescue RangeError # may be raised by scroll_up
    next_message
    retry
  end
end