Discarding Git Commits

Guangwang Huang (Whatacold) has an instructive video on how to discard commits using Magit. There are three methods:

  1. Hard reset
  2. Revert
  3. Soft reset

They all have advantages and disadvantages. A hard reset is fast but the discarded commits are deleted. The other two methods are safer but involve more typing. You can get all the details by watching the video.

Using either reset can seem like a scary proposition but Whatacold shows that they are both straightforward and easy to understand. If they still seem too fraught, you can always use revert. It generates more commits but doesn’t seem as scary.

The video is 9 minutes, 25 seconds so it should be pretty easy to fit in.

Posted in General | Tagged , | Leave a comment

Spell Checking Kitchin Style

John Kitchin has another video up in his Scimax series. This one is about how he handles spell checking in Scimax. As I watched the video, I thought that his setup was really new and different but it turns out that it’s all built on top of flyspell and Aspell with some help from flyspell-correct and flyspell-correct-ivy (included with flyspell-correct).

Watch the video to see how it all works. There’s no reason you can’t integrate Kitchin’s system into your own. There’s not a whole lot of code involved as you can see from scimax-spellcheck.el. The hydra that he discusses in here.

The video is 7 minutes, 23 seconds so it should be easy to fit into a coffee break.

Posted in General | Tagged | Leave a comment

Red Meat Friday: Spaces After a Sentence

Today’s Red Meat Friday is about the “correct” number of spaces after a sentence. Irreal has written about this before, most recently here, but all of you were familiar with the controversy long before Irreal opined on the matter. Oddly, the question still has stubborn partisans who will jump into any discussion of the matter to hotly defend their chosen position.

Here’s the latest fusillade, this time from Barton Swaim who reminds older folks that it’s 2021, we don’t use typewriters anymore, and there’s no need for two spaces after a sentence. Lifehacker doubles down on this and says that putting two spaces after a sentence marks you as a geezer.

It’s very true—at least according to the experts—that with modern proportional fonts, one space is the correct answer but it’s also true that it doesn’t really matter because your typesetter or rendering engine is going to use one space no matter what you input. Two-space partisans point out that given your input might very well use a monospace font and that your output will be correct however many spaces you use, two spaces make sense because they make your input easier to read and easier for a script to parse out sentences.

Of course, none of this will change anyone’s mind; that’s why this is a Red Meat Friday item.

Posted in General | Tagged , | Leave a comment

Playing and Logging a Random Album

Garjola Dindi has a delightful blog entry on how he leverages Emacs to enjoy his music. Dindi was nostalgic for the days when listening to music meant putting a vinyl disk on the record player. Back then, the friction of listening to recorded music meant you put on an album and listened to whole thing. These days, of course, Dindi’s music is digitized and lives in his computer.

Part of that means that now it’s possible to listen to a single track from one album and then switch to another track on some other album but Dindi wanted to experience the whole-album experience again. He uses EMMS to listen to his music so it was pretty easy to do what he wanted. He simply brought up an EMMS buffer with a list of his albums, used the random function to choose a line number, and goto-line to go to that album and then played it. He also logged it to an Org file so he would know what albums he had listened to.

All you Emacsers out there are jumping up and down and screaming, “Automate it. Automate it.” Of course, that’s exactly what he did. It turned out to be really easy: he basically just wrote some Elisp to call the same commands he was using to do it manually. He also added some code to make the log entry.

The code is simple but the point, as Dindi points out, is that with Emacs it’s possible to combine different applications that weren’t designed to work together to solve whatever problem you’re having.

Posted in General | Tagged , | Leave a comment

They Don’t Want to Return

CNBC has an interesting article about large-organization CEOs’ frustration at trying to get their workers back into the office. Workers have little interest in returning. Part of that is fear of COVID-19, of course, but many, having experienced the freedom and increased productivity of working from home, are in no hurry to return to the more constrained environment of the office with its meetings and micromanagement.

The obvious observation is that maybe the CEOs are asking the wrong question. Most of them have spent their whole working lives in a well defined, perhaps even regimented, system in which of course employees came into the office to work. How could it be otherwise? But perhaps the right question is, “How can we get our jobs done with a remote work force?”

Meanwhile, over at Medium, CodeX says that the office exodus is a movement. This article is specifically about developers but the same principals probably apply to other disciplines. Senior developers are leaving companies to go out on their own. Those who are staying are demanding remote work as a sine qua non.

Managers who believe or hope that things will go back to the way they’ve always been are probably kidding themselves. COVID-19 will be with us for a while longer and even afterwards people are going to be loath to return to their cubicle farm—or worse, open plan office. The smart CEOs will be asking themselves how to best take advantage of the new reality.

Posted in General | Tagged , , | Leave a comment

