Charles Choi on Imenu

Charles Choi has an excellent post on imenu. I’ve used it for a long time via the excellent councel-imenu but I’ve never really understood its scope or essential raison d’être. I’ve always thought of it as a way of locating functions and variables in a programming language buffer but that turns out to be a very circumscribed view of its purpose.

Choi has a much better explanation. He explains that what it really does is index many types of files that have some sort of definitions. This includes programming language files, of course, but also text files such as Org, Markdown, and other structured files.

You can get a feeling for how it works by trying it out on various types of files. It’s builtin so there’s no need to load it or do anything special to try it out. If you’re a swiper user, I recommend binding some easy binding to councel-imenu. I have it bound to Ctrl+. so it’s easy to invoke. Councel-imenu will bring up a completing read list of targets in the minibuffer that makes it easy to select the target.

Take a look at Choi’s post for other ways of using imenu. If you’re a menu user, you can easily add it to the menu. If, like me, you avoid the mouse, imenu is completely accessible through the keyboard. Choi recommends having it enabled by default but I find that having it an easy key shortcut away works well for me.

Posted in General | Tagged | Leave a comment

Programming Fonts

Many, many years ago I adopted the Inconsolata font because it was one of the first widely available, free, antialiased programming fonts. In those days, I was still using Vim but when I moved to Emacs, I brought it along with me. From time-to-time I see recommendations for the “ultimate” programming font but I always stay with Inconsolata.

Once you’ve dealt with antialiasing, I think that the critical aspects of a programming font are:

  • Distinguishing between oh and zero in a visually obvious way
  • Distinguishing between el, eye, and one in a visually obvious way

It’s a bit shocking how many fonts get this wrong.

Over at Evil Martians there’s a nice post on what constitutes the perfect coding font. That includes my desiderata about 0, o, O, i, I, l, L, 1 but also considers additional characters than can cause confusion. The post recommends

  • Widening the various brackets types so they can be more easily distinguished
  • Making the hyphen and the minus signs the same
  • Making ^ and * resemble the corresponding mathematical symbols
  • Mathematical symbols, ticks, and quotes should not be too small
  • Slashes and bars should be centered

These are all useful criteria but I’m happy if I can distinguish zero and one from other characters. The comments over at reddit suggest all sorts of recommendations for the perfect programming font but, as I say, I’ve been happy with Inconsolata for a long time and probably won’t be changing.

Posted in General | Tagged , | Leave a comment

EmacsConf 2024: Call For Participation

Planning for the 2024 EmacsConf is underway and the organizers are calling for participation. “Calling for participation” means they’re asking folks to submit proposals for talks. The conference will again be virtual and take place on December 7th and 8th.

If you’re interested in contributing, the organizers would like to hear from you as soon as possible but in any event by September 20. Your talk can be short (about 5–10 minutes) or long (about 20 minutes). If you’d like to give a longer talk, that can be arranged too: get in touch with the organizers.

EmacsConf is a great way to share your ideas and get some exposure. It’s virtual so there’s no expensive travel involved. Even if you are unavailable for questions on the day(s) of the conference, the organizers can accommodate that so if you think you have something to say, sign up for talk. The talks are prerecorded so you don’t have to worry about stage fright.

These conferences are a font of great ideas so whether or not you give a talk, be sure to be there. Even if you can’t be there, the talks will be available as recordings so you can enjoy them at your leisure but you won’t be able to join in the after talk discussions.

Posted in General | Tagged | Leave a comment

Gotos Considered Maybe Not Harmful

Way back in 1968, Edgar Dijkstra published a famous letter to the Communications of the ACM that explained why he felt the go to statement was being abused. Ever since then, lots of uninformed folks who haven’t bothered reading it and have missed the nuances in Dijkstara’s argument have been invoking it in what amounts to a jihad against using gotos in any circumstance. The letter almost wasn’t published because the editors felt it wasn’t that interesting and the famous title, “Go To Statement Considered Harmful” was actually written by one of the editors not Dijkstra.

