Module: LangHelp::DisplayResult

Included in:
FindXXX, LangHelp
Defined in:
lib/el4r/emacsruby/langhelp.rb

Instance Method Summary collapse

Instance Method Details

#display_result(x = {}) ⇒ Object

keyword of x: :line / :anchor



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/el4r/emacsruby/langhelp.rb', line 58

def display_result(x={})
  buf = nil
  pt = nil
  with(:save_window_excursion) do
    yield
    buf = current_buffer
    if x[:line]
      goto_char 1
      # TODO: write test for lineno
      if Fixnum === x[:line]
        forward_line x[:line]-1
      else
        search_line x[:line]
      end
    elsif x[:anchor]
      search_anchor x[:anchor]
    elsif x[:preserve]
      #
    elsif !x[:w3m]
      goto_char 1
    end
    pt = point
  end
  display_result_buffer buf, pt, x
  buf
end

#display_result_buffer(buf, pt, x) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/el4r/emacsruby/langhelp.rb', line 42

def display_result_buffer(buf, pt, x)
  #    display_buffer buf
  one_window_p and split_window
  let(:pop_up_windows, true) { pop_to_buffer buf }
  goto_char pt
  
  recenter((elvar.langhelp_centering || x[:centering]) ? [1] : 0)
  if x[:flash] || elvar.langhelp_flash
    flash_line
  end

  sit_for 0
  other_window 1 unless elvar.langhelp_edit
end

#flash_lineObject



33
34
35
36
37
38
39
40
# File 'lib/el4r/emacsruby/langhelp.rb', line 33

def flash_line
  if fboundp :make_overlay
    ovl = make_overlay point_at_bol, point_at_eol
    duration = 1
    overlay_put ovl, :face, :highlight
    run_at_time duration, nil, :delete_overlay, ovl
  end
end

#search_anchor(anchor) ⇒ Object



28
29
30
31
# File 'lib/el4r/emacsruby/langhelp.rb', line 28

def search_anchor(anchor)
  goto_char 1
  search_forward(format(elvar.ee_anchor_format,anchor), nil, true) and forward_line 0
end

#search_line(line) ⇒ Object



24
25
26
# File 'lib/el4r/emacsruby/langhelp.rb', line 24

def search_line(line)
  search_forward "\n#{line}\n", nil, true and previous_line 1
end