Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/textbringer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
require_relative "textbringer/commands/help"
require_relative "textbringer/commands/completion"
require_relative "textbringer/commands/lsp"
require_relative "textbringer/elisp/elisp"
require_relative "textbringer/commands/elisp"
require_relative "textbringer/mode"
require_relative "textbringer/modes/fundamental_mode"
require_relative "textbringer/modes/programming_mode"
Expand All @@ -42,6 +44,7 @@
require_relative "textbringer/modes/completion_list_mode"
require_relative "textbringer/modes/buffer_list_mode"
require_relative "textbringer/modes/help_mode"
require_relative "textbringer/modes/emacs_lisp_mode"
require_relative "textbringer/minor_mode"
require_relative "textbringer/global_minor_mode"
require_relative "textbringer/modes/overwrite_mode"
Expand Down
32 changes: 32 additions & 0 deletions lib/textbringer/commands/elisp.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module Textbringer
module Commands
define_command(:eval_elisp_expression,
doc: "Read an Emacs Lisp expression from the minibuffer, evaluate it, and display the result.") do
|s = read_from_minibuffer("Eval Elisp: ")|
result = Elisp.eval_string(s)
message(result.inspect)
end

define_command(:eval_elisp_buffer,
doc: "Evaluate the current buffer as Emacs Lisp.") do
source = Buffer.current.to_s
result = Elisp.eval_string(source, filename: Buffer.current.name)
message(result.inspect)
end

define_command(:eval_elisp_region,
doc: "Evaluate the selected region as Emacs Lisp.") do
b = Buffer.current
s = b.substring(b.point, b.mark).dup
result = Elisp.eval_string(s)
message(result.inspect)
end

define_command(:load_elisp_file,
doc: "Load an Emacs Lisp file.") do
|path = read_file_name("Load Elisp file: ")|
Elisp.load_file(path)
message("Loaded #{path}")
end
end
end
15 changes: 15 additions & 0 deletions lib/textbringer/elisp/ast.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module Textbringer
module Elisp
Location = Data.define(:filename, :line, :column)

IntegerLit = Data.define(:value, :location)
FloatLit = Data.define(:value, :location)
StringLit = Data.define(:value, :location)
CharLit = Data.define(:value, :location)
Symbol = Data.define(:name, :location)
List = Data.define(:elements, :dotted, :location)
Vector = Data.define(:elements, :location)
Quoted = Data.define(:kind, :form, :location)
Unquote = Data.define(:splicing, :form, :location)
end
end
Loading