Emacs: Rebinding Caps Lock to Ctrl

I was reading this piece, The Beginners Guide to Emacs, which suggested making the Caps Lock Key into CTRL. I’ve been using emacs for years, and it never occurred to me to make this change. Lovely! Since it isn’t in the instructions, I’d thought I’d make a note here in case it comes up in the future. This version simply makes CapsLk into Ctrl.

$ sudo emacs /etc/default/keyboard

Then add: 


$ sudo dpkg-reconfigure keyboard-configuration
$ shutdown -r now

A Quick Introduction to StumpWM on Linux

StumpWM is a tiling, keyboard driven X11 Window Manager written entirely in Common Lisp.”

Why Use It

StumpWM will likely cut down a lot of your use of a mouse. There’s many reasons to use the mouse less, such as speed (entering in a key combination is faster than using a mouse), carpal tunnel syndrome, and so forth.

I like StumpWM because it helps keep me on the command line. I’ve had some experience with it’s predecessor, Ratpoison, while trying to set up a C201 with free software last year, and I liked the focus on one application at a time and being able to type in a few keystrokes to move between them. So, I figured StumpWM was worth a try. Recommended, even if you don’t end up sticking with it.


Within Ubuntu, changing window managers is fairly easy. You just need to install StumpWM with the apt package manager.

$ sudo apt-get install stumpwm

Then, logout and select the gear icon near the enter button and select StumpWM from the drop-down menu and login as usual.

Quick Start

On logging in, you will notice StumpWM strips out most of what is standard in most window managers. There’s no clock. There’s no dock. There’s no background. There’s no list of apps. There’s nothing to navigate multiple desktops. There’s only a blank screen with a box in the upper right corner: “Welcome to Stump Window Manager. / Type C-t ? for help.”

The first thing you’ll want to do when you log in is type: Control-t together then the letter c and the Enter key (or abbreviated: C-t c, same style as in Emacs). This creates a console, and it takes up all the screen real estate. Like Emacs, it is possible to split the screen into a variety of configurations. For simplicity here and due to my preference for dealing with one application at a time, I’ll assume a single application in the screen.

So, if you want to use Firefox, type:

$ firefox &

The &; starts firefox as a background process. You can even change your .bash_aliases file to do this automatically for you.

Of course, there are command keys for other functions: C-t a will give you the time. C-t ; quit, then press Enter to quit.

If you want to switch back and forth between the console and Firefox, you type: C-t C-t. If you have multiple windows, you can see them all and chose them from a drop-down meny by typing: C-t ". Each window also has a number listed, which you can access directly, by typing: C-t 0 (assuming the window is 0).

That’s all you need to get up and running. If you want to start customizing your configuration, I’ve also included a straight-forward .stumpwmrc configuration file below, which among other changes includes replacing C-t with s-t (Windows key + t), which is useful if you want to continue using C-t to open new tabs in Firefox without having StumpWM supersede it.

Also, this configuration file will add back in a mode line, so you can have the time, battery level and option applications with numbers, which can be useful.

;; -*-lisp-*-                                                                  
;; .stumpwmrc                                                                                                                              
(in-package :stumpwm)                                                          
;;; Configuration                                                              
;; Change prefix key to Windows key                                            
(set-prefix-key (kbd "s-t"))                                                   
;; Changing to pointer from X default to standard left                         
(stumpwm:run-shell-command "xsetroot -cursor_name left_ptr")

;; Change prefix key to Windows key                                            
(set-prefix-key (kbd "s-t"))                                                   
;; Changing to pointer from X default to standard left                         
(stumpwm:run-shell-command "xsetroot -cursor_name left_ptr")                   
;; Turn-off start-up message                                                        
(setq *startup-message* nil)                                                   
 "feh --bg-scale ~/path/to/image.jpg")   
;; Start emacs daemon                                                          
; (run-shell-command "emacs --daemon")                                         
;; Start pulseaudio                                                            
(stumpwm:run-shell-command "pulseaudio --start") 

