Xcape on macOS (Sort Of)

Yesterday I wrote about T V Raman’s post explaining how he uses the X Windows xcape command to provide extra keys and better ergonomics for Emacs. Raman has some nice ideas about improving the Emacs keyboard interface but they were, unfortunately, restricted to those using X Windows. That’s a lot of people, of course, but about a quarter of those who use Emacs are doing so on a Mac and Raman’s hack wasn’t available to them.

Jeremy Friesen to the rescue. Like me, he was intrigued by Raman’s post but unlike me he decided to do something about it. He had a head start because he’s a Karabiner-Elements user and Karabiner makes it easy to do the sort of thing described by Raman.

Take a look at Friesen’s post for the details. Not everyone will want to do this but if you think your workflow could benefit from overloading modifier keys to provide additional shortcuts and eliminate some chording, it’s nice to know it’s possible for Mac as well as X Windows users.

Posted in General | Tagged | Leave a comment

Better Ergonomics Under X

T V Raman has a post that may be interesting to those of you who run Emacs under X. That’s probably just about everybody who isn’t using a Mac so many of you may be interested. The TL;DR is that his method turns the modifier keys into what he calls buttons. For example, (with his setup) pressing (just) the Ctrl key will send Ctrl+e to Emacs.

His keyboard has three modifier keys on each side of Space and adding the two Shift keys gives him eight possible “buttons”.

The key to making this work is the xcape command in the Xorg keyboard configuration to define what each of the buttons produce. Raman links to his xcape and XModmap configurations so you can see how he set things up but you’ll probably prefer other mappings.

The advantage of Raman’s method is two fold:

  1. It avoids chording for commonly use commands.
  2. It gives you several (8 in Raman’s case) extra keys to do something useful with.

If you’re an X user and interested in improving your keyboard ergonomics or perhaps just gaining some useful shortcut keys, take a look at Raman’s post. If you’re not afraid of modifying your XModmap file it’s not hard to set up.

UPDATE [2023-02-17 Fri]: Added link to Raman’s post.

Posted in General | Tagged | Leave a comment

Tempo Templates

Nicolas Martyanoff has a post on something I didn’t know about: Emacs Tempo templates. I’ve been an Emacs user for somewhere between 15 and 20 years and I’d never heard of Tempp templates. On the one hand that’s pretty surprising. On the other hand, we all know that learning Emacs is a lifelong journey that is never completed.

As most of you know, I’m a Yasnippet user and find it very useful even for non-programming chores so I’m not in the market for another templating engine but if you’re new to templating, Tempo may be worth a look. I don’t have any experience with it, obviously, but based on Martyanoff’s description I’d judge that Yasnippet is easier to use and learn and seems more flexible too.

Martyanoff says that one of the virtues of Tempo is that it’s simple but I find it harder to use than Yasnippet so my advice to the template n00b is to use Yasnippet. Still, as always, Emacs let you have your way. Along with skeletons there are three1 template systems you can use with Emacs so there are plenty of choices.

Footnotes:

1

Unless there’s yet another Emacs templating system I don’t know about.

Posted in General | Tagged | Leave a comment

Emacs Comes to Android

Here’s some good news: The F-Droid site now has a more or less complete implementation of GNU Emacs for the Android platform. I’m not sure Emacs on a phone is all that useful other than for dealing with Org files and there are several apps already available for that on both the Android and iOS platforms. On a tablet, though, it could be a real game changer. Emacs on a tablet—perhaps with a real keyboard—would enable truly remote work. Yes, you can carry your laptop around as many of us do but a tablet is much easier especially in situations such as air travel.

We here at Irreal are famously iPhone/iPad users so F-Droid’s announcement doesn’t affect us directly but perhaps it will encourage Apple to relax their no interpreters rule on the platform. I understand their reasoning but having a workable Emacs on the iPad would be such a win that it would be worth it, especially with appropriate sandboxing.

If we had Emacs on the iPad it would change my mobile computing strategy completely. I’d get a good keyboard for the iPad and probably almost always leave my laptop at home. The iPad, modulo software, is already as powerful as many laptops and could easily support remote work. I have a family member—in banking not software—who already uses his iPad as his exclusive mobile device. There’s no reason we developers couldn’t do the same. All we need is Emacs. I love my laptop and don’t foresee myself ever giving it up but it sure would be nice to have an easy-to-carry device for remote work.

Posted in General | Tagged | Leave a comment

Clocking and Status Changes

Just a quickie today courtesy of Mario Jason Braganza. Like most developers, Braganza is lazy in that good way that makes us search out ways to automate mundane tasks. Sometimes the automation doesn’t save much—or even any—time; it’s the principal of the thing. That and the prevention of the mental exhaustion resulting from the need to perform boring, repetitive tasks.

In Braganza’s case, that boring task is clocking in and out of tasks with a status of IN_PROGRESS. This isn’t an optimization that’s going to save any appreciable amount of time but it does collapse two tasks into the one task that it logically is. Check out his post for the exact problem that he’s trying to solve.

Although the solution is simple, he spent a day researching the problem to find it. That’s certainly more time than he’ll save in a lifetime of using the fix but it does address the all important issue of programmer mental fatigue. That and the satisfaction he gets from optimizing his workflow, even if in a small way.

Posted in General | Tagged , | Leave a comment

Red Meat Friday: A Close Call

