Navigating In View Mode

Emacs view mode is one of things that might seem superfluous at first glance. After all, you can always just visit a file and use the normal navigation commands to view the file. But there’s a lot to be said for a read-only file viewer—think less, more, or other pager utilities—that let’s you page through the file without worrying about accidentally introducing a change.

The normal view mode protocol is to use Space and Delete to scroll forward and backward like Ctrl+v and Meta+v do. It’s a nice and convenient way of viewing a file that you don’t want to edit.

Charles Choi agrees with all that but wants a richer protocol. For instance, if he’s in an Org file, he’d like the movement to be forward and backward to the next heading. Once you make that leap, you realize that other file types could also benefit from specialized navigation commands. He has a post that explores the idea of file type naviation in view mode.

He presents some code to do this for several file types and it would be no problem to add other file types as well. Even if you don’t know Elisp, it would be easy to follow the cases he presents to add your own.

View mode is an underused feature of Emacs and Choi’s enhancements make it even better. Take a look at his post and see if you don’t agree.

Posted in General | Tagged | Leave a comment

New AWK Book

Long time Irreal readers know that I’m a fan of the AWK language. Whatever OS you’re using, AWK is sure to be available. It’s installed by default on all Unix/Linux systems and may be on Windows as well. Linux systems probably use gawk by default but even it’s usually linked to awk. There is, in any event, at least one version for your system.

A year ago, I wrote about a Brailsford & Kernighan video where they talk about AWK and how Kernighan was updating it to support Unicode [1, 2]. Kernighan mentioned that as part of that effort he was updating the AWK book. The original book was written 1988 and while you can still get it, the price is exorbitant. Now that work is completed and the new book will be released on 2023-10-01. That’s good news for younger engineers who don’t have $100 to spend on the original.

I haven’t seen the new book, of course, but the original was excellent. Towards the front of the book they had a series of AWK one-liners that performed all sorts of useful tasks. Kernighan has said that he, Aho, and Weinberger had imagined that that was the way the utility would mostly be used but it’s been used for all sorts of more complicated programs, often by Kernighan himself. You can see some of those at the book link above.

I think it’s wonderful that AWK, a program dating from the 1970s, is still under development and that there’s a brand new book documenting it and its use.

Posted in General | Tagged | Leave a comment

Batch Mode

If you’re an even moderately experienced Emacs user, you probably know about batch mode. You can write a file with some Emacs commands and run it either by calling Emacs on the command line with a --script parameter pointing to the file or by adding at #! line to the top of the script and running it by calling the script directly.

Emacs Elements has a short video on batch mode that describes a use case I hadn’t seen before. The video is only 5 minutes, 45 seconds so you can watch it to get the details but the TL;DR is that you can use batch mode to check a changed init.el file for errors.

The idea is that you use batch mode to load the modified init.el file. If there are any errors, you get notified but your active Emacs instance is still operable. It’s preferable to just restarting Emacs because if there’s a disabling error, you still have a working Emacs to correct it. Sure, you could always restart Emacs with a -q or -Q option but then you don’t really have a fully operational Emacs to work with. That happens to me a lot when I have an error in my init.el. I can get by, of course, but it’s a pain. With Emacs Elements’ method you still have your familiar and comfortable working environment available.

Posted in General | Tagged | Leave a comment

Live In Emacs Or Die

Today, we have a bit of humor that we can all relate to. Reddit has a post announcing the Web browser NYXT inspired by Emacs. I don’t know anything about NXYT but I did love this comment from noooit:

Comment
byu/evlogii from discussion
inemacs

Those of us who live in Emacs will relate. The rest of the universe will wonder what in the world we’re talking about.

UPDATE [2023-09-23 Sat 15:04]: NXYT → NYXT.

Posted in General | Tagged , | Leave a comment

Kitchen Sink

