Monday, July 29, 2019

Rediscovering Atom Editor

PyCharm uses so much power! Yesterday I had to interrupt my work twice because my notebook was too hot.

I had another session with Atom. In Atom I currently have a funny issue. The “Open File” dialog looks like this:

../../_images/0729.png
$ wget -qO - https://packagecloud.io/AtomEditor/atom/gpgkey | sudo apt-key add -
$ sudo sh -c 'echo "deb [arch=amd64] https://packagecloud.io/AtomEditor/atom/any/ any main" > /etc/apt/sources.list.d/atom.list'
$ sudo apt-get install atom

Fixed. Yes, obviously I was using an obsolete version.

Before reasonably switching to Atom I also had to install the following packages:

  • language-restructuredtext <https://atom.io/packages/language-restructuredtext>`__

  • python-tools <https://atom.io/packages/python-tools>`__

Switching to Atom.

In my .bashrc file:

export EDITOR='atom'

But also in my .invoke.py file:

editor_command = 'atom'

Afterwards I removed above line and changed Atelier so that the default value for the editor_command setting is now taken from the EDITOR environment variable.

One problem was that inv blog did’t start the editor. Seems that atom doesn’t like the pty=True. The problem disappeared when I removed this argument in atelier.invlib.edit_blog_entry().

But when I ask Ctrl+Alt+G (Goto definition) it says “python-tools could not find any results!”. Tried to install jedi. Tried to set my virtualenv in the package’s settings. Then the problem vanished without explanation.

Cool: No need to find a plugin for reflowing a paragraph: Shift+Ctrl+Q. And, unlike the fill-paragraph in PyCharm it indents bullet lists (Paragraphs starting with “- “) correctly.

But I prefer Alt+Q. So I defined my first key binding: Cltr+, to open the settings, select Keybindings, search for “reflow”, copy it to the clipboard, pasted it to my .atom/keymap.cson and modified it to alt-q. Attention pitfall: not alt-Q.

Testing getlino

It is time to start testing getlino. I added test a suite and a .travis.yml file.

But I don’t yet see how we can create virgin debian machines and then install Lino on them. Dockerfiles? Heroku apps?

How to serialize choicelist

In a Django shell I can do:

>>> value = rt.models.tickets.TicketStates.new
from lino.core.choicelists import Choice
from django.db.migrations.serializer import BaseSerializer
from django.db.migrations.writer import MigrationWriter

class ChoiceSerializer(BaseSerializer):
    def serialize(self):
        return "rt.models.{}.{}.{}".format(value.choicelist.app_label, value.choicelist.__name__,value.name), {'from lino.api.shell import rt'}

MigrationWriter.register_serializer(Decimal, DecimalSerializer)