I’ve never understood the allure of Twitter. It is, without doubt, a toxic environment1 and while it may, according to whom you ask, have become more benign under Musk it’s still not, by and large, a place sensible people want to be.

Leave it to the Babylon Bee to perfectly capture the Zeitgeist:

Footnotes:

1

Yes, of course there are exceptions but the predominate vibe is take-no-prisoners political vitriol.

Posted in General | Leave a comment

Finding The Link To An Org Attach File

Matus Goljer (Fuco1), whose work I’ve written about many times before, has an interesting post on his use of org-attach. The point of the post is a way of automating the finding of the Org headline that points to an attached file. Normally, that’s not a problem because you’re starting with the Org file but occasionally you search for the attached file directly outside of Org and want to find the Org entry that points to it.

To me, the part of the post that resonated the most was that org-attach provides a way of avoiding the agonizing decision making that goes into deciding where to store documents in the file hierarchy. In that respect, it sort of reminds me of my email strategy. Following Ben Maughan, I store all my saved emails in a single flat file and use the excellent mu4e search capability to find them. It really is far superior to trying to figure out where in a complex file hierarchy the email belongs.

The same is true in storing a file related to an Org file heading. Rather than trying to figure out the proper place to store it, you simply let Org worry about where it is and use Org’s search and linking capabilities to find it.

Goljer’s post is short and worth a read. It’s another example of how Emacs and Org mode can make your life easier.

Posted in General | Tagged , | Leave a comment

A Brief History of Sun Microsystems

If you’re involved with computer/software engineering and aren’t just starting out, you’ll be familiar with Sun Microsystems. For a long time their computers seemed to many of us to be the very apotheosis of a “workstation”. Many software folks still consider SunOS 4.1.3 to be the best commercial Unix implementation before or since.

Sadly, Sun was caught up in the rise of cheap Intel-based workstations running Linux and was unable to adapt to the market changes. The once powerhouse was finally bought by Oracle and effectively disappeared. The most salient extant Sun product is Java. Its hardware and most of its software has simply disappeared.

It’s easy to see why. When I was coming up, Sun machines were too expensive for most individuals and found use mostly as servers and high end workstations for well healed corporations. On the other hand, most folks could afford a cheap Intel machine running Linux or one of the BSDs. These days, Intel/Linux machines have taken over most of the server market as well.

Asianometry has an interesting video that provides a short history of the rise and fall of Sun. It follows Sun from its inception as a Stanford project to its acquisition—and dismantling—by Oracle.

Sun is an important part of our shared history and their hardware and culture are an important part of our story so it’s worth understanding their part in that history. The video is 18 and a half minutes long so plan accordingly.

Posted in General | Tagged | Leave a comment

The Loop Macro Explained

If you’re a Lisper, you’re probably aware of the loop macro controversy. Few people are neutral: they either love it or hate it. I’m in the latter group. Although I’ve gotten to where I can mostly read a loop macro and figure out what it’s doing, I would never use it to write code. My objections are two-fold:

  1. Its syntax is not at all Lisp-like and requires a paradigm shift to use.
  2. It’s not really documented. Paul Graham remarks that it’s code is the documentation.

Gavin Freeborn is in the other camp. He loves the loop macro and considers it one of the best parts of Common Lisp. Unlike me, he considers its declarative syntax a feature. He thinks the loop macro is “the best form of procedural iteration that I’ve ever seen.” He has a video on the loop macro that regardless of which camp you fall in you’ll probably find useful.

One thing I really liked about the video is that he precedes each keyword with a colon—something not strictly required—making it much easier to mentally parse the loop invocation. If you’re like me and are not a loop aficionado, you’ll find the video useful because it will help you understand what’s going on when you run across the macro in other people’s code. If you don’t mind the idea of loop but are not an expert, the video serves as a good introduction.

The video is just short of 21 minutes long so you’ll need to schedule some time. If you’re not a Common Lisper but want to experiment with the macro, Elisp also has a version (officially called cl-loop but loop is still accepted) that you can play with from the comfort of Emacs.

Posted in General | Tagged , | Leave a comment

Supercharge Your Workflow With Yasnippet

I’ve long been an enthusiastic Yasnippet user and have written about it a few times. Its canonical use case is in programming to fill in primitives such as the for loop in C or a class definition in Python but I rarely use it that way. I mostly use it with Org files to do things like create the header for blog posts, add boilerplate, do simple expansions like latex → LaTeX, insert daily checklists into my journal, and add code blocks to my blog posts.

These are all pretty simple operations that don’t begin to use all that Yasnippet has to offer. Jack of Some has an excellent video on how to superchage Emacs with Yasnippet. He does, of course, cover simple text substitutions but he also shows how to use its more advanced features.

One particularly nice example is his expansion of a Python class definition. As he adds arguments to the definition, the snippet automatically adds the code to initialize the instance with the arguments’ values. More generally, he shows how you can embed Elisp into the snippet template to do non-trivial things like insert the name of the current file into the text.

One thing I didn’t know how to do was to add “global snippets”. Usually snippets are only active for a particular type of file but it’s possible to have snippets that are always available. Take a look at the video to see how to do this.

The video is two years old but I just came across it. It’s definitely worth a few minutes of your time. It’s a few seconds over 12 minutes long so it should be easy to fit into your schedule.

Posted in General | Tagged | Leave a comment