Unified Context Switching

James Dyer has a really interesting post on how he used a bit of Elisp to solve one of his workflow problems. He’d recently abandoned his use of save=desktop in favor of recentf. His reasons for switching don’t really matter—although you can read them in his post—but after opting for recentf he wanted a way to switch to contexts other than files. He wanted to be able to switch to a recent file, a buffer, a bookmark, or a new theme.

All that’s possible out of the box, of course, but Dyer didn’t want to worry about separate keybindings for each of them; he wanted a unified selection method. It took a surprising small amount of Elisp to get this done. A single binding invokes a completing read with all the files, buffers, bookmarks, and themes as possibilities.

Dyer shows the code in his post. It’s amazingly straightforward. The only complicated thing is that he uses some of the more esoteric capabilities of completing read, many of which I didn’t know about.

Even if you’re not interested in building a unified context switching mechanism such as his, his code is worth studying for what it reveals about the features of completing read. It’s a lot more capable than you probably think. As usual, with Dyer’s post, it’s short and won’t take you long to read.

Posted in General | Tagged | Leave a comment

Executing All Babel Buffers

Over at the Emacs subreddit, justrajdeep asks an interesting question: If you have several Babel source blocks in an Org document, is there any way to execute all the blocks and get their data with a single command.

I often have this problem when I have a document with two or more Babel blocks and want to export it. On export, every to block will ask me if I want to execute it. It’s not a huge problem but it is a bit annoying. My go to solution is to set org-confirm-babel-evaluate to nil temporally. After a while, I wrote a function to handle this automatically.

Karthink to the rescue. There’s a command, org-babel-execute-buffer, to execute every Babel buffer in an Org file. If you run it, every Babel buffer in the Org file is executed. Unfortunately, it still asks for confirmation before executing each block.

That’s easily fixed with a bit of Elisp. Here’s some code I whipped up in less than a minute:

(defun jcs-execute-all-buffers ()
  (interactive)
  (let ((org-confirm-babel-evaluate nil))
    (org-babel-execute-buffer)))

That code will execute all Babel buffers in the file without asking for confirmation. If you just want an easy way of executing all the blocks at one time and don’t mind authorizing each execution, then org-babel-execute-buffer is all you need. If you don’t want to have to okay each block, a bit of Elisp such as the above is all you need.

Posted in General | Tagged , | Leave a comment

How Google Is Trying To Kill RSS

Irreal readers know that I’m a big fan of RSS and use it as my primary means of discovering interesting content. Happily, despite the efforts of the content aggregators in their never ending crusade to wall in and control all of the Internet’s content, RSS lives on and may, according to some, even be experiencing a comeback.

The worst culprit in the anti-RSS campaign is, of course, Google. It’s not hard to understand why. It’s crucial that access to content passes through Google so they can track and monetize it. RSS makes this difficult so Google used it to capture user bases and then killed their support for it. This includes much more than their infamous sunsetting of Google Reader.

The Open RSS organization has a post from last August that describes How Google has helped destroy RSS adoption. As I said above, it’s much more than just abandoning Google Reader. You can get all the details at the link. Google, it seems, has fully embraced Microsoft’s Embrace, Extent, and Extinguish tactics with regards to RSS.

In one sense, I’m insulated from all this because my RSS solution—the excellent Elfeed— is self contained and doesn’t depend on Google in any way. On the other hand, any RSS reader depends on sites providing an RSS feed. By convincing users that RSS is dead, Google has persuaded content providers not to bother providing an RSS feed.

It’s just another item in the long and sordid list of crimes Google has committed in their total abandonment of their early motto of “Don’t Be Evil”.

Posted in General | Tagged | Leave a comment

Handling Comments When Joining Lines

Tony Zorman has an interesting post on joining lines in the presence of comments. If you’re like me, your first reaction is apt to be, “why should I care about this?” After a second’s thought, though, I realized that joining lines is something I occasionally have to do when I start writing an Irreal post in the wrong directory where visual-line-mode does not get set. Once I realize my mistake, I want to move the text to the proper directory and join the lines in each paragraph.