The truth is, there are lots of circumstances in which gotos make perfect sense. I’ve used them myself but I always felt the need to document why my use didn’t violate some sacred dictum by referring to this paper by Knuth in the source code. It saved me a lot of pushback and I could tell those who persisted in arguing the point to direct their comments to Knuth.

Now Joe Marshall offers another example of acceptable goto use. It’s not clear from his post whether he’s using an explicit goto or merely pointing out that gotos occur implicitly in all programming languages. Certainly, the example of tail recursion is like that. His point is that tail recursion is simply a goto even if there’s no explicit goto involved.

The use of gotos that Dijkstra was arguing against is clearly a bad thing but that doesn’t mean that their use in specialized situations is a sign of sin.

Posted in General, Programming | Leave a comment

Favorite Emacs Utilities

Over at the Emacs subreddit, Phovox—a 30-year Emacs user—asks what your favorite Emacs utilities are. He’s started using Doom Emacs and has discovered, through Doom, utilities that he didn’t know about. So he’s wondering what else he may have missed and is asking the community what they recommend.

Some of the answers were general things like the ability to use Emacs to change virtually any part of Emacs to suit your preferences. Others were more on point and included things like Dired, Hippie-expand, the classical version control system, Ediff, Magit, Calc, Org, Projectile, LSP, and Replace-regexp.

Some of the other commenters mentioned third-party packages such as Hyperbole and Everything.

The best advice, I think, came from Wumpitz. That is to spend some time with the Emacs manual. It’s too much to try to read it straight through, of course, but you can decide to read one chapter every day or week. It is, says Wumpitz, amazing how much you don’t know about some of the basic utilities.

All the action is in the comments so take a look to see if there’s some utility you should be using but aren’t.

Posted in General | Tagged | Leave a comment

Emacs For Writing

There’s a great question and answers post over at the Emacs subreddit. The question, from lynnlei, asks how a prose writer who has been using Vim should approach moving to Emacs. This comes up a lot, of course, and it’s always the comments that provide value. I like reading them because I almost always learn something new about Emacs.

That’s certainly the case here: I learned about org-novelist, which will be the subject of an upcoming post even though, as I recently said, I don’t write novels. Even so, it has lots of capabilities to help with any long(ish) form writing.

The rest of the comments are interesting and helpful too. There’s no ankle biting or silliness so you might learn something useful for your own workflow.

A lot of the things we Emacers take for granted seem mysterious and marvelous to immigrants so posts like this are really useful to get new users oriented. They’re also useful to introduce oldtimers to Emacs features that they were previously unaware of.

Lynnlei said she wasn’t interested in Evil, even though she is coming from Vim, and that leads to some interesting discussions on packages that are probably best thought of as “evil-light”. Whether you’re coming from Vim are or an old-time Emacs user, there’s probably something worthwhile for you in this post. The comments are definitely worth perusing.

Posted in General | Tagged | Leave a comment

BOM Characters From Windows Files

It’s been a slow day on the Intertubes for Irreal material but I do have something that might interest those of you who have the misfortune to be running Emacs on Windows. Just the other day, we discussed the sad fact that Emacs on Windows can be slow. Despite the tone that my posts on Windows often take, I do want Windows users to be able to enjoy all the benefits that Emacs offers.

One of the problems with Window/Unix interaction is that they made slightly different decisions about file formats. That mostly manifests itself in Windows using CR LF for EOL while Unix uses LF. This isn’t just a matter of Microsoft’s contrariness. The choice of CR LF was reasonable at the time.

Over at the Emacs subreddit, BrainFuckPlusPlus talks about another problem with using Emacs on Windows. He’s an Emacs user working in a shop dominated by VSCode users. Apparently VSCode saves files with a BOM sequence starting the file and he was trying to get Emacs to ignore the BOM by setting the Emacs coding method. He found a solution but that solution caused problems in another area.

That brings up another remarkable aspect of this story. BrainFuckPlusPlus’s question was answered by Eli Zaretskii, the main Emacs maintainer. This was an obscure question on reddit, not the Emacs-Devel mailing list, and yet Zaretskii took notice and explained what BrainFuckPlusPlus should do to resolve it.

