Lucas E M M. opinions

Emacs code navigation? TAAAGS!

emacs tools

Do you know when you open a code file and you want to navigate it but you have to fire up a whole enviroment just to do it? In clojure, would be cider, in python it would be elpy and so on…

Well, get ready feel free! All you need is a command line and vanilla emacs!!

The command is etags. What this command does is look for all the definitions you made in the files you pass as an argument with the language and it will create a TAGS file in the current directory.

find . -type f -name "*.clj" | xargs etags --language=lisp

Once that is done, use you xref-find-definitions and xref-pop-marker-stack command (alias in vanilla as M-. and M-,, respectively) and it will ask you where is the TAGS table.

You can reset the table with tags-reset-tags-table. If it feel very UNIX like, you would be right. It is! Enjoy!

Oh, not sure what languages are supported? Fear not!

etags --help

  1. emacs tags
  2. elpy
  3. cider

/comments ~lucasemmoreira/ Emacs code navigation? TAAAGS!

My first clojure project on the list!

code finance

Recently, I created a new page on this website. I decided to put all cool projects that I made/find around the web (spoiler alert, for now it has only my projects hehe).

I have already put a few, but I noticed that none of them are in clojure which is my most fluent programming language these days.

So, let me introduce you to: invoice-translator!

The idea of the project is for you to be a little bit more aware of how you are spending your money every month. You can use something like gnucash for something like this, right? Well, yes but the tricky part is that you would have to populate the data. Or translate it to gnu-cash if you will.

Hence: invoice-translator! The idea here is to use the software to transform you credit card invoice (for now) into a csv in order to be fed to your money handling software.

/comments ~lucasemmoreira/ My first clojure project on the list!

Integration test in a good way

code tools

This is another tale of redemption… I really enjoy minimalistic solutions and yet, I was not using for integration tests…

So, as everything that needs a start, what was the problem? For some time, I have been thinking about integration tests. What I am calling integration here means a way to test an API that goes through other APIs.

The non minimal

I tried a few approaches. One was to create a “fake” data structure that would represent the return of one API but that proved to be very difficult to insert in my coding routine.

Another approach was to use a http request client. The one I used the most was restclient mode in emacs. Which is pretty good. Here is an example of a GET request from the README:

# XML is supported - highlight, pretty-print

With the mode, you have some shortcuts and can have a bunch of requests in a single file. It is pretty cool actually. The problem? it is not very good in the automation front… I did not find an easy way to run all these requests.

Well, what is the solution? Thinking minimal. Like, really minimal. I mean curl minimal.

Now, what is the problem with curl? It is tedious to make it work if you are not used to it. You have a lot of the control of how the request should be made…

Save this. We will come back to it.

The minimal

Why is it a solution, then? Because you made your request with a command line, it is very easy to automate with a script, such as a shell script.

For instance, you can create an “integration” test script like so:

# testing with 10
curl -X GET

# a test with json post
curl -X POST --json @path-to-json-file


Pretty simple if you ask me. Now, after a commit or when you feel like it, it is one command away.

Remember the problem? Well, I wonder if it really is. More control over it means that you are fully aware of what is going on. Meaning, you have a better understanding of the process. You have to study more? Sure, however I would argue it is the extra mile that could make you a better coder.

I am leaving giving my thanks to ’erica and umgeher for this small realization. Cheers!

/comments ~lucasemmoreira/ Integration test in a good way