Narrowing To Focus

Arthur A. Gleckler has a nifty post that discusses Emacs narrowing as a way to help with focus. The TL;DR is that sometimes you want to focus on a piece of code or other text and one way to do that is to temporarily remove all the surrounding text so that only the part you’re interested in is visible.

Emacs, of course, has you covered. It’s narrowing functions are just what’s called for. You can narrow to a region, a function, and various other parts of text. To a first approximation, it’s just what you need.

Gleckler, though, has an additional requirement. Sometimes he wants to look at the surrounding context and then return to the narrowed display. It’s easy, of course, to just widen the text, look at the context, and then narrow it again but that’s “complicated” enough that you can loose focus. He wanted a way to quickly pop in and out of narrowed displays.

He solved that problem with a bit of Elisp. The basic idea is that if there is an active region, he records the position of the region as an overlay with a special property and narrows to it. If no region is active, he looks for an overlay with the special property and uses its position as the inputs to narrow. Finally he binds a key shortcut to his function so that invoking it is as simple as it’s possible to be in Emacs.

The code is only a few lines and pretty easy to understand. If you’re interested in a similar facility or just want to see how he handled remembering which text to narrow to, take a look at his post. It’s short and easy to read.

Posted in General | Tagged | Leave a comment

BSD

Over at Abort Retry Fail there’s a very nice and comprehensive history and discussion of BSD Unix. I’m pretty familiar with most of this history but the article mentions some things that were new to me.

A good case can be made that it was BSD Unix that jump started the free software movement, although credit should be also given to AT&T or at least The Computing Science Research Center that embraced the idea as much as the AT&T lawyers would permit.

Because of their controlled monopoly status, AT&T couldn’t offer Unix commercially so they restricted distribution—at least initially—to academic institutions. Berkeley didn’t have those restrictions and were more interested in providing Unix to the world at large but couldn’t legally provide it to anyone who didn’t have an AT&T Unix source license.

This resulted in a mostly successful effort the remove all AT&T code from the Berkeley distribution. By the time of BSD 4.0 there were only a very few files that contained ATT&T IP. At this point the lawyers got involved and the famous UC Berkeley/ATT&T lawsuit was launched. In the end, BSD was essentially open sourced and we all benefited from distributions like NetBSD and FreeBSD. Eventually, of course, Linux became the standard “Unix” and, SCO notwithstanding, was completely free of prior IP.

If you’re at all interested in Unix history, this is a great article. It’s a bit long but there’s a lot of history to cover. It’s definitely worth your time.

Posted in General | Tagged | Leave a comment

Emacs Wow

Over at the Emacs subreddit, dehaticoder asks what things do you do in Emacs that make people say “Wow”. I’m probably an easy mark but I really love this type of post. They’re always enjoyable and sometimes I even learn something new. If you also enjoy these kinds of posts or want to learn some new techniques, take a look at dehaticoder’s post.

A lot of the answers are what you’d expect: Org mode, Magit, TRAMP, narrowing, and keyboard macros. Others had more specialized answers. One responder said that the thing that always elicited gasps of amazement from his coworkers was the speed at which he could make edits, and switch to other files or even machines, all without touching the mouse, of course.

My favorite was a variation on the grep/wgrep/make changes to grep buffer/save back to original files workflow that I first wrote about here. The simplest case is changing every occurrence of foo to bar in a set of files but the same technique can do more complicated tasks. Other suggestions were undo in region and undo tree that treats the undo history for the tree that it is.

There isn’t much ankle biting in the replies so it’s pleasant to read through them. As I said, you may even learn some new ideas for your own Emacs workflow.

Posted in General | Tagged | Leave a comment

Red Meat Friday: Avoid The Mouse

_nambiar has a short video on how painful it is to watch people use other editors and reach for the mouse every time they want to do some navigation or select text. He’s an Emacs user but his message will resonate with Vim users as well.

