lunes, 28 de diciembre de 2015

Linting guix packages

Guix is getting more mature every day (It's probably going to beta soonish).  One of the commands it got 'recently' is guix lint.

Once you write a package definition you want to know if it complies with guix standards. Let's try guix lint.

  1. Write package definition.
  2. Put the definition into a guix checkout (not your running guix).
  3. run 'guix environment guix'.
  4. cd to the checkout directory.
  5. ./bootstrap && ./configure --localstatedir=/var --prefix= && make
  6. ./pre-inst-env guix lint my-package
  7.  If you get an 'ERROR: missing interface for module (gnutls)', means that you need to install gnutls. 'guix package -i gnutls'
  8. After that, you can finally run 'guix lint my-package', and it'll tell you if you have any obvious failures or warnings in your definition.

miércoles, 23 de diciembre de 2015

dash docset for nginx lua

Here's a quick hack I wrote to fetch the reference doc for nginx lua module and convert it to a dash docset. Which I view using our beloved helm-dash.

Quick, and kinda easy.  It's totally hackish in the way that I'm parsing HTML with regexps. Not even recursive regexps.....

But the thing is that this html is generated by markdown, and as it's fetching for a very concrete type of lines, they are all formatted the same way.

Another option (less hackish but for this concrete case, equally fragile) is using xmlstarlet. The code is also in the file (for reference).

So here's the kidd/HttpLuaModule.docset repo.

jueves, 3 de diciembre de 2015

Improving Lua support in etags

It seems it's Lua time again!

So for my new project I'm starting in openresty+lua, I needed some kind of support for tags. Lua is a very simple language syntaxwise (it's whole grammar fits in a screen of code).

Etags support is quite poor, in fact, if you read the emacs-devel message when it got added, you'll see how basic is it.

+ * Lua tag functions
+ *  look for function, local function.
+ */
+static void
+Lua_functions (inf)
+     FILE *inf;
+  register char *bp;
+  LOOP_ON_INPUT_LINES (inf, lb, bp)
+    {
+      if (bp[0] != 'f' && bp[0] != 'l')
+       continue;
+      LOOKING_AT (bp, "local");
+      if (LOOKING_AT (bp, "function"))
+       get_tag (bp, NULL);

The regex version of this would be:   /^(local)?\s+function\s+(\w)/ .

So I wanted to add support for lines not in the beginning, and also to add support for things like

local foo = function (p1, p2) .... end

So it turned out to not be very difficult to augment etags to do that.

 etags --language=lua --regex='/.*\([^. \t]\)*[ \t]*=[ \t]*function/\1/' \
 --regex='/.*\(local\|\)[ \t][ \t]*function[ \t]\([^ \t(]*\)[ \t]*(/\2/'  **/*lua

Just adding this to the Makefile allows me to catch the other forms of lua functions. Again, regex to the rescue! :)