Magit 3.3 Released

Tarsius (Jonas Bernoulli) has announced the release of Magit 3.3.0. The link takes you to his GitHub repository Change Log that has a detailed list of changes. If you want the TL;DR, you can check out his blog entry about the release.

The last link also has pointers to various ways of supporting tarsius’ work. If you’re a Magit user, you should really consider chipping in a few dollars to keep the goodness coming.

Posted in General | Tagged , | Leave a comment

Kitchin on Elisp Data Structures

John Kitchin has another video up on his Scimax Channel. This time, it’s about elementary Elisp data structures and their manipulation. He considers

  • Strings
  • Lists
  • Vectors
  • Alists
  • Plists
  • Hash tables

Strings aren’t really a data structure in the sense of the others but they are, in effect, character arrays and it’s possible to extract or insert data into a string.

The premier Lisp data structure is, of course, the list. After all, its name appears on the marquee. Kitchin describes the need and use of quoting and quasiquoting and various ways of accessing list elements. I’m not really a Lisp old-timer but I’ve been at it long enough that I still prefer the car and cdr primitives to the newfangled inventions such as first, tail, cl-first, and all the rest. If I need an element after the third or fourth, I’ll use nth or elt. Kitchin likes the cl-* constructs and as usual Emacs lets you have it your way.

Like me, Kitchin doesn’t use vectors very often and doesn’t have much to say about them but they are simple and easy to use.

Alists and plists are two variations on the same theme. They’re both lists of key/value pairs differing in their representation and access means. A good argument can be made that we don’t need both but they exist for hysterical raisons and Lispers tend to use them both.

Finally, there are hash tables. The idea is pretty well known by now although they are commonly called dictionaries in other languages. They are, again, key/value pairs but have a generally \(O(1)\) lookup time while alists and plists are \(O(n)\). That doesn’t matter for small lists but with hundreds or thousands of items the \(O(n)\) can add up so hash tables make sense for that case.

Even if you’re familiar with using hash tables in Elisp, you may not be familiar with using “reader notation” for initializing a hash table. It really makes sense only for small hash tables—or for writing out and then later reading in a hash table.

The video is just short of 26 minutes so plan accordingly. As usual with Kitchin’s videos, it’s well worth the time to watch it even if you’re an experienced Elisper.

Posted in General | Tagged , | Leave a comment

Inspired Python

All Irreal readers are, I’m sure, familiar with Mickey Petersen who, in addition to his excellent Emacs site, Mastering Emacs, is also the author of a book by the same name. The articles on his site are among the best you’ll find dealing with Emacs. The same is true of his book. If you don’t yet have it and you’re an Emacser, you should definitely get a copy.

Now Mickey has a new site, Inspired Python. Here’s his Twitter announcement:

I haven’t written in Python for some time but I read a couple of the articles and, of course, they’re up to Mickey’s usual high standards. If you’re a Pythonista, be sure to check it out.

Posted in General | Tagged , | Leave a comment

Emacs 28 Is Drawing Near

Eli Zaretskii writes that he’s cut the release branch for Emacs 28.1 in preparation for the upcoming pretest. He asks that everyone tracking Emacs development switch to the new branch so that it can get as much testing as possible.

Eli is anticipating that the first pretest will be released in a few weeks. If you’re like me, you want it right now but the reality is, as I’ve said before, that Eli and the other developers are working hard to give us the best possible release and in the end we’ll be glad we waited. In the mean time, you can help by compiling and using the release branch to help with the bug squashing.

Posted in General | Tagged | Leave a comment

REPL Driven Programming in Python

As many of you know, I’ve long been fascinated with interactive or exploratory programming—what some call REPL driven programming. It’s the idea that you write a bit of code and try it immediately by executing it to see what happens. You keep adding to the code and soon you have a function and then a program. The very best example of it that I know of is Kris Jenkins’ video on building a Spotify client for Emacs. If you haven’t seen this video, I urge you to take a look; you won’t be sorry.

When I think of interactive programming, I usually think of it in terms of a Lisp-based language such as Scheme, Common Lisp, or Elisp. There’s no reason, though, that you can’t bring the method to bear on any language that supports a REPL. David Vujic has an interesting post on applying the method to Python programming.

He starts by explaining what he doesn’t mean by REPL driven programming and moves on to what he does mean. The TL;DR is that he’s not talking about typing in a Python expression from the shell; he’s talking about interactive use from within an editor. If that doesn’t make sense to you, take a look at Jenkins’ video to see it in action with Elisp and Emacs. He spends the rest of the post explaining his setup and workflow. If you’d like to try out interactive programming but don’t know any of the Lisps, perhaps Vujic’s post will help you get started.

Posted in General | Tagged | Leave a comment