The video is definitely propaganda and certainly a fit subject for Red Meat Friday but no matter how much the naysayers try to deny it, it contains a nugget of truth. Some of the naysayers on the original reddit post make the ludicrous argument that his argument fails because some of his key bindings are long. Even leaving aside the fact that the first thing _nambiar says in the video is that you should learn to touch type, every Emacs user knows that you can rebind the bindings you use a lot to whatever you like.

There is, of course, a long standing argument about whether using the mouse or the keyboard for navigation is faster and some research claims that the mouse is faster but I’d be willing to bet that the editor used in those studies wasn’t Emacs. If you’re using some brain dead editor that makes you use the arrow keys to move around, then yes, the mouse may be faster but if you’re using an editor with robust keyboard navigation like Emacs or Vim, then I doubt a mouse could compete.

In any event, if you’re an Emacs or Vim user, enjoy the red meat.

Update [2024-03-15 Fri 15:39]: The “research” claims that the mouse not the keyboard is faster.

Posted in General | Tagged , | Leave a comment

More On The Emacs World Time Clock

As I’ve written before, Emacs has a world clock. Well, it’s not really a clock: just a list of times in various cities but it’s great for today’s remote work place. If your colleagues are stationed all over the world, it’s really useful to know what time it is where they are so you don’t try to contact them at 3 in the morning their time.

As the above linked post says, it’s possible to edit the list of cities listed. The method that Choi uses (in the above link) to configure them is the custom interface but others may prefer a more Lispy way of configuring it.

Bozhidar Batsov also addresses the world clock function and shows us how to configure it in, say, our init.el file. It’s easy to do except for knowing what the proper time zone is for the city you’re interested in. It’s easy to find that out by searching for “iana time zone <city>” For example, if I wanted to add Glasgow to the list, I would search for “iana time zone glasgow” and discover that the proper time zone is “Europe/London”. There’s also a database that you can download that contains all the supported places but it’s definitely overkill for this application.

Batsov also notes that you can edit the time string that gets displayed. Basically, you can specify any format supported by format-time-string. You might find that useful for further automation.

This is just another small example of how Emacs helps smooth your daily workflow. Even if you only occasionally want to know what time it is at Aunt Millie’s, it’s worthwhile looking up her time zone and adding it to the list.

Update [2024-03-15 Fri 12:41]: Glascow → Glasgow.

Posted in General | Tagged | Leave a comment

Org-linker

I’ve had this in my queue for a while but I wanted to try it out before I wrote about it. Sadly, I just haven’t had the time and probably won’t in the immediate future. Therefore, I’m writing about it now before it ages out.

This looks like a useful project for those of us who use org-attach and are worried about the problem of using the file name as the link. Org-linker uses a UUID instead and jin-cg claims that it’s more robust.

There are more details at the GitHub repository for the project so be sure to take a look at that if you’re interested in this project. If you’ve used it, drop a note and let us know how you like it.

Posted in General | Tagged , | Leave a comment

Boeing Continues To Founder

Boeing was a great company. For many years it defined the aviation industry by designing and building the best aircraft possible. The company thrived in large part because its culture was informed by an engineering ethos. Even their top executives had an aviation engineering background.

Then disaster struck. The government—in its omniscience—decided that Boeing should merge with McDonald Douglas and pressured Boeing to do so. The result was that the company was captured by suits with no engineering background or knowledge. That resulted, among other things, in a CEO who thought it made sense to hire and fire engineers according to short term needs.

The results have been aircraft crashes and door plugs blowing out in flight. We’re beginning to see the wages of these mishaps. People—not just the usual paranoids, but knowledgeable folks with aviation experience—are refusing to fly on the Boeing 737 Max. Take a look at this article that discusses the refusal of Ed Pierson, a man with military aviation experience and a ten year career at Boeing, to fly on the 737 Max. When he discovered, despite his explicit instructions to the contrary, that he was on a 737 Max, he demanded to get off the plane even though the hatch had been closed.

When informed travelers like Pierson refuse to fly on a particular aircraft, others are sure to follow and that is already happening as the article reports.