It turns out, of course, that there’s an Emacs command for that: join-line. I’ve always solved the problem by setting the line length to a large value and reformatting the buffer. Using join-line is a much better solution.

For me, that’s the end of the story but Zorman wants to use join-line in programming buffers and it turns out that join-line doesn’t care about or do anything special for comments. That means that

;; Several comments
;; in a row
;; like this

gets concatenated into a single line, which is definitely not what you want.

The majority of Zorman’s post details his solution to this. For comments that start with a single character, the solution is easy. A simple advice-add does the trick. For languages like Lisp, though the solution is harder because the convention is to start whole line comments with two or more ; characters.

For that case, Zorman has to modify the source code of the function directly. The final solution covers all the cases that Zorman cares about and you may find it useful too. Take a look at his post for the details.

Posted in General | Tagged | Leave a comment

Running Magit In Full Screen Redux

Life goes on and things change. Over 10 years ago, I wrote about a hack to run Magit in full screen mode. The hack—apparently from Magnar Sveen originally—was pretty simple. Here it is:

(eval-after-load 'magit
  '(progn
     (defadvice magit-status (around magit-fullscreen activate)
       (window-configuration-to-register :magit-fullscreen)
       ad-do-it
       (delete-other-windows))

     (defadvice magit-mode-quit-window (after magit-restore-screen activate)
       (jump-to-register :magit-fullscreen))))

You can tell it’s old because it uses the now deprecated defadvice.

I just read a post from Jeremy Friesen that does the same thing but in a more modern way. It takes advantage of some variables specifically provided for this type of thing. Take a look at Friesen’s post for the details. The TL;DR is that it’s even shorter than my version and probably protected from going out of date. It’s a nice solution.

On the other hand, my solution is, in a sense, universally applicable. You can, as I have, use it, mutatis mutandis, in a variety of situations. I use it, for example, to run eshell in full screen mode. Once you understand how it works, it’s easy to apply to any situation where you want to run something in full screen, even if the function doesn’t provide a special mechanism for it.

Regardless, if you’re lookng for a way to fun Magit in full screen (actually, in full window) mode, take a look at Friesen’s post for any easy way of doing so. It’s a good post and it’s short so it will take no time at all to read.

Posted in General | Tagged | Leave a comment

Buffer Specific Commands

Remember the other day when I said I almost always learn something new from Bozhidar Batsov’s posts? I just ran across another example. Batsov informs us that as of Emacs 29, there’s a new command called execute-extended-command-for-buffer (bound to Meta+X) that’s like execute-extented-command (bound to Meta+x) except that the candidate commands are limited to those that make sense for the current buffer. That means commands specific to the current major mode, enabled minor mode, and commands bound to the local key map.

This is useful for those (almost everybody?) who have some sort of completion mechanism in place for the minibuffer. It’s especially useful for those who, like me, sometimes can’t remember the exact name of the command they want to run and depend on the completion mechanism to find it for them.

Meta+X is marginally harder to type than Meta+x but not enough to discourage its use. I suppose that if you find yourself using it all the time, it might make sense to switch the bindings but I doubt that’s necessary for most users.

Thanks again to Batsov for letting us know about this command.

Posted in General | Tagged | Leave a comment

Custom Functions In Org Tables

Most Org users know that there are built in functions that can do things like sum some or all of the entries in a row or column of a table. The set of functions is actually much richer than simply adding up a column’s entries. It can, in fact, be any algebraic expression understood by Emacs Calc

But wait, there’s more. If you need something not covered by the builtin functions, you can define your own. It’s actually pretty simple and worth being aware of.

525G7bKV over at the Emacs subreddit has a short post that shows how to do it. The function part is an ordinary Elisp function that can make pretty much any calculation you need. That part shouldn’t present any problem to those familiar with Elisp.

The trickier—but not by much—part is specifying how to call the function in the table’s TBLFM line. Specifying what cells to use is done as usual and the function to call is placed in a '(...) construct. Check out 525G7bKV’s post and the documentation for the details.

Given the richness of operations accepted by Calc, you wouldn’t think you’d need a custom function but it comes up occasionally for me. It is, in any event, worth knowing that the capability exists in case the need arises.

