Weekly review: Week ending April 16, 2021

| weekly, review
  • I switched my blog from Wordpress to 11ty. I figured out how to post to 11ty from an Org Mode file in the right directory, and I set up redirects for my categories and feeds using an Nginx map.
  • I got org2blog to work with my special blocks. Now I can post with multiple columns.
  • I realized that I'd gotten overexcited about setting the plants out, so I took many of them back in and I put covers on the seedlings still outside.
  • I filed our taxes.

Blog posts



Category The other week % Last week % Diff % h/wk Diff h/wk
Discretionary - Productive 8.8 12.6 3.8 21.2 6.3
A- 46.3 48.8 2.5 82.0 4.2
Discretionary - Play 0.8 0.8 0.0 1.3 0.0
Personal 4.6 4.6 -0.1 7.7 -0.1
Business 2.0 0.8 -1.2 1.3 -2.0
Sleep 32.5 30.6 -1.9 51.5 -3.1
Unpaid work 4.9 1.8 -3.1 3.1 -5.2
View or add comments

This is a test post from Org Mode to 11ty

| blogging, org, emacs

At the moment, my Org file needs to be in the proper content directory. I'm planning to copy the way ox-hugo allows me to export to a different directory and export filename. In the meantime, this is a start.

;;; ox-11ty.el --- Eleventy export for Emacs Org Mode  -*- lexical-binding: t -*-

;; Copyright (C) 2021 Sacha Chua

;; Author: Sacha Chua <sacha@sachachua.com>
;; Version: 2.17.0
;; Package-Requires: ((emacs "27"))
;; Keywords: org, eleventy, 11ty
;; Homepage: https://github.com/sachac/ox-11ty

;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program.  If not, see <https://www.gnu.org/licenses/>.

;;; Commentary:

;; A very rough starting point for exporting to 11ty from Org Mode.

;;; Code:

