relisp 0.9.1 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +10 -0
- data/Manifest +5 -2
- data/README +3 -4
- data/examples/elisp_master/elisp_master.el +3 -4
- data/examples/elisp_master/ruby_slave +4 -1
- data/lib/relisp/elisp_functions.rb +38 -1
- data/lib/relisp/slaves.rb +74 -29
- data/lib/relisp/type_conversion/editing_types.rb +1178 -0
- data/lib/relisp/{programming_types.rb → type_conversion/programming_types.rb} +56 -11
- data/lib/relisp/type_conversion.rb +60 -0
- data/lib/relisp.rb +3 -4
- data/manual_test/tests.el +72 -0
- data/manual_test/tests.rb +66 -0
- data/src/relisp.el +91 -40
- data/src/relisp.elc +0 -0
- data/test/test_editing_types.rb +455 -14
- data/test/test_elisp_functions.rb +2 -0
- data/test/test_programming_types.rb +42 -20
- data/test/test_slaves.rb +7 -5
- metadata +7 -4
- data/lib/relisp/editing_types.rb +0 -295
data/test/test_slaves.rb
CHANGED
@@ -5,10 +5,12 @@ require 'test/unit' unless defined? $ZENTEST and $ZENTEST
|
|
5
5
|
$:.unshift File.dirname(__FILE__) + "/../lib"
|
6
6
|
require 'relisp'
|
7
7
|
|
8
|
+
EMACS = Relisp::ElispSlave.new unless defined? EMACS
|
9
|
+
|
8
10
|
module TestRelisp
|
9
11
|
class TestElispSlave < Test::Unit::TestCase
|
10
12
|
def setup
|
11
|
-
@emacs =
|
13
|
+
@emacs = EMACS
|
12
14
|
end
|
13
15
|
|
14
16
|
def test_debugging
|
@@ -32,7 +34,7 @@ end
|
|
32
34
|
module TestRelisp
|
33
35
|
class TestSlave < Test::Unit::TestCase
|
34
36
|
def setup
|
35
|
-
@emacs =
|
37
|
+
@emacs = EMACS
|
36
38
|
end
|
37
39
|
|
38
40
|
def test_elisp_eval
|
@@ -40,11 +42,11 @@ module TestRelisp
|
|
40
42
|
assert_equal 3, @emacs.elisp_eval("(+ 1 2)")
|
41
43
|
end
|
42
44
|
|
43
|
-
def
|
44
|
-
@emacs.
|
45
|
+
def test_elisp_exec
|
46
|
+
@emacs.elisp_exec("(setq blah 17)")
|
45
47
|
assert_equal 17, @emacs.elisp_eval(:blah)
|
46
48
|
assert_raise Relisp::ElispError do
|
47
|
-
puts @emacs.
|
49
|
+
puts @emacs.elisp_exec("(relisp-nonsense-function 2)")
|
48
50
|
end
|
49
51
|
|
50
52
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relisp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Don
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-03-10 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -40,10 +40,13 @@ files:
|
|
40
40
|
- examples/elisp_master/ruby_slave
|
41
41
|
- examples/ruby_master/ruby_master_example
|
42
42
|
- lib/relisp.rb
|
43
|
-
- lib/relisp/editing_types.rb
|
44
43
|
- lib/relisp/elisp_functions.rb
|
45
|
-
- lib/relisp/programming_types.rb
|
46
44
|
- lib/relisp/slaves.rb
|
45
|
+
- lib/relisp/type_conversion.rb
|
46
|
+
- lib/relisp/type_conversion/editing_types.rb
|
47
|
+
- lib/relisp/type_conversion/programming_types.rb
|
48
|
+
- manual_test/tests.el
|
49
|
+
- manual_test/tests.rb
|
47
50
|
- setup.rb
|
48
51
|
- src/relisp.el
|
49
52
|
- src/relisp.elc
|
data/lib/relisp/editing_types.rb
DELETED
@@ -1,295 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright (C) 2009 <don@ohspite.net>
|
3
|
-
#
|
4
|
-
# This file is part of Relisp.
|
5
|
-
#
|
6
|
-
# Relisp is free software: you can redistribute it and/or modify it
|
7
|
-
# under the terms of the GNU General Public License as published by
|
8
|
-
# the Free Software Foundation, either version 3 of the License, or
|
9
|
-
# (at your option) any later version.
|
10
|
-
#
|
11
|
-
# Relisp is distributed in the hope that it will be useful, but
|
12
|
-
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14
|
-
# General Public License for more details.
|
15
|
-
#
|
16
|
-
# You should have received a copy of the GNU General Public License
|
17
|
-
# along with this program. If not, see
|
18
|
-
# <http://www.gnu.org/licenses/>.
|
19
|
-
#++
|
20
|
-
#
|
21
|
-
# See the documentation in <tt>programming_types.rb</tt>.
|
22
|
-
#
|
23
|
-
# Elisp editing types as described in the elisp info manual:
|
24
|
-
#
|
25
|
-
# Editing Types
|
26
|
-
#
|
27
|
-
# Buffer Type:: The basic object of editing.
|
28
|
-
# Marker Type:: A position in a buffer.
|
29
|
-
# Window Type:: Buffers are displayed in windows.
|
30
|
-
# Frame Type:: Windows subdivide frames.
|
31
|
-
# Window Configuration Type:: Recording the way a frame is subdivided.
|
32
|
-
# Frame Configuration Type:: Recording the status of all frames.
|
33
|
-
# Process Type:: A process running on the underlying OS.
|
34
|
-
# Stream Type:: Receive or send characters.
|
35
|
-
# Keymap Type:: What function a keystroke invokes.
|
36
|
-
# Overlay Type:: How an overlay is represented.
|
37
|
-
#
|
38
|
-
# Unlike with elisp programming data types, ruby does not translate
|
39
|
-
# the editing data types to an equivalent ruby object; instead, the
|
40
|
-
# class corresponding to each data type is just a proxy that acts on
|
41
|
-
# the original object in elisp.
|
42
|
-
|
43
|
-
module Relisp
|
44
|
-
|
45
|
-
# Proxy contains the code that creates a wrapper around a variable
|
46
|
-
# in emacs.
|
47
|
-
#
|
48
|
-
class Proxy
|
49
|
-
def self.from_elisp(object)
|
50
|
-
new(object[:variable], object[:slave])
|
51
|
-
end
|
52
|
-
|
53
|
-
# If the last argument is a Relisp::Slave, it gets pulled off and
|
54
|
-
# used as the slave; otherwise Relisp.default_slave is used. If
|
55
|
-
# the first argument is a Symbol, it is assumed to be the name of
|
56
|
-
# an elisp variable which needs a proxy. If the first argument
|
57
|
-
# isn't a Symbol, all of the arguments (except the last, if it was
|
58
|
-
# a Slave) are send off to the child to handle.
|
59
|
-
#
|
60
|
-
def initialize(*args)
|
61
|
-
@slave = if args.last.kind_of?(Relisp::Slave)
|
62
|
-
args.pop
|
63
|
-
else
|
64
|
-
Relisp.default_slave
|
65
|
-
end
|
66
|
-
|
67
|
-
if args[0].kind_of?(Symbol)
|
68
|
-
@elisp_variable = @slave.get_permanent_variable(args[0])
|
69
|
-
elisp_type= ""
|
70
|
-
self.class.to_s.split("::").last.split(//).each_with_index do |char, index|
|
71
|
-
unless index==0 || char == char.downcase
|
72
|
-
elisp_type << "-"
|
73
|
-
end
|
74
|
-
elisp_type << char.downcase
|
75
|
-
end
|
76
|
-
|
77
|
-
unless @slave.elisp_eval("(type-of #{@elisp_variable})") == elisp_type.to_sym
|
78
|
-
raise ArgumentError, "#{@elisp_variable} isn't a #{elisp_type}"
|
79
|
-
end
|
80
|
-
else
|
81
|
-
@elisp_variable = @slave.new_elisp_variable
|
82
|
-
yield args
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
attr_reader :slave, :elisp_variable
|
87
|
-
|
88
|
-
def to_elisp
|
89
|
-
@elisp_variable
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
# A proxy to an Emacs buffer.
|
94
|
-
#
|
95
|
-
class Buffer < Proxy
|
96
|
-
|
97
|
-
# _args_ can be any of these forms:
|
98
|
-
# * (_symbol_, <em>slave = Relisp.default_slave</em>)
|
99
|
-
# * (_string_, <em>slave = Relisp.default_slave</em>)
|
100
|
-
# * (<em>slave = Relisp.default_slave</em>)
|
101
|
-
#
|
102
|
-
# When a _symbol_ is given it is considered to be the name of a
|
103
|
-
# pre-existing bufer in the _slave_ process. Otherwise a new,
|
104
|
-
# buffer is created (<tt>generate-new-buffer</tt>). The name is
|
105
|
-
# _string_, if given, and a variant of "relisp-buffer" otherwise.
|
106
|
-
#
|
107
|
-
def initialize(*args)
|
108
|
-
super do |args|
|
109
|
-
name = args[0] ? args[0] : "relisp-buffer"
|
110
|
-
raise ArgumentError unless name.kind_of?(String)
|
111
|
-
@slave.elisp_execute( "(setq #{@elisp_variable} (generate-new-buffer #{name.to_elisp}))" )
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
# Return the name of Buffer, as a string (<tt>buffer-name</tt>).
|
116
|
-
def name
|
117
|
-
@slave.buffer_name(@elisp_variable.value)
|
118
|
-
end
|
119
|
-
|
120
|
-
# Save the buffer in its visited file, if it has been modified.
|
121
|
-
#
|
122
|
-
def save
|
123
|
-
@slave.elisp_eval <<-EOM
|
124
|
-
(save-excursion
|
125
|
-
(set-buffer #{@elisp_variable})
|
126
|
-
(save-buffer))
|
127
|
-
EOM
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
# A proxy to an Emacs marker.
|
132
|
-
#
|
133
|
-
class Marker < Proxy
|
134
|
-
|
135
|
-
# _args_ can be any of these forms:
|
136
|
-
# * (_symbol_, <em>slave = Relisp.default_slave</em>)
|
137
|
-
# * (<em>slave = Relisp.default_slave</em>)
|
138
|
-
#
|
139
|
-
# When a _symbol_ is given it is considered to be the name of a
|
140
|
-
# pre-existing marker in the _slave_ process. Otherwise a new,
|
141
|
-
# empty marker is created (<tt>make-marker</tt>).
|
142
|
-
#
|
143
|
-
def initialize(*args)
|
144
|
-
super do
|
145
|
-
@slave.elisp_execute( "(setq #{@elisp_variable} (make-marker))" )
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
# Return a newly allocated marker which does not point at any
|
150
|
-
# position (<tt>make-marker</tt>).
|
151
|
-
#
|
152
|
-
def self.make(slave = Relisp.default_slave)
|
153
|
-
slave.make_marker
|
154
|
-
end
|
155
|
-
|
156
|
-
end
|
157
|
-
|
158
|
-
# A proxy to an Emacs window
|
159
|
-
#
|
160
|
-
class Window < Proxy
|
161
|
-
|
162
|
-
# _args_ must be of the form (_symbol_, <em>slave =
|
163
|
-
# Relisp.default_slave</em>)
|
164
|
-
#
|
165
|
-
# The _symbol_ argument is considered to be the name of a
|
166
|
-
# pre-existing window in the _slave_ process.
|
167
|
-
#
|
168
|
-
def initialize(*args)
|
169
|
-
super do
|
170
|
-
raise ArgumentError, "Cannot create Window using 'new' method."
|
171
|
-
end
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
# A proxy to an Emacs frame
|
176
|
-
#
|
177
|
-
class Frame < Proxy
|
178
|
-
|
179
|
-
# _args_ can be any of these forms:
|
180
|
-
# * (_symbol_, <em>slave = Relisp.default_slave</em>)
|
181
|
-
# * (<em>option_hash = {}</em>, <em>slave = Relisp.default_slave</em>)
|
182
|
-
# * (<em>slave = Relisp.default_slave</em>)
|
183
|
-
#
|
184
|
-
# When a _symbol_ is given it is considered to be the name of a
|
185
|
-
# pre-existing frame in the _slave_ process. Otherwise a new,
|
186
|
-
# frame is created using any options in (<tt>new-frame</tt>).
|
187
|
-
#
|
188
|
-
# The _option_hash_ can specify the following
|
189
|
-
# [<tt>:name =></tt> _string_]
|
190
|
-
# The frame should be named _string_.
|
191
|
-
# [<tt>:width =></tt> _fixnum_]
|
192
|
-
# The frame should be _fixnum_ characters in width.
|
193
|
-
# [<tt>:height =></tt> _fixnum_]
|
194
|
-
# The frame should be _fixnum_ text lines high.
|
195
|
-
#
|
196
|
-
# You cannot specify either :width or :height, you must use neither or both.
|
197
|
-
#
|
198
|
-
# [<tt>:minibuffer => true</tt>]
|
199
|
-
# The frame should have a minibuffer.
|
200
|
-
# [<tt>:minibuffer => nil</tt>]
|
201
|
-
# The frame should have no minibuffer.
|
202
|
-
# [<tt>:minibuffer => :only</tt>]
|
203
|
-
# The frame should contain only a minibuffer.
|
204
|
-
# [<tt>:minibuffer =></tt> _window_]
|
205
|
-
# The frame should use _window_ as its minibuffer window.
|
206
|
-
#
|
207
|
-
# [<tt>:"window-system" => nil</tt>]
|
208
|
-
# The frame should be displayed on a terminal device.
|
209
|
-
# [<tt>:"window-system" => :x</tt>]
|
210
|
-
# The frame should be displayed in an X window.
|
211
|
-
# [<tt>:terminal =></tt> _id_]
|
212
|
-
# The frame should use the terminal identified by _id_.
|
213
|
-
#
|
214
|
-
def initialize(*args)
|
215
|
-
super do |args|
|
216
|
-
hash = args[0]
|
217
|
-
alist = ""
|
218
|
-
if hash && hash.size > 1
|
219
|
-
alist << "'("
|
220
|
-
hash.each_pair do |key, val|
|
221
|
-
val = if val.kind_of?(Symbol)
|
222
|
-
val.value.to_elisp
|
223
|
-
else
|
224
|
-
val.to_elisp
|
225
|
-
end
|
226
|
-
alist << "(#{key} . #{val.to_s}) "
|
227
|
-
end
|
228
|
-
alist << ")"
|
229
|
-
end
|
230
|
-
|
231
|
-
@slave.elisp_execute( "(setq #{@elisp_variable} (new-frame #{alist}))" )
|
232
|
-
end
|
233
|
-
end
|
234
|
-
|
235
|
-
end
|
236
|
-
|
237
|
-
# A proxy to an Emacs window-configuration
|
238
|
-
#
|
239
|
-
class WindowConfiguration < Proxy
|
240
|
-
|
241
|
-
# _args_ must be of the form (_symbol_, <em>slave =
|
242
|
-
# Relisp.default_slave</em>)
|
243
|
-
#
|
244
|
-
# The _symbol_ argument is considered to be the name of a
|
245
|
-
# pre-existing window-configuration in the _slave_ process.
|
246
|
-
#
|
247
|
-
def initialize(*args)
|
248
|
-
super do
|
249
|
-
raise ArgumentError, "Cannot create WindowConfiguration using 'new' method."
|
250
|
-
end
|
251
|
-
end
|
252
|
-
end
|
253
|
-
|
254
|
-
# A proxy to an Emacs frame-configuration
|
255
|
-
#
|
256
|
-
class FrameConfiguration < Proxy
|
257
|
-
|
258
|
-
# _args_ must be of the form (_symbol_, <em>slave =
|
259
|
-
# Relisp.default_slave</em>)
|
260
|
-
#
|
261
|
-
# The _symbol_ argument is considered to be the name of a
|
262
|
-
# pre-existing frame-configuration in the _slave_ process.
|
263
|
-
#
|
264
|
-
def initialize(*args)
|
265
|
-
@elisp_type = :cons
|
266
|
-
@elisp_test_type_function = "frame-configuration-p"
|
267
|
-
|
268
|
-
super do
|
269
|
-
raise ArgumentError, "Cannot create FrameConfiguration using 'new' method."
|
270
|
-
end
|
271
|
-
end
|
272
|
-
end
|
273
|
-
|
274
|
-
|
275
|
-
# # A proxy to an Emacs [OBJECT]
|
276
|
-
# #
|
277
|
-
# class [CLASS] < Proxy
|
278
|
-
|
279
|
-
# # _args_ can be any of these forms:
|
280
|
-
# # * (_symbol_, <em>slave = Relisp.default_slave</em>)
|
281
|
-
# # * (<em>slave = Relisp.default_slave</em>)
|
282
|
-
# #
|
283
|
-
# # When a _symbol_ is given it is considered to be the name of a
|
284
|
-
# # pre-existing [TYPE] in the _slave_ process. Otherwise a new,
|
285
|
-
# # empty [TYPE] is created (<tt>[FUNCTION]</tt>).
|
286
|
-
# #
|
287
|
-
# def initialize(*args)
|
288
|
-
# super do
|
289
|
-
# @slave.elisp_execute( "(setq #{@elisp_variable} (FUNCTION))" )
|
290
|
-
# end
|
291
|
-
# end
|
292
|
-
# end
|
293
|
-
|
294
|
-
end
|
295
|
-
|