Posted in General | Tagged , | Leave a comment

Yeetube

As I’ve written many times before, the Irreal bunker strives to be Google free. We mainly succeed in that endeavor with the single exception of YouTube. It’s far and away the best in class service of its type and more importantly it has no viable alternatives.

It turns out, though, that you can lessen the pain a bit. Michał Sapka has a nice blog post reporting on Yeetube, an Emacs wrapper around YouTube that lets you play YouTube videos (via MPV). It does away with the ads, has less tracking, and allows you to download and save videos for later viewing.

In addition to doing away with the worst aspects of YouTube, it lets you deal with the videos from within Emacs. I haven’t had a chance to try it out yet and I don’t know what the video quality is like versus native YouTube but it seems like a worthwhile project. Take a look at Sapka’s post for the details.

Posted in General | Tagged | Leave a comment

A Bit More On The Silliest Emacs Meme

Last Friday, I offered up a Red Meat Friday post that discussed the silly but depressingly widely held idea that Emacs is dying. As I said in that post, this is not an idea that’s held by anyone who actually uses Emacs but appears to be an article of faith held by those unwilling to spend the effort to learn Emacs at even a journeyman level.

Bozhidar Batsov also discussed this issue recently and dismissed it as the usual nonsense that should be ignored. He even says he didn’t bother reading the reddit post that occasioned Batsov’s and my subsequent posts. He does, however, provide a bit of evidence for one of my suppositions.

I speculated that Emacs usage as a percentage of the total possible user base has declined. Take a look at the chart he provides for the evidence. The TL;DR is that while VS Code holds 73.71% of that user base, Emacs is down at 4.69%. Notice that that figure says nothing about the total number of Emacs users. It may have increased, as Batsov suggests, or it may have declined. There’s probably no way of knowing.

One thing for sure, the Emacs editor is going strong, enjoying healthy development, and is probably growing, at least in total user terms. I’d be willing to bet that Emacs will still be going strong long after VS Code has faded into same obscurity being enjoyed by all the other would-be Emacs killers.

As of this writing, no one has bothered commenting on Irreal. That’s probably because Irreal readers are smarter than the average bear and consider everything I said obvious and not in need of further discussion. It was picked up by the Emacs subreddit, however, and there are plenty of comments there if you really want to know what others are saying.

Posted in General | Tagged | Leave a comment

The Roots of Unix

While researching for my post The History of C Compilers, I came across another post from Diego Crespo that was sort of along the same lines. This one, Tracing the Lines: From the Telephone to Unix, follows the early history of Unix and how it fit into the history of the telephone system.

Almost from the beginning, Bell instituted a research organization in his new company. It was called the Volta Bureau but its mandate was remarkably similar to that of the Bell Labs that it would evolve into. This was in 1880.

Years later, Bells Labs was a third of the Multics Project—along with MIT and General Electric—but eventually realized that the enterprise was a dead end and withdrew. By now, it’s a well know story that Ken Thompson found himself with nothing to do and started playing around with an essentially forgotten PDP-7. It was there that he first programmed his Space Travel game and later started experimenting with optimizing disk access.

Eventually, he realized that he was 3 weeks away from an operating system. Serendipitously, his wife chose that time to take their young son to visit her parents in California for 3 weeks. When she returned, the first version of Unix had been born.

Most of this work was done in secret because, after Multics, Bell Labs management wanted nothing further to do with operating systems. Thompson wanted a bigger machine but couldn’t get approval. Then he convinced the patent office that was looking for a system to deal with Bell Labs patents that they should get the machine he wanted and his group would write the software for it. That was so successful that the patent office bought them an even bigger machine (a PDP-11) to work on.

What I like about this story is that like a lot of great systems, Unix was the result of an individual programmer’s itch. Thompson was bored so he invented Unix. Try to imagine what would happen if Unix had been a management inspired project. Actually, we don’t have to imagine. We need only look to Redmond.

If this type of thing interests you, take a look at Crespo’s post. It’s a good read.

Posted in General | Tagged , | Leave a comment