Emacs Popup Frames

Protesilaos Stavrou (Prot) has posted a really nice and useful video on something that I’ve been struggling with off and on for many years. The problem is I often want—usually several times a day—to pop up an Emacs buffer and run some command like org-capture. There’s no problem with that, of course, if I’m in Emacs but what if—as is often the case—I’m in some other app?

The basic strategy is to call emacsclient with a -e parameter specifying whatever Emacs command you want to run. The devil, as they say, is in the details. First of all, you have to arrange for an Emacs frame to hold the popup menu and then you have to arrange for it to be deleted when you’re done.

Prot provides a complete, easy to understand framework for all of this. He defines a macro that lets you specify an Emacs command for a popup. You need only specify an OS level key binding to call the function and identify a hook function that will call the function to delete the popup frame when the command is done—most other situations are handled by the code generated by the macro.

I’ve tried to solve this problem with everything from some Applescript to Alphapapas yequake. I’m currently using yequake and it works well for me but if I were starting out I’d definitely take a look at Prot’s code. It’s self contained, easily understandable and hackable, and can be adjusted to your particular use case. All you need is a way of binding an OS level key sequence to the appropriate command. If you need to execute Emacs commands from outside of Emacs, take a look at Prot’s code.

Posted in General | Tagged | Leave a comment

🥩 Red Meat Friday: More Red Meat For Emacsers

You can think of today’s post as a coda to last week’s Red Meat Friday. Unlike that post, this week’s offering isn’t really about the editor holy war. It’s about Emacs versus every other editor out there, which is a different thing.

As you know, I don’t really take sides in the Emacs/Vim debate. I think they offer different things to people with different needs. The rest of those editors though… Well, you all know my feelings about editors and their users who prioritize bling over efficiency: If your editor uses menus exclusively and you have to click to do anything then, sorry, your editor isn’t efficient.

Of course, none of that will matter because those editors are “modern” and Emacs is old and used only by boomers. Or something. Doubtless, some of those people will have the scales fall from their eyes and discover true editor efficiency. Sadly many others will never make that discovery and will end their days clicking on menus and using the arrow keys.

But this is, after all, Red Meat Friday so enjoy the red meat now because tomorrow we get back to serious stuff.

Posted in General | Tagged , | Leave a comment

Speaking Of Emacs Keyboards

After my last post on ideal Emacs keyboards, here’s a reminder of what reality actually looks like. When I used to see pictures like that, I thought they were amusing but couldn’t really relate. Now my own laptop keyboard is showing the same signs.

Oddly, it’s not the Ctrl key that’s showing wear but the Meta key, otherwise known as ⌥ Opt in Apple land, that’s showing wear. That’s probably because I have Caps Lock bound to Ctrl but I use both it and Ctrl depending on the situation. That means that Ctrl gets only half the use it otherwise would.

The other key that’s showing wear is my left ⌘ Cmd key. For Emacs purposes that’s bound to Super but I rarely use it for that. Its wear is probably due to its central role in Apple navigation.

When your Emacs keys begin to wear out, it’s probably a sign that it’s time to upgrade your laptop—or get a new keyboard if you’re using a desktop. I actually have a new laptop ready but it uses the new M-series processors so upgrading is not as easy as I’d like. Still, it’s obviously time to get on with it.

Posted in General | Tagged | Leave a comment

The Ideal Emacs Keyboard

If you’re a real Emacs aficionado then you probably think that the ideal—indeed, the only acceptable—keyboard for Emacs is the Space Cadet Keybord. I’m sympathetic to that view and would love to have such a keyboard available to use. Sadly, that’s not likely to happen so we’re reduced to choosing from one of the actually available keyboards.

They’re all basically the same but there is enough difference to allow one to start with a keyboard that can be customized. Over at the Emacs subreddit, drojd specifies their ideal Emacs keyboard layout. I agree that it’s pretty nice and, indeed, it’s pretty close to what I use on my Mac keyboards.

The main problem1 for us Emacs users is finding a reasonable mapping for HYPER and SUPER. I’ve been through several iterations for these mappings. The problem, for me, is that macOS keeps appropriating the keys I use for those modifiers. Doubtless, other operating systems have similar problems. My current configuration has worked for several years so I’m hopeful that I won’t have to learn new bindings anytime soon.

When I look at the diagram in drojd’s diagram what strikes me is that it’s really only HYPER and SUPER that need to be specified. To be sure, I’d like a Space Cadet keyboard but any modern keyboard will do as long as you can make reasonable mappings for HYPER and SUPER.

One can—just barely—get by without HYPER and SUPER but why would you want to? My main use for them is not for whatever their defaults bindings are but to expand the number of available bindings for my own commands.

Footnotes:

1

Well, after getting Ctrl into a reasonable position but virtually every Emacs user already remaps Caps Lock to Ctrl.

Posted in General | Tagged | Leave a comment

Word Diff Counter

Chris Maiorana has an interesting take on counting words. He’s a writer and like all writers, he’s interested in how many words he’s written in the current session. His reasons for wanting that count boils down to it providing a measure of his daily work and, perhaps more important, helping him to know when to stop.

But, he says, there are some problems with word counts as usually implemented. The most important concerns the way that many (the majority of?) writers work. They like to reread and edit what they wrote in their last session. That means that words may be subtracted as well as added. What’s really needed, he says, is a count of the number of words that have changed.

