Complete Computing Environment: Long Form

Table of Contents

Long Form writing with Org-mode

I really enjoy, when I have the time, to do long-form writing on my blog1 and in a private Org-mode journal. One of my biggest struggles has always been trying to externalize my thoughts and feelings, and long-form writing has been the thing that causes the biggest single improvement. Even here, distilling why I do what I do in to words has made these choices all the more clear to myself, and have given me ideas on how to expand this, not even considering the usefulness this will have for others.

My long-form lives in a few places at this point, primarily blog and a private journal, as mentioned above. The blog is built on top of Org-page2, a neat little static site generate built on top of Org's export system. You can do this directly with Org's export system3, but generating RSS from individual pages isn't a thing that can happen apparently, and things like automatic blog index generation don't happen and, well, those are things I shouldn't need to do. And org-page does them, and does a pretty decent job at it.

The rest of my long-form simply lives in an ~/org/private.org.gpg along with personal information, plans, and short thoughts, which since it's encrypted doesn't end up in my Agendas or anything like that. Emacs's EPG library4 makes editing GPG encrypted files entirely seamless, just make sure /tmp is a ramdisk :)

(provide 'cce-writing)

Spell checking is the code linting of prose; flyspell does a good job at it, though it requires ispell to be installed.

(require 'flyspell)
(diminish 'flyspell-mode "✓")
(add-hook 'text-mode-hook 'turn-on-flyspell)
(add-hook 'org-mode-hook 'turn-on-flyspell 'append)

Sometimes I work with Markdown mode, markdown should always open in markdown-mode.

(install-pkgs '(markdown-mode))
(autoload 'markdown-mode "markdown-mode"
  "Major mode for editing Markdown files" t)
(add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.mkd\\'" . markdown-mode))

Configuring Org-page itself is kind of, well, underdocumented. Thankfully, all of the variables are mostly self-documenting in regards to their names.

(install-pkgs '(org-page))
(require 'org-page)
(setq op/repository-directory "/home/rrix/Projects/org.rix.si/")
(setq op/site-domain "http://whatthefuck.computer")
(setq op/theme-root-directory "/home/rrix/Projects/org.rix.si/themes")
(setq op/site-main-title "Computer :(")
(setq op/site-sub-title "/home/rrix")
(setq op/theme 'mdo)
(setq op/personal-github-link "http://fort.kickass.systems:10082/cgit/")
(setq op/personal-google-analytics-id "UA-30162624-1")

These are the Export formats that I use regularly: HTML, Markdown and ASCII. I want to write one for Phabricator's remarkup5 bullshit, some day.

(require 'ox-html)
(require 'ox-md)
(require 'ox-ascii)
(require 'ox-org)

Display inline images after you run a Babel execution.

(add-hook 'org-babel-after-execute-hook 'bh/display-inline-images 'append)
(defun bh/display-inline-images ()
  (condition-case nil
      (org-display-inline-images)
    (error nil)))

Configure what languages we want to use for org-babel

(org-babel-do-load-languages 'org-babel-load-languages
                             '((emacs-lisp . t)
                               (dot . t)
                               (ditaa . t)
                               (python . t)
                               (ledger . t)
                               (ruby . t)
                               (gnuplot . t)
                               (clojure . t)
                               (shell . t)
                               (org . t)
                               (js . t)))

Output to a lowercase'd results block.

(setq org-babel-results-keyword "results")

Do not prompt to confirm evaluation. This may be dangerous - make sure you understand the consequences. I'm of two minds here; on the one hand, hanging to confirm every source block is terrible, but on the other hand, I'd like to have some modicum of security. In reality, I should set this only for my own files somehow.

(setq org-confirm-babel-evaluate nil)

Always show inline images on startup and in HTML output.

(setq org-startup-with-inline-images t)
(setq org-html-inline-images t)
(defun bh/make-org-scratch ()
  (interactive)
  (find-file "/tmp/publish/scratch.org")
  (gnus-make-directory "/tmp/publish"))

Create footnotes inline instead of in a separate heading at the end of the file.

(setq org-footnote-define-inline t)

Install emoji support in to Emacs, very very important. 🔥

(install-pkgs '(company-emoji))
(company-emoji-init)
- name: symbola installed
  dnf:
    name: "gdouros-symbola-fonts"
    state: installed
  when: ansible_pkg_mgr == "dnf"

- name: symbola installed
  apt:
    name: "ttf-ancient-fonts"
    state: installed
  when: ansible_distribution == "Debian"

- name: symbola installed
  apt:
    name: "fonts-symbola"
    state: installed
  when: ansible_distribution == "Ubuntu"

Use Symbola for the Emojis. 🙌 🙌 🙌

(when (version< emacs-version "25.0")
    (install-pkgs '(emoji-fontset))
    (emoji-fontset-enable "Symbola"))

Publishing Projects

I should use publishing projects as a site to showcase my projects, and a way to showcase my org-mode config. In the long term, I'd like to move all of my sites to this model, but I think that the blog is going to be tough; I can generate the blog index and stuff via org-page, and then do the org bits using Publish, but for now we'll minimize that, since it seems pretty pointless.

Project list

  • projects -> doc.rix.si -> an index of my projects
  • org -> doc.rix.si/cce/ -> a published version of my org-mode literate configuration
(setq org-publish-project-alist
      '(("melchior-org"
         :base-directory "~/Code/melchior-docs"
         :publishing-directory "/ssh:rrix@fort:/var/www/sites/melchior.systems"
         :recursive t
         :table-of-contents nil
         :section-numbers nil
         :base-extension "org"
         :publishing-function org-html-publish-to-html)
        ("melchior-extra"
         :base-directory "~/Code/melchior-docs"
         :publishing-directory "/ssh:rrix@fort:/var/www/sites/melchior.systems"
         :base-extension "css\\|pdf\\|png\\|jpg\\|gif"
         :publishing-function org-publish-attachment
         :recursive t
         :author nil)
        ("melchior"
         :components ("melchior-org" "melchior-extra"))
        ("portfolio-org"
         :base-directory "~/Projects/org.rix.si"
         :publishing-directory "/ssh:rrix@li01.rix.si:/var/www/sites/org.rix.si/_site/"
         :recursive t
         :table-of-contents nil
         :section-numbers nil
         :base-extension "org"
         :publishing-function org-html-publish-to-html)
        ("portfolio-extra"
         :base-directory "~/Projects/org.rix.si"
         :publishing-directory "/ssh:rrix@li01.rix.si:/var/www/sites/org.rix.si/_site/"
         :base-extension "css\\|pdf\\|png\\|jpg\\|gif\\|html"
         :publishing-function org-publish-attachment
         :recursive t
         :author nil)
        ("portfolio"
         :components ("portfolio-org" "portfolio-extra"))
        ("projects-org"
         :base-directory "~/Projects/projects.rix.si"
         :publishing-directory "/ssh:rrix@li01.rix.si:/var/www/sites/doc.rix.si/_site/"
         :recursive t
         :table-of-contents nil
         :section-numbers nil
         :base-extension "org"
         :publishing-function org-html-publish-to-html)
        ("projects-extra"
         :base-directory "~/Projects/projects.rix.si"
         :publishing-directory "/ssh:rrix@li01.rix.si:/var/www/sites/doc.rix.si/_site/"
         :base-extension "css\\|pdf\\|png\\|jpg\\|gif"
         :publishing-function org-publish-attachment
         :recursive t
         :author nil)
        ("projects"
         :components ("projects-org" "projects-extra"))
        ("irlafk-org"
         :base-directory "~/Projects/rl/"
         :publishing-directory "/ssh:rrix@li01.rix.si:/var/www/sites/org.rix.si/_site/irlafk/"
         :recursive t
         :table-of-contents nil
         :section-numbers nil
         :base-extension "org"
         :publishing-function org-html-publish-to-html)
        ("irlafk-extra"
         :base-directory "~/Projects/rl/"
         :publishing-directory "/ssh:rrix@li01.rix.si:/var/www/sites/org.rix.si/_site/irlafk/"
         :base-extension "css\\|pdf\\|png\\|jpg\\|gif"
         :publishing-function org-publish-attachment
         :recursive t
         :author nil)
        ("irlafk"
         :components ("irlafk-org" "irlafk-extra"))
        ("work-scratch"
         :base-directory "/tmp/publish/"
         :publishing-directory "/ssh:rrix@adhoc04-sjc1:/home/rrix/public_html/p/"
         :recursive t
         :section-numbers nil
         :table-of-contents nil
         :base-extension "org"
         :publishing-function (org-html-publish-to-html org-org-publish-to-org)
         :plain-source t
         :htmlized-source t
         :style-include-default nil
         :auto-sitemap t
         :sitemap-filename "index.html"
         :sitemap-title "Test Publishing Area"
         :sitemap-style "tree"
         :author-info t
         :creator-info t)
        ("scratch"
         :base-directory "/tmp/publish/"
         :publishing-directory "/ssh:rrix@li01.rix.si:/home/rrix/public_html/scratch/"
         :recursive t
         :section-numbers nil
         :table-of-contents nil
         :base-extension "org"
         :publishing-function (org-html-publish-to-html org-org-publish-to-org)
         :plain-source t
         :htmlized-source t
         :style-include-default nil
         :auto-sitemap t
         :sitemap-filename "index.html"
         :sitemap-title "Test Publishing Area"
         :sitemap-style "tree"
         :author-info t
         :creator-info t)
        ("org-org"
         :base-directory "~/sync/cce/"
         :publishing-directory "/ssh:rrix@li01.rix.si:/var/www/sites/doc.rix.si/_site/cce/"
         :recursive t
         :table-of-contents t
         :section-numbers nil
         :base-extenshion "org"
         :publishing-function org-html-publish-to-html)
        ("org-extra"
         :base-directory "~/sync/cce/"
         :publishing-directory "/ssh:rrix@li01.rix.si:/var/www/sites/doc.rix.si/_site/cce/"
         :base-extension "css\\|pdf\\|png\\|jpg\\|gif"
         :publishing-function org-publish-attachment
         :recursive t
         :author nil)
        ("org"
         :components ("org-org" "org-extra"))))

This function is bound to C-S-F12 and will publish the project which a file belongs to.

(defun bh/save-then-publish (&optional force)
  (interactive "P")
  (save-buffer)
  (org-save-all-org-buffers)
  (let ((org-html-head-extra)
        (org-html-validation-link "<a href=\"http://validator.w3.org/check?uri=referer\">Validate XHTML 1.0</a>"))
    (org-publish-current-project force)))
(global-set-key (kbd "C-s-<f12>") 'bh/save-then-publish)

(setq org-html-xml-declaration '(("html" . "")
                                 ("was-html" . "<?xml version=\"1.0\" encoding=\"%s\"?>")
                                 ("php" . "<?php echo \"<?xml version=\\\"1.0\\\" encoding=\\\"%s\\\" ?>\"; ?>")))
(setq org-export-allow-BIND t)

Medium-form writing with Org-mode

One thing that I am experimenting with right now, is a sort of "short-notes" system, similar to a blog but limited to exporting a single paragraph, and to be heavily marked up with microformats so that IndieWeb sites can use them; in the long-term these will supersede my direct usage of Twitter/Facebook/Instagram, with content coming out of my Org-mode, exported to HTML and RSS, and then syndicated to other sites via Bridgy.

It currently just lives in my home directory, not even pushed to git:

(add-to-list 'load-path "/home/rrix/Projects/notes")
(condition-case nil
  (require 'arcology)
  (error (message (format "I guess we don't have arcology available."))
         nil))

Using it is quite simple: I hit C-c _ to call the mfblog capture template, I write my shortnote, and then mark it as DONE with C-t d, and then call mfblog:gen, which will generate the site and push it to my server.

This function, cce/insert-image takes a URL, downloads it locally and attaches it to the current task; I use this to quickly copy files from my phone in to Arcology.

(defun cce/insert-image (url)
  (interactive "sURL? ")
  (let ((id (org-id-new)))
    (shell-command (format "wget '%s' -O /tmp/%s.jpg" url id))
    (org-attach-attach (format "/tmp/%s.jpg" id))))

Footnotes:

Author: Ryan Rix

Created: 2017-10-03 Tue 10:07

Validate XHTML 1.0