(require 'ox-html)

(defun org-11ty-template (contents info)
  (let* ((date (org-export-data (plist-get info :date) info))
         (title (org-export-data (plist-get info :title) info))
         (permalink (org-export-data (plist-get info :permalink) info))
         (categories (org-export-data (plist-get info :categories) info))
         (collections (org-export-data (plist-get info :collections) info))
         (front-matter (json-encode
                        (list :permalink permalink
                              :date date
                              :title title
                              :categories (split-string categories)
                              :tags (split-string collections)))))
     "module.exports = class {
  data() {
    return %s;
  render() {
    return %s;
     (json-encode-string contents))))

(defun org-11ty-export-as-11ty (&optional async subtreep visible-only body-only ext-plist)
  "Export current buffer as 11ty file."
  (org-export-to-buffer '11ty "*org 11ty export*" async subtreep visible-only body-only ext-plist))

(defun org-11ty-export-to-11ty (&optional async subtreep visible-only body-only ext-plist)
  (let* ((info
           (org-export--get-export-attributes '11ty subtreep visible-only)
           (org-export-get-environment '11ty subtreep)))
         (base-file-name (concat (or
                                  (and (plist-get info :file-name)
                                       (if (string= (file-name-base (plist-get info :file-name)) "")
                                           (concat (plist-get info :file-name) "index")
                                         (plist-get info :file-name)))
                                  (org-export-output-file-name "" subtreep))
          (if (plist-get info :base-dir)
              (expand-file-name base-file-name (plist-get info :base-dir))
    (when (file-name-directory file)
      (make-directory (file-name-directory file) :parents))
    (org-export-to-file '11ty file
      async subtreep visible-only body-only ext-plist)))

(org-export-define-derived-backend '11ty 'html
  '(?1 "Export to 11ty JS"
       ((?b "As buffer" org-11ty-export-as-11ty) 
        (?1 "To file" org-11ty-export-to-11ty)))
  '((template . org-11ty-template))
  '((:permalink "PERMALINK" nil nil)
    (:categories "CATEGORIES" nil 'split)
    (:base-dir "ELEVENTY_BASE_DIR" nil nil)
    (:file-name "FILE_NAME" nil nil)
    (:collections "ELEVENTY_COLLECTIONS" nil 'split)))

;;; ox-11ty.el ends here


View or add comments

Emacs: Making a hydra cheatsheet for Lispy

| emacs

I wanted to get the hang of Lispy thanks to Leo Vivier’s presentation at EmacsSF, but there are a lot of keyboard shortcuts to explore. In Karl Voit’s demo of Org Mode at GLT21, he showed how he uses Hydra to make cheat sheets. That makes perfect sense, of course, as Hydra can display text and allow you to run commands while the text is displayed. I wanted to make a Hydra that would show me categorized commands to make it easier to look up and eventually remember them. I also wanted to skip the commands that I already knew or that I didn’t want to focus on just yet.

Fortunately, the function reference had a link to the Org file used to generate it. I copied the tables, merged them together, named them with #+NAME: bindings, replaced the links with plain text, and added a third column with the category I wanted to put commands into.

key function column
< lispy-barf  
A lispy-beginning-of-defun  
j lispy-down  
Z lispy-edebug-stop  
B lispy-ediff-regions  
G lispy-goto-local  
h lispy-left  
N lispy-narrow  
y lispy-occur  
o lispy-other-mode  
J lispy-outline-next  
K lispy-outline-prev  
P lispy-paste  
l lispy-right  
I lispy-shifttab  
> lispy-slurp  
SPC lispy-space  
xB lispy-store-region-and-buffer  
u lispy-undo  
k lispy-up  
v lispy-view  
V lispy-visit  
W lispy-widen  
D pop-tag-mark  
x see  
L unbound  
U unbound  
X unbound  
Y unbound  
H lispy-ace-symbol-replace Edit
c lispy-clone Edit
C lispy-convolute Edit
n lispy-new-copy Edit
O lispy-oneline Edit
r lispy-raise Edit
R lispy-raise-some Edit
\ lispy-splice Edit
S lispy-stringify Edit
i lispy-tab Edit
xj lispy-debug-step-in Eval
xe lispy-edebug Eval
xT lispy-ert Eval
e lispy-eval Eval
E lispy-eval-and-insert Eval
xr lispy-eval-and-replace Eval
p lispy-eval-other-window Eval
q lispy-ace-paren Move
z lispy-knight Move
s lispy-move-down Move
w lispy-move-up Move
t lispy-teleport Move
Q lispy-ace-char Nav
lispy-ace-subword Nav
a lispy-ace-symbol Nav
b lispy-back Nav
d lispy-different Nav
f lispy-flow Nav
F lispy-follow Nav
g lispy-goto Nav
xb lispy-bind-variable Refactor
xf lispy-flatten Refactor
xc lispy-to-cond Refactor
xd lispy-to-defun Refactor
xi lispy-to-ifs Refactor
xl lispy-to-lambda Refactor
xu lispy-unbind-variable Refactor
M lispy-multiline Other
xh lispy-describe Other
m lispy-mark-list Other

I wrote this Emacs Lisp code with the header arguments #+begin_src emacs-lisp :var bindings=bindings :colnames yes:

  '(defhydra my/lispy-cheat-sheet (:hint nil :foreign-keys run)
     ("<f14>" nil :exit t))
  (cl-loop for x in bindings
           unless (string= "" (elt x 2))
           (list (car x)
                 (intern (elt x 1))
                 (when (string-match "lispy-\\(?:eval-\\)?\\(.+\\)"
                                     (elt x 1))
                   (match-string 1 (elt x 1)))
                 (elt x 2)))))
(with-eval-after-load "lispy"
  (define-key lispy-mode-map (kbd "<f14>") 'my/lispy-cheat-sheet/body))

Here’s the result:


Figure 1: Hydra-based cheat sheet

I’m experimenting with having my Windows key be F14 if tapped and Super_L if held down. I use KDE, so I disabled the Applications shortcut with:

kwriteconfig5 --file ~/.config/kwinrc --group ModifierOnlyShortcuts --key Meta ""
qdbus org.kde.KWin /KWin reconfigure

and then used xcape -e 'Super_L=F14' to make it work.

Looking forward to getting the hang of this!

This is part of my Emacs configuration.
View or add comments

2021-04-12 Emacs news

| emacs, emacs-news

Links from reddit.com/r/emacs, r/orgmode, r/spacemacs, r/planetemacs, Hacker News, planet.emacslife.com, YouTube, the Emacs NEWS file and emacs-devel.

View or add comments

Sharing more of my discretionary time

Posted: - Modified: | writing

Depending on what time A- finally goes to bed, I might have around 1-2 hours of discretionary time that I can use to focus on a small task and complete it. If I pick something that’s too big, I get tempted to stay up late, which often makes me grumpy the next day. So a good approach might be to have a number of reasonably small tasks that give me as quick a payoff as possible, especially if those tasks can result in compounding improvements.

Now that I can post Org Mode headings to my journal from Emacs, it’s easier to log finished tasks as journal entries that will get picked up during my weekly and monthly review. The next step might be to figure out how to flesh out those lines into more useful posts. That way, I can find things again by searching my blog. Also, if other people can pick up ideas from my posts, I might be able to benefit from their improvements.

There’s a lot of room for growth in terms of my workflow for doing stuff, learning stuff, and sharing stuff. Here’s what a possible learning path might be like:


  • Planning: I’ve just started excavating the Org files that I’ve been tossing ideas into over the last 5+ years of limited discretionary time. Now things are mostly refiled, and I’ve got quite a few projects on my priority list. I might spend a bit of non-computer time mulling over 1-3 possibilities throughout the day, and then work on the most interesting one after processing my inbox. I find that in the course of a week, I tend to focus on one or two projects in order to take advantage of momentum. It’s also good to set aside planning/improvement/review time instead of getting tempted to prioritize coding all the time, as fun as it is to write stuff.

    I don’t have to optimize this. Most tasks are good to work on and move me forward, so I don’t have to spend a lot of time trying to analyze the best effort/reward ratio. I can usually just go with whatever I feel like working on.

  • Coding: I usually work with Emacs Lisp or Javascript, with a little bit of Python. I have some technical debt in Ruby that I don’t have the brainspace to dig into at the moment. It may have to wait until A- goes to in-person school. For Emacs Lisp, my next workflow improvement might be to get the hang of Lispy. For my personal projects, infrastructure is the main thing tripping me up. I need to spend some time setting up a proper development environment and learning more about workflows so that I can reduce risk when I’m working on stop-and-go things.
  • Writing: Dictation is out for now, since I don’t feel much like talking at night. It’s nice to be quiet after a whole day of talking with a kiddo. When I get the Georgi keyboard I ordered, stenography might be an interesting long-term skill investment. The bottleneck is probably still my thinking speed, though. That means I could probably:
    • embrace lists and outlines as a way of getting fragmented thoughts down (possibly over several sessions) and then shuffling them around into some form of coherence (yay Org Mode)
    • lower my threshold for posting; it’s better to think out loud
  • Screenshots: I recently tweaked my shortcuts for inserting screenshots. Now I just need to make them part of muscle memory.
  • Drawings: I can sketch things out on my Lenovo X220 tablet PC, although flipping the screen is a little annoying. One option might be to leave my screen rotated and then use a Bluetooth keyboard to type and use shortcuts. The keyboard isn’t as comfortable to type on as my laptop is, though. Hmm… org-krita doesn’t quite fit my workflow, so I need to write my own. I want to be able to quickly sketch something. If I like it, I want to convert it, rename it with a caption, and add it to my sketches.

(defun my/org-insert-drawing-as-link ()
  (let ((file (make-temp-file "/tmp/image" nil ".psd")))
    (copy-file my/index-card-template-file file t)
    (insert (org-link-make-string (format "file:%s" file)))
    (my/open-images-in-krita (list file))))

(defun my/preview-in-other-buffer (file)
  (with-current-buffer (find-file-noselect file)
    (display-buffer (current-buffer))))

(defun my/org-convert-sketch-at-point (&optional two-col)
  (interactive "p")
  (let* ((link (org-element-context))
         (file (org-element-property :path link))
         (intermediate (concat (file-name-sans-extension file) ".png"))
         new-file new-link)
    (unless (eq (org-element-type link) 'link)
      (error "Not at a link"))
    ;; (call-process "krita" nil nil nil file "--export" "--export-filename" intermediate)
    (call-process "convert" nil nil nil (concat file "[0]") intermediate)
    (my/preview-in-other-buffer intermediate)
     date (org-read-date)
     caption (read-string "Caption: ")
     new-file (expand-file-name (format "%s %s.png" date caption) my/sketches-directory)
     new-link (concat "#+CAPTION: " date " " caption "\n"
                      (org-link-make-string (concat "sketch:" (file-name-base new-file)))))
    (rename-file intermediate new-file t)
    (delete-region (org-element-property :begin link)
                   (org-element-property :end link))
    (if two-col
        (progn (insert
                (format  "#+begin_columns
               (save-excursion (insert "
      (insert new-link "\n"))))

(defun my/reload-sketches ()
  (url-retrieve "https://sketches.sachachua.com/reload" (lambda (&rest args) (message "Updated sketches."))))

What are drawings useful for? Nonlinear thinking, sharing, flipping through, building up, visual shorthand, fun. Text is nicer for searching, linking, and dealing with stop-and-go thoughts.

W-‘s offered to let me use his iPad. Concepts and Procreate are both pretty cool, and I have a reasonable workflow for sending files back to my computer and getting them into my Org file. My X220 is still the fastest for quickly switching between text and drawing. I guess either will do.

Also, graphviz is pretty handy for quick diagrams, and it will probably be even more useful as I dig into it and other text-based diagram tools. The diagram at the beginning of this post was generated with:

#+begin_src dot :file "sharing-path.png" :cmdline -Kdot -Tpng -Nfontname=sachacHand -Nfontsize=30
digraph {
  node [shape=box];
  "Planning" -> "Coding" -> "Writing" -> "Screenshots" -> "Drawings" -> "GIFs?" -> "Video" -> "Streaming";
  "Planning" -> "Reading" -> "Writing";
  "Planning" -> "Writing";

Animated GIFs, videos, and streaming may have to wait until I have more brainspace. Plenty to tweak even now!

View or add comments

Weekly review: Week ending April 9, 2021

| review, weekly
  • I figured out how to asynchronously tangle and compile my Emacs configuration.
  • I tweaked my shortcuts for inserting the latest screenshot into my Org file.
  • I added my first ligature and my first contextual substitution to my font.
  • The code I wrote to update my journal from Emacs makes it pretty easy to use Orgzly to capture keywords throughout the day, flesh them out during my inbox review, and post them or update them. That means I should be able to continue to take notes even if I’m offline for an extended period of time.
  • Pretty good progress on emotion regulation! So neat to see.

Blog posts



Category The other week % Last week % Diff % h/wk Diff h/wk
A- 43.4 46.3 2.9 77.8 4.9
Unpaid work 3.8 4.9 1.2 8.3 2.0
Discretionary – Play 0.0 0.8 0.8 1.3 1.3
Discretionary – Productive 8.9 8.8 -0.1 14.9 -0.1
Discretionary – Family 0.6 0.0 -0.6 0.0 -1.0
Sleep 33.3 32.5 -0.8 54.6 -1.3
Personal 5.4 4.6 -0.8 7.8 -1.3
Business 4.7 2.0 -2.7 3.3 -4.5
View or add comments

Grabbing the Youtube auto-generated captions is pretty useful when making Emacs News

| emacs

I’ve been adding Emacs-related videos to my public Emacs News playlist to make it easier to include them when I put together Emacs News every week. I still haven’t had much time to watch things, though. But the code I wrote to convert captions into a table so that they could be used to make notes after a meetup presentation turned out to be handy for Emacs News as well.


Figure 1: With a bit of clicking, Youtube can display translated subtitles and a transcript on the side. I haven’t figured out how to get the transcript translated on Youtube yet.


Figure 2: My Org buffer displays the auto-translated captions, making things easy to skim through.

Then I can jump to sections I’m particularly curious about. Neat!

View or add comments