== Experimental Emacs ==
Corwin's Emacs Blog

The Automation Begins

The Automation Begins

Having decided I should make a blog to chronicle my adventures in Emacs, I started looking into hugo a minimal blogging framework written in GO. It turns out that hugo has excellent org integration, incorporating go-org, which is the same library used by Github.

Approach and Setup

As pre-work, I created the (sub) domain where this blog is hosted with my web hosting provider's CPANEL tools Then I created a new shell user with access only to the new site and enabled ssh access for the new user. Finally, I installed my workstation's public ssh key into the authorized_keys file for new user account I use to publish the blog.

With the setup completed, I created the initial post and published it by hand, then I had supper and watched The Simpsons with the family for a while. Then I created this post and used it to published itself! 😵


Within Emacs, this means putting my cursor with-in each of the code-blocks in turn then pressing C-c C-c (That's Control+C, twice) to execute the block the cursor is currently within ("at point").

This works because, in the org file "behind" this blog post, I warp the code-block with special org-mode specific mark-up that identifies the programming language. Just as go-org uses this mark-up to select the right syntax highligher when rendering HTML, org is additionally able to use system functions to invite whatever interpretor based on the type of code the block contains.


  #+BEGIN_SRC perl
  say "Hello, org-babel!"

Windows: Fix-up for ob-sh to use cmd.exe

I will run this first code-block only when I have restarted Emacs since I last published the blog. It sets up advice, which are a convenient way to alter how built-in Emacs functionality works.

I'm using Windows 10, so the first thing needed was a fix for invoking cmd.exe. This SO solution is actually wrapping sh babel processing to use cmdproxy, which can pass us back STDOUT properly.

  ;;(require 'ob-sh)
  (defadvice org-babel-sh-evaluate (around set-shell activate)
    "Add header argument :shcmd that determines the shell to be called."
    (let* ((org-babel-sh-command
	    (or (cdr (assoc :shcmd params)) org-babel-sh-command)))


Now we can just use hugo -D to render the site as static content.

  /c/hugo/hugo -D


Once the static files are rendered I use pscp to upload them to the web host.

pscp -r d:/projects/bla/corwin.bru.st/public/* dh_aw28jd@corwin.bru.st:/home/dh_aw28jd/corwin-emacs


That's it. I'll likely clean-up the output somewhat later on. That's even more likely to happen if I need to "scrape" it for further automation later on.

UPDATE: Thanks again to sachac for the tip to use :results verbatim!

Thanks for reading!