It’s often said of Emacs that it includes everything including the kitchen sink. Indeed, there’s even an Emacs logo reflecting this sensibility. I don’t know if it was ever an official logo but its use is widespread. Still, it would be easy to dismiss the notion as a bit of Emacs fanboy hyperbole.

Gopar has a short video that provides compelling evidence that Emacs does, indeed, include the kitchen sink and everything else. The video demonstrates two builtin functions. To say that they are obscure and little used would be an award winning understatement.

The first is a function that translates to and from Morse code. Just in case you want to know what “Emacs is amazing” looks in More code, Emacs has you covered:

./--/.-/-.-./... ../... .-/--/.-/--../../-./--.

The second functionality is to render text in the phonetic alphabet. I’m familiar with this from my pilot days, where it can increase clarity in radio communications, but didn’t expect to find it in Emacs core. If you want to know how to spell Emacs in the phonetic alphabet, here you go:

Echo-Mike-Alfa-Charlie-Sierra

Emacs calls this the “NATO alphabet”. I’ve never heard it called that before but whatever you call it, Emacs can render text into it and, of course, go in the other direction as well.

Again, these functions are builtin, not packages. They make the current agonizing over whether or not to add actually useful functionality to Emacs core look positively silly.

Posted in General | Tagged | Leave a comment

Zamansky: Learning Elisp #10

Mike Zamansky has popped in with another Learning Elisp video before he departs on his vacation. He didn’t want to start the next project and leave it hanging while he was away so this video covers some preliminaries. In particular, he covers some Elisp builtin data structures. That includes lists, pairs, vectors, hash tables, and association lists.

Vectors and hash tables have direct analogs in other languages and are probably familiar to all Irreal readers. Lists are simply linked lists and although they don’t have a builtin analog in most other languages, the idea is a common and familiar.

Zamansky explains how lists and pairs (single, unlinked cons cells) are implemented and then goes on to discuss the data structure that he’s planning to use in the next project: association lists. They’re sort of an intermediate structure, a bit like hash tables but lighter weight and not as fast. They’re the ideal key/value lookup method for small tables. It’s \(O(n)\) instead of the \(O(1)\) that hash tables provide but it’s perfect for relatively small lookup tables.

The next project is going to be about inserting emoji into a buffer and Zamansky is planning on using an association list to map the emoji name to the actual symbol. We’ll have to wait until Zamansky gets back from Europe for that but we can consider this video a teaser.

The video is 16 minutes, 16 seconds long so plan accordingly.

Posted in General | Tagged | Leave a comment

Emacs Writing Studio

As many of you know, I’m very interested in the use of Emacs for non-technical purposes. In particular, I interested in how prose writers and researchers in disciplines other than Computer Science and its close siblings use Emacs for their writing.

Peter Prevos has written a lot about using Emacs for writing and he’s gathered these posts together into an Emacs Writing Studio section on his blog. As Prevos puts it, “The Emacs Writing Studio configuration shows how to use Emacs to conduct research, write your prose and publish your text as an article, (e)book, or website.”

It’s an excellent resource conveniently broken into small easy-to-read articles. There are 28 articles—although some of them are only peripherally about writing. The other aspect of the Emacs Writing Studio is that it includes a downloadable configuration to get the n00b started using Emacs for writing.

In the reddit article about the Emacs Writing Studio, Alphapapa provides a link to his own collection of articles on using Emacs for writing that’s also worth taking a look at.

In his first article, Prevos notes that the right way to approach Emacs is to learn just enough to get started and then learn other details as they become necessary. As even moderately experienced Emacs users know, it’s a fool’s errand to try to learn everything about Emacs up front. Prevos suggests the same incremental approach that Irreal and others have recommended for Org mode.

If your principal activity is writing prose, you should take a look at Prevos’ site. It is, as I say, a nice resource.

UPDATE [2023-09-19 Tue 14:31]: Alphapappa → Alphapapa.

Posted in General | Tagged | Leave a comment