But that’s not all. NPR is reporting that Boeing is withholding key details about the recent door plug incident. NPR says that the NTSB has become increasing frustrated with its inability to get needed data from Boeing.

None of this bodes well for Boeing. If travelers refuse to fly on their aircraft, airlines will refuse to buy them. Perhaps it’s time to reconsider having the bean counters in charge.

Posted in General | Tagged | Leave a comment

Using Hook Functions

Arialdo Martini has a nice post on how to configure and use Emacs hook functions. Most Emacs users have a general idea about hook functions but Martini goes into more detail, especially as concerns their use in major modes. The TL;DR is that when a major mode starts, it calls a series of functions called “hook functions”.

That may seem a bit esoteric and something that only very advanced users would want to do but Martini gives some everyday uses that make sense for any Emacs user. His post is a reasonably detailed explanation of how to use hook functions and is well worth reading. He includes information how to handle conflicts where more than one one mode in a major mode hierarchy add the same function.

One thing that Martini covers that I didn’t know about is how to walk the major mode hierarchy to find out what modes the current mode is derived from. You probably won’t ever need to do this but it is interesting and points to how to investigate problems with conflicting hook functions.

The post is apparently Martini’s interpretation of some lessons he took from Protesilaos Stavrou and the usual Prot excellence shines through. As I say, it’s well worth taking a look at the post to get a better idea of what’s going on with hook functions.

Posted in General | Tagged | Leave a comment

Happy 51st Birthday To Dark Side Of The Moon

It’s that time again. Every year on this day, Irreal suspends our normal blathering to celebrate the release of the best album of all time: Pink Floyd’s Dark Side of the Moon. There are rumors that the actual release date was March 1, 1973, but Irreal has always celebrated it on March 10th and sees no reason to change that tradition now.

Every year I provide a link to one of the songs from the album in the hope of introducing others to their extraordinary music. This year, I’m going to change things up a bit and feature a song from their 1987 album A Momentary Lapse of Reason. That song, On the Turning Away, is not my favorite Pink Floyd song but this video of them performing it is my favorite Pink Floyd video.

Here it is:

I like it because it showcases the unique talents of each of the band members. It begins with Rick Wright doing the keyboard introduction. You don’t often see extended shots of him playing. At 3:37 you see Nick Mason showing what a mondo drummer he really is. Then, of course, there’s David Gilmour whose virtuosity needs no comment from Irreal.

The best part of the video is the second half, which is entirely instrumental. I find it really powerful and always seem out of breath when it ends. On of my favorite parts of the second half is the under appreciated backup singers Machan Taylor, Durga MacBroom, and Rachel Fury. They’re always great but they really shine in this video. Sadly, the official released version didn’t include these clips but thanks to Obi Wan Kenobi we can enjoy them whenever we like. Watch the video. I hope you enjoy it as much as I do.

Posted in General | Tagged | Leave a comment

Essential Functions

If you’re an Emacs n00b—and despite the ankle biters claiming Emacs is dead, there are a lot of them—İsmail Efe Top has a post that you may find useful. The point of the post is to list some functions that Top finds essential for his work with Emacs.

If you’ve got any experience at all with Emacs, the list will seem unsurprising, obvious even. The list is:

  • view-echo-area-messages (bound to Ctrl+h e) that he uses to see ephemeral echo area messages. All the command does is display the ∗Messages∗ buffer but the binding is a useful shortcut.
  • describe-function and describe-variable. I think it’s safe to say that not a day goes by that I don’t use at least one of them. I’d guess they’re my most used aspect of the Help system.
  • ispell (for spelling correction). I use ispell in conjunction with flyspell to get immediate feedback on spelling errors and typos. Others—like Top, apparently—like to do the spell checking all at once after the writing, or some portion of it, is complete.
  • org-insert-structure-template (bound to Ctrl+c Ctrl+,) is another everyday function that those writing in Org mode simply couldn’t live without.
  • Finally, Top offers up his own version of a function to look up the word at point in Google.

As I say, all this is pretty elementary but if you’re just starting out it’s some really useful information.

Posted in General | Tagged | Leave a comment