January 30, 2018

TeX Writer: Editor Redesign

Many new TeX Writer users find that the editor uses an odd selection method that's quite different from the system one. When I implemented TeX Writer editor years ago, there was no TextKit. We had to use CoreText to layout and to render text. The app development scene is more active than it is today, and developers put out new things everyday. So people tolerate new ideas more back in those days. From appstore review section I saw that some people find our way interesting and convenient. Today, it is unthinkable to keep non-standard behaviors. We should just conform to the system behavior and everyone can use the app right away.

For the entire January, I have been playing with TextKit and trying to make the editor more native. At the same time we want to keep the appearance more or less the same: Line numbers, fringes on both side, a command bar to type in commands, and the color settings in twinit.l.

Some new things came out out during the experiment:

That is quite a lot to do, and to implement them properly will at least take another month. I hope we can have a nice update that is worth the wait.

January 2, 2018

Writing a Small LISP Interpreter

Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp. -- Philip Greenspun, 1993

TeX Writer uses a half-baked lisp for configuring its editor. Since we are going to reimplement the editor, the lisp engine needs to be updated as well. For the entire December, I had been working on the new lisp implementation (well, to be honest, took me some time to building a retro 486 PC too). Actually I had tried to rewrite it many times before, but every single time I abandoned because it didn't feel pretty. This time, with all those failures under my belt, the implementation goes smoothly. Start from the tokenizer, then parser, simple expression evaluation, lambda, macro, tail recursion, error callstack, then the tests. Features unfold naturally, and it's done with about 3500 lines of C code, though I may need to add some more in the following weeks.

The lisp dialect is modeled after Scheme, but conforming to standard is not our goal. It has some special features. For instance, it's easy to write a self printing program:

((lambda (&label p) (write (cons (cons (quote lambda) (cdr p)) ()))))

The argument modifier &label binds p to the lambda closure itself, and (cdr p) returns the source of lambda. I don't have any real use for it, but seeing it run gives me smile.

Now I have no more reason to postpone the real work here -- new editor, better editor.

November 22, 2017

Why Don't We Auto Sync

People has been asking why tex writer no longer syncs automatically. I think we better answer here so that we can hear more voices.

The reason we didn't turn on auto sync by default is that it gives you a chance to review local changes like a light weight version system. You can even revert unwanted changes. The new syncing model encourages people to collaborate on a shared folder. Therefore we don't want to overwrite the remote copy too easily. It would be quite annoying if you sync breaking changes to cloud.

An exception is, for remote compiling (xelatex), we have to automatic sync the working changes to cloud so that our online compiler can fetch them.

We can provide an automatic sync option in future if people find it necessary.

November 13, 2017

On TeX Writer 4.0 (iOS)

We are finishing up the next TeX Writer major update and hope to deliver it as soon as possible. We have many feature requests, but unfortunately many of them have to wait for another update, because we simply don't have enough time to implement everything in this release. We have to focus on the file syncing part, as we have explained before that TeX Writer's current dropbox syncing will stop working near the end of November.

New TeX Writer 4.0 supports two general purpose cloud storage: Dropbox and OneDrive. It will have full access to your cloud files. Instead of syncing everything down to your device, you can now select a single folder to sync. This will make syncing a lot faster. Although the syncing engine has been totally rewritten, our existing users should not find the changes surprising. Everything is still familiar and more explicit. Of course you will need to relink.

An unexpected outcome of this redesign is that now online XeLaTeX compiler is also supported. If the following fragment is detected in your tex file, TeX Writer will treat it as XeLaTeX file and try to compile it with our online compiler.


You still compile a file as you have always been doing, everything is handled automatically, as long as the source files are kept in sync with a cloud folder. The cloud compiler doesn't keep a copy of all your files. It only downloads required files from the cloud. Downloaded files are purged after use. To have a quick turn around, files are cached for 1 hour before deletion. In order to use our compilation server, you must have a Pro subscription.

There are also a lot of small improvements to make TeX Writer easier to use. For example:

What's Next

There are a lot of things that we want to do in future TeX Writer updates. For example, a new editor. The current one was developed long ago and many users prefer iOS standard behaviors. People also want better integration with files app. And we want to make the pro subscription more worthwhile.

However, in the next few weeks, the Android version will be our new focus. Its file syncing is facing the same outage problem. The worst problem is that it relies on a package server which is outdated and unavailable. We really need to fix these issues as soon as possible.

UPDATE 11/16: TeX Writer 4 is now available in AppStore.

October 26, 2017

Improving File Syncing for TeX Writer

We are undertaking the second rewrite of file syncing engine in TeX Writer. The first rewrite was when Dropbox introduced its sync SDK. This time is because the sync SDK has been abandoned by Dropbox, and TeX Writer has been living on an extension period before syncing stops working eventually.

I don't want to blame Dropbox for the termination of sync SDK. It actually got me thinking how we can redesign a better syncing engine. Previously it's difficult to integrate another cloud storage provider, because the code has been structured around Dropbox sync SDK, and we have been reluctant to change code that is not broken. Now change is inevitable, and we have a chance to start from scratch.

We have been thinking and working on the new file syncing in the recent weeks. Many ideas come and go, and the following list is what we end up with.

Full cloud access

Currently only a small portion of Dropbox is visible to TeX Writer, that is files and folders under /Apps/TeX Writer. We wanted to play safe but that is extremely inconvenient for people who collaborate on folders outside the sandbox area. So this time we really want to make people's life easier by asking for full access to entire Dropbox folder.

The way TeX Writer compiler works requires the presence of all referenced files, especially when we need to work in offline mode, like on an airplane. We used to sync entire /Apps/TeX Writer folder down, but now it doesn't make sense to sync entire Dropbox. So we will let users to link a local folder on device to a remote folder on Dropbox (or any other storage provider). Only linked folders will be kept in sync. This is like the selective sync feature on desktop Dropbox client.

Auto merge

Currently if a file is changed locally and also has changes remotely, TeX Writer will require manual conflict resolution. You have to choose either local or remote copy, and it's painful. Most of the time, the changes happen on different portion of the same file and we should be able to merge automatically. We are not going to implement a version control system inside TeX Writer, but this kind of basic feature is useful when we are working on a shared folder with other collaborators.


Dropbox is still the best out there in my opinion, but people have been asking for alternatives. Many ask for iCloud. However, iCloud has a lower priority on our road map, because it is not a general purpose cloud storage. OneDrive is actually the better option. OneDrive provides web API, and its sdk is available on both iOS and android. Its SDK may not be as clean as Dropbox's, but is surely better than either iCloud or GoogleDrive.

Other things

TeX Writer has introduced Pro subscription so that subscribed users can use advanced features. Currently Pro subscription is not cross-platform, but eventually we will associate Pro subscription to one's Dropbox or OneDrive account, so that if one subscribes Pro on iOS, pro features should be avaiable on both texwriter.net and the Android version of TeX Writer, provided that the same Dropbox or OneDrive account is used. Likewise, if one have already purchased web app pro subscription, Pro features should be avaiable in apps too. This is on our list, but may take some time to implement because we need to think it through.

So far, progress has been slow, because file syncing requires extensive testing, and we want to be very careful with user files. The sync engine is implemented and tested separately and we need to integrate into the app in the next few weeks. We hope to deliver the new file syncing before the end of next month.