Mediating Remote Work Decisions With Gut Feelings

As most of you know to your sorrow, I have an obsession with certain non-computer subjects. The origins of COVID and remote work are two examples. Oddly, those two subjects have collided recently. With the end of COVID lockdowns, many companies are reconsidering their work-from-home policies.

A certain amount of the pressure to return to the office is driven by venal real estate concerns: both exposure to the real estate market and in some cases community requirements to have a certain number of employees present in the “downtown area”. That and that fact that hideously expensive office space is lying fallow provides a powerful financial motive for wanting employees back in the office.

Gleb Tsipursky has an article in Fortune that posits that a large part of the problem with the return to office movement is CEOs relying on the opinions of other CEOs and their gut feelings rather than data. He uses Amazon’s Andy Jassy as an example. When asked why he was insisting employees return to the office, Jassy’s answer was essentially that that’s what all the other CEOs were doing.

Some companies are making more nuanced decisions. For example, Salesforce looked at the data and discovered that new hires do better by being in the office and meeting their colleagues so they tailored their approach to take the data into consideration. They ended up with happier employees by fitting the policy to the individual.

As I’ve said before, work-from-home is here to stay and CEOs who wage a battle against it are risking their careers and the fate of their companies. As Tsipursky says, some positions require more on site presence than others and intelligent management will look to the data to discover what those positions are rather than instituting a one-size-fits-all policy.

Posted in General | Tagged | Leave a comment

Fixing The Emacs/Gnupg Problem

For some time there’s been a problem between Gnupg 2.4.1 and Emacs. Although you can decrypt files with Emacs—your .authinfo.gpg file for example—you couldn’t edit and save an encrypted file: Emacs hangs. This turns out to be a mismatch between the way Emacs and Gnupg expect to communicate the password and apparently it’s a hard problem to resolve. Until one or both apps are fixed you need a workaround.

The workaround is simple: downgrade to Gnupg 2.4.0. That’s not hard, of course, if you compile Gnupg yourself, but is harder if you use Brew to install it. There’s no easy way to do that with the standard Brew commands and the process that I’ve seen previously seemed a bit complex.

Álvaro Ramírez to the rescue. He has a post that gives us a simple procedure for doing the downgrade. Basically, you just download the Brew recipe and then install it using standard Brew commands. I’ve already done that and it took me less than a minute so there’s no reason not to follow his prescription if you’re having the problem.

Posted in Blogging | Tagged | Leave a comment

Emacs Bookmarks

Charles Choi has a new post that considers Emacs bookmarks. His idea is to make Emacs bookmarks as similar as possible to browser bookmarks. That makes sense and, I’m sure, works for lots of folks but I’ve gone in a completely different direction. My main objection to Choi’s method is that he uses a menu to access the bookmarks. Despite our detente1 on using proportional fonts for writing prose, we will probably never agree on the use of the mouse in Emacs. I consider every use of the mouse in Emacs a fail and go to significant effort to avoid it.

Choi is absolutely right that the default keybindings for dealing with bookmarks are obscure and hard to remember. I solved that with a hydra mostly stolen from abo-abo. You can read about it at the link but the TL;DR is that it gives me a fast and easy way to jump to a bookmark. That and the use of headlong-bookmark-jump makes opening a bookmark trivial.

That doesn’t address the other bookmark operations, of course, but I very rarely use them. When I do, I simply type Ctrl+x r (that much I can remember) and let the excellent whick-key tell me the correct suffix.

Finally, as suggested by Choi, I do use Bookmark+. I like it because it allows me to bookmark things other than files. For example, one of my bookmarks is to Irreal. When I invoke it, focus jumps to my browser and opens the Irreal site. It’s a real time saver and I use this all the time.

Take a look at Choi’s post. He’s got a lot of good ideas and you may find some you want to steal.

Footnotes:

1

Okay, my absolute surrender.

Posted in General | Tagged | Leave a comment