# Where parallels cross

Interesting bits of life

# Becoming Glamorous: how GlamorousToolkit can run Emacs Lisp.

Two great tools like GlamorousToolkit (GT) and Emacs can work together! Here I show how to make GT run Emacs Lisp!

## The problem

Emacs is an amazing OS text editor. What I like most of it is that I can express myself in Lisp. And as I express myself, my tool adapts to me. This is pretty moldable. Recently I wrote about moldable development and GT, a tool created for this approach. As you can mold Emacs via Lisp, so you can mold GT via Pharo, a Small Talk dialect. The advantage of GT is its wonderful community and its focus on making software a story that can be explained. With GT you can explore code by creating interactive views of it. These views are really Pharo objects, so you can interact with them. With some knowledge of Pharo and GT you can program and adapt these views to your needs.

Can we have the best of Emacs and GT moldable worlds? Can we mix Emacs and GT already?

## It is a problem indeed

A lot of times people polarize. I refer to battles like Vim vs Emacs. Every time I get into reading those smart how-better-is-my-tool-over-yours comparisons, I smile because I think: "lucky me, I like them both!". It is the same for Emacs and GT. Actually it seems to me that these tools can learn from each other. Even better they can cooperate!

I imagine myself to open a project in Emacs, use code-compass to check if there is some architectural decay. Then still curious I would seamlessly move to GT and produce a graph of dependencies between modules in the project. I could even decide to set some architectural constraints with GT. And then somehow I would go back to Emacs and keep track of these same constraints in an Org Mode file. And then automatically publish these somewhere with the amazing export features of Org Mode.

I imagine a back and forth of Lisp and SmallTalk: what a joy! Is this world possible? How far away is it?

## And there is a solution

Not too far! Andrew, a smart Emacs and GT user, is putting quite some effort into bridging these worlds. He has recently published an interpreter of Emacs Lisp for GT: https://gitlab.com/skeledrew/EmacsInGT. This is just too cool! I decided to try the latest version and see if with my minimal GT skills I could run some Elisp in GT. I will share it here if you want to try too!

(defun fun/make-latest-version-of-GT ()
(interactive)
(if (file-exists-p "/tmp/myGT")
(async-shell-command "cd /tmp/myGT; cd */.; ./glamoroustoolkit")
(async-shell-command "mkdir /tmp/myGT; cd /tmp/myGT; wget https://dl.feenk.com/gt/GlamorousToolkitLinux64-release.zip; unzip GlamorousToolkitLinux64-release.zip; cd */.; ./glamoroustoolkit")))


If you are on Linux, just invoke this and you will have a running instance of GT in a few seconds.

Then I moved into Emacs and added a text file called data.txt. When I did that today (by running GT with my function) the full path of the file was /tmp/myGT/GlamorousToolkitLinux64-v0.8.635/pharo-local/data.txt and I added this contents:

emacsclient /bin/emacsclient
lispDirs .


You will probably guess it: you want to run Emacs as a server for this mode to work (basically just run (server-start) as explained in the Emacs manual: https://www.emacswiki.org/emacs/EmacsClient).

Then in GT select the Playground icon. And add this Pharo code:

Metacello new


Then run it with the small "play and i" icon, that is the "Inspect" command.

This should go easy. When it is done, click the "+" icon, choose Pharo and run this code.

Metacello new
baseline: 'EmacsInGT';
repository: 'gitlab://skeledrew/EmacsInGT:master/src';


This will likely throw an error. Don't worry, we are quite there! Open another Pharo Playground with the "+" icon, and type:

Gt4Git new


And press again "Inspect". If you click on the Repositories heading in the new tab, you should see "emacsingit". Double-click on it, a new tab will open, and you will see a "Load" button next to "EmacsInGit". Load it!

Congratulations, you have just used Git via GT! You loaded a repository that contains a GT extension.

Now we are ready to evaluate some Elisp!

Just type the following in another Pharo Playground:

EigtEngine new
read: '(mapcar (lambda (x) (+ 1 x)) (list 1 2 3))';  "expression to evaluate"
eval;
print.


If you evaluate that with "Inspect", you will see GT evaluating Elisp!

How cool is that! And this is just an alpha release. Looking forward to see the amazing things Andrew will achieve!

## Conclusion

Emacs and GT can work together. They can become incredible tools in the tool-belt of software engineers. I am looking forward to this incredible synergy! If you are curious, just follow the above to be an alpha user of EmacsInGT.

Happy Elisping!