;; Disable system bell                                                         
(stumpwm:run-shell-command "xset b off")                                       
;; Start gnome keyring                                                         
(stumpwm:run-shell-command "gnome-keyring-daemon --start --components=gpg,pkcs\
;; Mode line                                                                   
(defvar *battery-status-command*                                               
  "acpi -b | awk -F '[ ,]' '{printf \"%s%s\", $3, $5}' | sed s/Discharging/\-/\
 | sed s/Unknown// | sed s/Full// | sed s/Charging/+/")                        
(setf *screen-mode-line-format*                                                
      (list "[^B%n^b] %W^>"                                                    
      '(:eval (run-shell-command *battery-status-command* t))                  
      " | %d"))                                                                
(setf *window-format* "%m%n%s%c")                                              
(setf *mode-line-timeout* 1)  

;; Turn on the new mode line.                                                  
(toggle-mode-line (current-screen)                                             
;; Launch Terminal at Start                                                    
(stumpwm:run-shell-command "gnome-terminal")                                   
;; Define keys                                                                 
(define-key *root-map* (kbd "c") "exec gnome-terminal")                        

; Emacs is commented out because I prefer to use                               
; it in the terminal.                                                          
;(define-key *root-map* (kbd "e") "exec emacs")  

(define-key *root-map* (kbd "f") "exec firefox")                               
(define-key *root-map* (kbd "v") "exec eog") ; Eye of Gnome                    
(define-key *root-map* (kbd "t") "exec thunderbird")                           
(define-key *root-map* (kbd "k") "exec keepassxc")                             
(define-key *root-map* (kbd "g") "exec gimp")                                  
(define-key *root-map* (kbd "r") "exec rstudio")                               
;; Functions                                                                   
(defun browse-url (url-string)                                                 
  "Browse url using WEB-BROWSER"                                               
  (check-type url-string string)                                               
  (run-shell-command (concat WEB-BROWSER "\"" url-string "\"")))

;; For connecting to emacs see:
;; http://www.kaashif.co.uk/2015/06/28/hacking-stumpwm-with-common-lisp/index.html

Fixing a Broken org2blog Configuration

I used to have a working set-up of org2blog. Somewhere along the way, it got borked. I couldn’t login. I tried fixing it a few times, but I couldn’t get the problem resolved. Today, I finally got org2blog working. Key piece is setting the gnutls-algorithm-priority.

Use the instructions at the org2blog site:


Do everything it says, such as install the dependencies, create a ~/.netrc file with wordpress as the machine name, and so forth. After creating .netrc, limit access by doing: $ chmod 600 ~/.netrc. Then, replace the blog credentials .emacs code with the following:

;; org2blog  
(require 'org2blog-autoloads)
(require 'netrc)

;; With Emacs 27.1, the following line borked configuration again, remove
;; (setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")

;;; org2blog hydra hooks (defun my/org2blog/wp-mode-hook-fn () (local-set-key (kbd "M-9") #'org2blog/wp-hydra/body) (local-set-key (kbd "M-0") #'org2blog/wp-complete-category)) (add-hook 'org2blog/wp-mode-hook #'my/org2blog/wp-mode-hook-fn)

;;; org2blog authentication (require 'auth-source) (let (credentials) (add-to-list 'auth-sources "~/.netrc") (setq credentials (auth-source-user-and-password "wordpress")) (setq org2blog/wp-blog-alist `(("blogname" :url "https://blogname.wordpress.com/xmlrpc.php" :username ,(car credentials) :password ,(cadr credentials) :default-title "Insert title" :default-categories ("comments") :tags-as-categories nil))))
(setq org-src-fontify-natively t)

I posted this using org2blog with this configuration.

Learn to Program With Common Lisp

Tim Ferriss has a currently popular blog post, “Ten Lessons I Learned While Teaching Myself to Code,” that I’ve seen mentioned in a few places. While it is largely good advice, there is one point that is wrong. It does matter what language you learn. Here’s the ten lessons from his article:

  1. The online world is your friend, start there.
  2. Don’t stress over what language to pick.
  3. Code every day.
  4. Automate your life.
  5. Prepare for constant, grinding frustration.
  6. Build things. Build lots of things.
  7. “View Source”: Take other people’s code, pick it apart, and reuse it.
  8. Build things for you—code you need and want.
  9. Learn how to learn.
  10. Reach out to other coders.

The programming language you choose matters. If what you are doing is trivial, then yes, you can use any programming language. To quote from Paul Graham’s essay, “Revenge of the Nerds“:

“The disadvantage of believing that all programming languages are equivalent is that it’s not true. But the advantage is that it makes your life a lot simpler. And I think that’s the main reason the idea is so widespread. It is a comfortable idea…There are, of course, projects where the choice of programming language doesn’t matter much. As a rule, the more demanding the application, the more leverage you get from using a powerful language. But plenty of projects are not demanding at all. Most programming probably consists of writing little glue programs, and for little glue programs you can use any language that you’re already familiar with and that has good libraries for whatever you need to do. If you just need to feed data from one Windows app to another, sure, use Visual Basic.”

Tim Ferriss is writing trivial programs. So, for his use case, the choice of language is irrelevant. It might be for your use case as well.

But, computer languages are not the same. They have different strengths and weaknesses. For example, in this blog post, a professional programmer discusses why Rust is not a good replacement for C. The short version, Rust is a young language that isn’t stable, and it lacks features older languages have, such as a specification.

Some languages are simply more powerful, mature and give you more options. If you are going to go through the trouble to learning how to program, why not ground yourself in a language with more capabilities?

Your first choice of programming language is going to shape how you think about programming. It can take a long time to broaden your sense of the possible if you pick a language with limited features when you first start learning.

There are many good, powerful programming languages. Arguments can be made for any language you like. However, Paul Graham’s article mentioned above makes a good case that Lisp is a very powerful language. In Pascal Costanza’s Highly Opinionated Guide to Lisp, there’s an interesting observation:

…”Lisp is, in some sense, the mother of all [computer programming] languages…the mindset of Lisp asserts that expressive power is the single most important property of a programming language. Nothing should get in your way when you want to use that power. A programming language should not impose its view of the world on the programmer. It is the programmer who should be able to adapt the language to his/her needs, and not the other way around.”

Lisp is old. It’s stable. It is powerful. Textbooks teaching it date back to the early 1990s. But, they are still relevant and can be bought for almost nothing. So, why not learn Common Lisp? It’s a good question. The most common answer is that computer programming languages are subject to fads and new languages are more popular. But, given Lisp’s flexibility, it’s difficult to make the case that they are better.

Ok, suppose for a moment I’ve convinced you. Now, the question is: how do you go about learning Common Lisp? Last year, Steve Losh provided an answer. He put together a blog post called “A Road to Common Lisp,” that explains the Lisp language in detail and how he went about learning it. In short:

  1. Install SBCL or if you’re using MacOS and want a single GUI app you can download from the App Store, choose Clozure CL. My preference is for Emacs, SBCL, quicklisp and SLIME (tutorial), but you should use an editor that is comfortable to you that can balance parentheses, highlight comments and strings, and autoindent Lisp code. Atom can be a good choice if you haven’t use a text editor before. But, it would be better if you learned either Emacs or Vim.
  2. Read Common Lisp: A Gentle Introduction to Symbolic Computation (<$2 on Alibris, online for free). Do all the exercises and grok in fullness. This book is aimed at intelligent beginners with no prior programming knowledge. Take your time and noodle with this text. It’s going to take time to develop a fluency, and it’s a different style of thinking.
  3. Then read Practical Common Lisp (<$25 on Alibris, online for free). Work through some of this book every day until you complete it. Type in the code if it is going to help you understand it. It doesn’t have exercises.
  4. Write some code for something easy, e.g., Project Euler.
  5. Then, flesh out your understanding further with Paradigms of Artificial Intelligence Programming (<$25 on Alibris).
  6. Now, you’re ready to program something serious and need a weighty reference text, i.e., Common Lisp Recipes (<$50 on Alibris).
  7. Finally, I suspect that Patterns of Software: Tales from the Software Community (<$10 on Alibris) is recommended because it’s a help with understanding how to work on software projects, but the purpose of the recommendation is kept unclear to prevent spoilers.

This strikes me as a better alternative than a $11,000 boot camp. Depending on how much you want to learn, you can get the tools you need to learn Common Lisp to the level you want for somewhere between $0-$150. All the software is available at no cost, and it will run on any computer you already own. Then, if you want to branch out and learn Python, Javascript, or some other language, you’ll have an excellent foundation. However, if you try learning Python or Javascript and then try to learn Lisp or another more powerful language, you’ll find it to be a much more difficult task.

Good luck!

The Plain Person’s Guide to Plain Text Social Sciences by Kieran Healy

The Plain Person’s Guide to Plain Text Social Science is written for graduate students in the social sciences, but useful for any writer. For people not doing sophisticated data analysis, the key suggestions are to use a text editor like Emacs for writing, Markdown for formatting, git—such as on GitLabs—for version control, and a translator program like Pandoc to translate your text file into a variety of formats, such as epub, pdf, doc and so forth. Additionally, he strongly recommends automated backing up of your data with a cloud service. He mentions two standards but if you go that route consider a privacy focused service like SpiderOak, or the free software alternative, NextCloud.


The Plain Person’s Guide to Plain Text Social Science is worth reading for anyone involved with writing, research or data analysis. It introduces the problem of thinking about the tools that we use to do our work and serves as a technical primer for a particular style of writing.Kieran Healy starts with a dichotomy, c.f., Section 1.2. There are two computer revolutions. One revolution is trying to abstract out the technology and present people with an easy, touch interface to accomplish specific tasks. Using your phone to take a picture, send a text message, post to social media, play YouTube videos, etc. are all examples of this type of technology. It’s probably the dominant form of computing now.

The other revolution are the complex computing tools that are being developed that cannot be used via a touch interface. At this point, there is no way to use an open source neural net like Google’s TensorFlow in a way that is going to make sense to the vast majority of people.

As we move to using a keyboard, this tension can be seen in the different types of tools we can use to write, research and do analysis. Microsoft Word, PowerPoint, Excel, Access, etc. were designed to be digital equivalents to their analog predecessors – the typewriter, the overhead projector, the double entry account book or the index file. Of course, the digital equivalents offered additional capabilities, but it was still tied to the model of the business office. The goal for these tools, even as they include PivotTables and other features, is to be relatively easy to learn and use for the average person in an office.

The other computing revolution is bringing tools to the fore that are not tied to these old models of the business office and is combining them in interesting new ways. But, these tools have a difficult learning curve. For example, embedding programming code that can be written into a text analysis to generate calculations when it is typeset is not a feature the average person working in a typical office needs. But, it clearly has some advantages in some contexts, such as for data analysts.

Complexity makes mistakes easier to make. So, it requires a different way of working. We have to be careful to document the calculations we use, track versions from multiple sources, be able to fold changes back into a master document without introducing errors, and so forth. The Office model of handing a “master document” back and forth and the process bottle-necked waiting for individuals making revisions isn’t going to work past a certain minimum baseline level of complexity that we are slowly evolving past.

So, laying out this case, he then suggests various tools to consider: a text browser such as Emacs, Markup for formatting, git for version control, Pandoc for translating text documents into other formats, backup systems, a backup cloud service, etc. All of these tools are equally important to complex writing of any sort, whether it be for writing long works of fiction, research analysis, collaborative writing, and other circumstances we are more likely to find ourselves in, which these more powerful tools help make possible.