7. Emacs + Spark - Spark

https://www.spark.io/build is great IDE, but you may want to use your own tool, which is Emacs :)


Open your .emacs and associate .ino file to cc-mode.

(setq auto-mode-alist
  (append '(("\\.h$" . c++-mode) ("\\.cpp$" . c++-mode) ("\\.ino$" . c++-mode)) auto-mode-alist))

When you are using Emacs, you need to compile & flash via console. Don’t worry it’s easy!

% brew install node
% npm install -g spark-cli
% spark cloud login 

Now you can compile by spark compile and flash by spark flash command, but I’d use make :)
Then you can compile by make and flash by make install

TARGET  = firmware.bin
SOURCES = main.ino

all : $(TARGET)

$(TARGET): $(SOURCES)
     spark compile $(SOURCES) $(TARGET)

install: $(TARGET)
     spark flash $(SPARK_CORE_ID) $(TARGET)

clean:
     rm -f $(TARGET)

check-syntax:
     spark compile $(SOURCES) $(TARGET) | sed s/cpp/ino/

One more thing

If you are familiar with flymake on Emacs, you can use it. It’s basically syntax check on the fly. As you can see in the Makefile, there is check-syntax target.
You can see what’s wrong in Emacs immediately.

Enjoy!