Class: Overlay
Overview
Wrapper around the elisp ‘overlay’.
Represents an overlay and has finder methods for getting overlays for more, see www.gnu.org/software/emacs/elisp/html_node/Overlays.html represents an elisp overlay. the Overlay class finder methods for getting overlays – IMPORTANT NOTES:
start/end have been renamed to left/right respectively
Class Method Summary collapse
-
.all ⇒ Object
returns all overlays for current buffer.
-
.at(pos) ⇒ Object
returns all overlays that cover pos.
-
.between(left, right) ⇒ Object
returns all overlays that contain at least one character between left and right empty overlays are included.
- .delete_all ⇒ Object
-
.face(face, options = {}) ⇒ Object
Code Sample: Overlay.face :trailing_whitespace, :what=>:line Apply face to region.
- .find_or_make(left, right) ⇒ Object
-
.find_overlay_by_name(name) ⇒ Object
maybe subclass NamedOverlay what about uniqueness of name?.
-
.make(left, right) ⇒ Object
create elisp overlay and wrap it in a ruby object.
- .menu ⇒ Object
-
.on(left, right) ⇒ Object
returns all overlays that have left and right exactly.
- .overlays_with(left, right, properties = {}) ⇒ Object
- .remove_overlays ⇒ Object
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, val) ⇒ Object
-
#buffer ⇒ Object
returns the buffer that overlay belongs to.
-
#delete ⇒ Object
deletes overlay.
-
#initialize(elisp_overlay) ⇒ Overlay
constructor
A new instance of Overlay.
-
#invisible ⇒ Object
method missing candidate.
- #invisible=(arg) ⇒ Object
- #isearch_open_invisible_temporary ⇒ Object
- #isearch_open_invisible_temporary=(arg) ⇒ Object
-
#left ⇒ Object
returns the position at which overlay starts, as an integer.
-
#properties ⇒ Object
returns a copy of the property list.
-
#right ⇒ Object
returns the position at which overlay ends, as an integer.
-
#to_elisp ⇒ Object
def move end.
Constructor Details
#initialize(elisp_overlay) ⇒ Overlay
Returns a new instance of Overlay.
10 11 12 13 |
# File 'lib/xiki/overlay.rb', line 10 def initialize() # raise TypeError.new("argument must be elisp overlay") if overlayp(elisp_overlay) @overlay = end |
Class Method Details
.all ⇒ Object
returns all overlays for current buffer
39 40 41 |
# File 'lib/xiki/overlay.rb', line 39 def self.all between(View.top, View.bottom) end |
.at(pos) ⇒ Object
returns all overlays that cover pos
49 50 51 52 |
# File 'lib/xiki/overlay.rb', line 49 def self.at(pos) = $el.(pos).to_a .map { |o| Overlay.new(o) } end |
.between(left, right) ⇒ Object
returns all overlays that contain at least one character between left and right empty overlays are included
33 34 35 36 |
# File 'lib/xiki/overlay.rb', line 33 def self.between(left, right) = $el.(left, right).to_a .map { |o| Overlay.new(o) } end |
.delete_all ⇒ Object
93 94 95 96 |
# File 'lib/xiki/overlay.rb', line 93 def self.delete_all $el.(View.top, View.bottom).to_a.each{|o| $el. o} nil end |
.face(face, options = {}) ⇒ Object
Code Sample: Overlay.face :trailing_whitespace, :what=>:line Apply face to region
80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/xiki/overlay.rb', line 80 def self.face(face, ={}) left ||= [:left] right ||= [:right] if [:what] == :line or left.nil? left, right = Line.left, Line.right+1 end o = Overlay.find_or_make(left, right) o[:face] = face o nil end |
.find_or_make(left, right) ⇒ Object
58 59 60 61 62 63 64 65 66 |
# File 'lib/xiki/overlay.rb', line 58 def self.find_or_make(left, right) = on(left, right) if .any? puts "warning: more than 1 overlay" if .size > 1 .first else make(left, right) end end |
.find_overlay_by_name(name) ⇒ Object
maybe subclass NamedOverlay what about uniqueness of name?
70 71 72 |
# File 'lib/xiki/overlay.rb', line 70 def self.(name) # search overlays for all overlays with property name end |
.make(left, right) ⇒ Object
create elisp overlay and wrap it in a ruby object
27 28 29 |
# File 'lib/xiki/overlay.rb', line 27 def self.make(left, right) Overlay.new($el.(left, right)) end |
.menu ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/xiki/overlay.rb', line 15 def self. " - api/ | Make some text have a style @ Overlay.face :underline, :left=>1, :right=>300 | | Remove all overlays @ Overlay.delete_all " end |
.on(left, right) ⇒ Object
returns all overlays that have left and right exactly
44 45 46 |
# File 'lib/xiki/overlay.rb', line 44 def self.on(left, right) between(left, right).select { |o| o.left == left && o.right == right } end |
.overlays_with(left, right, properties = {}) ⇒ Object
54 55 56 |
# File 'lib/xiki/overlay.rb', line 54 def self.(left, right, properties = {}) # implementation needed end |
.remove_overlays ⇒ Object
74 75 76 |
# File 'lib/xiki/overlay.rb', line 74 def self. # implementation needed end |
Instance Method Details
#[](key) ⇒ Object
164 165 166 |
# File 'lib/xiki/overlay.rb', line 164 def [] key $el.(@overlay, key) end |
#[]=(key, val) ⇒ Object
160 161 162 |
# File 'lib/xiki/overlay.rb', line 160 def []= key, val $el.(@overlay, key, val) end |
#buffer ⇒ Object
returns the buffer that overlay belongs to. It returns nil if overlay has been deleted.
99 100 101 |
# File 'lib/xiki/overlay.rb', line 99 def buffer $el. @overlay end |
#delete ⇒ Object
deletes overlay. The overlay continues to exist as a Lisp object, and its property list is unchanged, but it ceases to be attached to the buffer it belonged to, and ceases to have any effect on display. A deleted overlay is not permanently disconnected. You can give it a position in a buffer again by calling move-overlay.
124 125 126 |
# File 'lib/xiki/overlay.rb', line 124 def delete $el. @overlay end |
#invisible ⇒ Object
method missing candidate. name space with ‘set’ or ‘propset’
136 137 138 |
# File 'lib/xiki/overlay.rb', line 136 def invisible $el.(@overlay, :invisible) end |
#invisible=(arg) ⇒ Object
140 141 142 143 144 145 146 |
# File 'lib/xiki/overlay.rb', line 140 def invisible=(arg) if arg $el.(@overlay, :invisible, true) else $el.(@overlay, :invisible, nil) end end |
#isearch_open_invisible_temporary ⇒ Object
148 149 150 |
# File 'lib/xiki/overlay.rb', line 148 def isearch_open_invisible_temporary $el.(@overlay, :isearch_open_invisible_temporary) end |
#isearch_open_invisible_temporary=(arg) ⇒ Object
152 153 154 155 156 157 158 |
# File 'lib/xiki/overlay.rb', line 152 def isearch_open_invisible_temporary=(arg) if arg $el.(@overlay, :isearch_open_invisible_temporary, true) else $el.(@overlay, :isearch_open_invisible_temporary, nil) end end |
#left ⇒ Object
returns the position at which overlay starts, as an integer.
109 110 111 |
# File 'lib/xiki/overlay.rb', line 109 def left $el. @overlay end |
#properties ⇒ Object
returns a copy of the property list.
104 105 106 |
# File 'lib/xiki/overlay.rb', line 104 def properties $el. @overlay end |
#right ⇒ Object
returns the position at which overlay ends, as an integer.
114 115 116 |
# File 'lib/xiki/overlay.rb', line 114 def right $el. @overlay end |
#to_elisp ⇒ Object
def move end
131 132 133 |
# File 'lib/xiki/overlay.rb', line 131 def to_elisp @overlay end |