His solution for that is to use git diff to find out how the text has changed and count the number of changes. It’s a bit fussy as you’d imagine but really pretty straightforward. Take a look at his blog post for the code and details.

I love this idea but I’m not sure it’s for me. For long form writing, what I’m mainly interested in is progress so knowing my current word count—regardless of additions or subtractions—is what’s important to me. For short form writing, such as this blog, I really care only about the total word count since I almost always complete a post in a single session—not counting a final editing pass just before I publish it—and I’m never in any danger of burning out while writing a single post.

Still, if you’re a writer and interested in measuring your work rather than your progress, Maiorana’s hack may be just what you’re looking for. You’ll need to keep your text in Git but you should be doing that anyway.

Posted in General | Tagged | Leave a comment

An Early Emacs Paper

For those of you interested in the history of Emacs, how it all started, and where it got its name, here is an original document from 1979 written by Richard Stallman that describers the new Emacs system.

I found the paper in this this post that references an update to the original paper. EricIO added a pointer to the orginal paper that I’ve linked above. There’s a lot of good information in the comments including a Twitter thread that discusses how Stallman eventually settled on the name Emacs.

For the day-to-day programmer, none of this matters a bit but for those of us who care about our backstory and how we got here, it’s a nice addition to the narrative. The whole thing—other than the actual paper—is short so take a look if you’re interested in our history.

Posted in General | Tagged | Leave a comment

Some Notes On The Culture

Virtually everyone here knows that I’m a huge fan of Iain M Banks’ Culture novels. Indeed, the name “Irreal” comes from an idea in his 1996 novel, Excession. I’ve read all the Culture novels except the last one, which I’m saving to savor at a later time given that Banks died tragically young and the series came to an end.

I just came across these notes on the Culture from Banks. In them, he lays out a mostly complete world view of the Culture and how it operates. Considering that the Culture is, after all, a fictional entity, it’s an amazing complete and coherent description. Even if you’ve haven’t read all the novels—or maybe especially if you have read all the novels—you should take a look at this. It’s long but discusses lots of things that you may have missed when you read the novels.

Banks’ essay is hosted on Trevor Hopkins site, which also lists 3 novels and several short stories that he’s written that take place in the Culture universe. I just found his site so I haven’t had a chance to read any of his stories yet but I’m hopeful that they’ll feed my appetite for Culture stories.

As I’ve said many times before, if you like Science Fiction you should definitely read these novels. They describe a universe in which I, at least, would love to live. In the Culture you can do pretty much whatever you want and the society takes pains to prevent those with a will to power from gaining it. What’s not to like.

Posted in General | Tagged | Leave a comment

Org For Writing And More

Aditya Athalye has a nice post on how he uses Org-mode for writing and more. Like most Org users he started using it for a single task and discovered, as he went along, that he could also use it for other tasks.

Like me, his main use is writing. He writes his blog, his talks and most everything else in Org. As I’ve said many times before, I hate writing in anything else. The thing about Org—when run natively in Emacs—is that you get all the advantages of Org markup along with the superior editing environment provided by Emacs. I would use Org even without Emacs but I wouldn’t enjoy it nearly as much.

As Perry Metzger recently said in an Irreal comment, Emacs really does provide a superior editing environment that makes editing text much easier than in other editors. If your priority is efficient text entry and editing rather than bling, it’s a no-brainer. Take a look at Metzger’s comment for one of many reasons why.

Athalye considers, among other things, why you should use Org markup instead of Markdown. Both are way better than the WYSIWYG editors but Org is I think the better alternative. Karl Voit agrees. One of the main ways that it’s better is Babel and the way it enables “live documents” that rewrite themselves when the data they describe changes.

Another advantage is that’s there’s only one Org whereas there are several flavors of Markdown. This is mainly due to the tight coupling of Org markup with Emacs and could change if Org markup obtains enough traction in other editors. That’s why Voit, at the above link, argues for a standardized Org markup that’s the same with every editor.

If you want to see some good reasons for why the effort of learning Org is worthwhile, take a look at Athalye’s post.

Posted in General | Tagged , | Leave a comment

Red Meat Friday: A Poetic Incursion Into The Editor Wars

Here’s a bit of Friday Red Meat for all you Emacs partisans in the eternal editor holy war.

Before you flame me, please keep in mind that I was a long time Vim user and often write approvingly of it. As I’ve often said, these days the editor wars are more about comic relief than a serious dispute. The real point of contention is not the editors themselves but the workflow that they engender.

Some people want a Lisp Machine, others want a small, fast, editor that’s good at editing and nothing more. The nice thing is that the Emacs/Vim duopoly lets you choose the environment most comfortable to you.

Anyway, enjoy the short diversion and get back to work. After all, we all have serious matters to deal with.

Posted in General | Tagged , | Leave a comment

Emacs Pretest 30.0.91

Andrea Corallo has just announced that the first Emacs 30 pretest (30.0.91) is available for download and testing. You can check the NEWS file to see what’s new in the release.

As always, thanks to Eli, Andrea, and all the other devs who worked so hard to bring us this release and who keep Emacs a vital and thriving enterprise. The release of this pretest means that the release cycle for Emacs 30 is underway and we can expect the first release candidate sometime soon depending on how many errors are discovered in 30.0.91.

The developers depend on the Emacs community to help find those errors so if you can, please download and test the new version. It will help us all and move Emacs 30 closer to the official release.

Posted in General | Tagged | Leave a comment