Zaretskii, like most FOSS maintainers, doubtlessly has a job and a family demanding first claim on his time but he still found a few minutes to help an Emacs user with an arcane problem. It’s yet another demonstration that Eli and the other devs don’t get nearly enough credit.

Posted in General | Tagged | Leave a comment

One Line Per Sentence

Chris Maiorana has another thought provoking post that advocates the use of one line sentences. The idea is that each sentence ends not just with a period but with a newline. That seems a little unnatural but has a lot to recommend it.

I don’t do that anymore but I used to. I wrote two books where every sentence was a separate line. This was before my Emacs days so I was using Vim but it worked pretty much like it would in Emacs. If the sentence was long, the line would wrap to fit on the screen but the wrap was virtual, much like Emacs’ visual-line-mode. Actually, using visual-line-mode means that paragraphs rather than sentences are the single lines but no one ever thinks of it that way.

I no longer remember why I used the one-line-per-sentence method for my books. It probably had something to do with the fact that they were written with Groff but as Maiorana says, there are lots of good reasons to recommend it. You can check his post for some of those reasons.

As with most things, Emacs—and in particular Org mode—has you covered. There are commands for moving between sentences and for moving those sentences up and down. That makes it easy to switch sentences around while you’re editing. None of that depends on one line per sentence, of course, but works seamlessly if you prefer that way of working.

My view is that Emacs and Org mode do away with a lot of the reasons to use one line per sentence but, of course, you like it for some of the reasons Maiorana offers or for others, Emacs has you covered. Even if you have to mix methods, Emacs will work the same way.

Posted in General | Tagged | Leave a comment

Why SICP Matters

All you Irreal oldtimers know that I’m a fanatical fan of Abelson’s and Sussman’s Structure and Interpretation of Computer Programs (SICP). It is, I think, arguably the best computer science book ever written. You oldtimers also know how bitterly disappointed I was when MIT abandoned SICP and the course built around it. I’ve never accepted nor found convincing the rationale for that change.

I discovered SICP late in my career and even though I was well past the age when fundamental change was supposed to be possible, it completely changed the way I thought about and approached our craft. It was literally a life changer.

In 2011, to celebrate MIT’s 150th birthday, Brian Harvey, a Berkeley professor, was asked to write an article on why SICP was important. Here it is. It is, at the same time, inspiring, bittersweet, and infuriating.

It’s inspiring because it states clearly and convincingly why SICP is the right thing and how much better it is than other introductory courses that spend most of the semester discussing the syntax of whatever (non-Scheme) language de jour they’re using.

It’s bittersweet because Harvey recounts how SICP affected his students even though some of them didn’t realize its profound effect until years later. That would be fine except that in his essay Harvey wondered if SICP would survive his retirement. Sadly it didn’t—see his post.

Finally, it’s infuriating precisely because the fight was lost. All the people who wanted to talk about robots and program in Python won. Robots and Python are important things to learn about but they don’t teach you how to think about programming. They mainly teach you how to use libraries. That’s also important, of course, but shouldn’t we teach students about fundamentals and how to think about programming? Apparently not.

If you care at all about SICP and the culture that it engendered, take a look at Harvey’s essay.

Posted in General | Tagged , | Leave a comment

Casual Suite

Charles Choi has made good on a promise he made in his post announcing a name change for some of his early Casual packages. In that post, he said he was going to bundle all the current and future Casual extensions into a single package.

He’s honored that pledge and the new Casual Suite is available for download on MELPA. It’s the best of both worlds. If you want all the current and future porcelains, you can install the Casual Suite package. If, like me, you prefer to load only some of them, you can do that too because the individual porcelains are available on MELPA too.

As I’ve said before, these packages are a real win. The only time you need to invoke them is when you want to use some aspect of the target UI that you seldom need and don’t remember the shortcut for. The menus are never shown unless you explicitly call them.

Posted in General | Tagged | Leave a comment