Another Look At Counting Org Tags

Andrea over at Where parallels cross has decided to post some shorter tips in addition to the blog’s longer offerings. The first is some Elisp to count the number of tags in your agenda files. When I looked at the code, I thought it was a bit too complicated for what it was trying to do.

My first objection was the onetime use of the macro but it turned out that Andrea already had it so that wasn’t a problem. The real issue is that the code duplicated a lot of already existing functionality. I remembered writing a post a couple of years ago where I needed to list all my agenda tags. It turned out that org-global-tags-completion-table did just that. It also eliminates duplicates and nil entries. In fact, if you look at the code, it does pretty much what Andrea did.

Here, then, is my rendition of counting Org tags:

(require 'dash)

(->> (org-global-tags-completion-table)
     -flatten
     length)
715

One final note. The tags for each file begins with a property string such as

#("JOURNAL" 0 7
 (inherited t))

so you should really subtract the number of agenda files to get an exact count.

Posted in General | Tagged | Leave a comment

Are Google Searches Losing Quality?

As most of you know, I try to avoid Google as much as possible. In particular, I haven’t used the Google search engine in years. But that’s because of privacy concerns and Google’s sordid record of vacuuming up as much of their users’ information as possible. I’ve always assumed, though, that Google probably had the highest quality search results in the industry. That’s undoubtedly been true in the past; after all, Google invented modern browsing indexing techniques and has been at it for a very long time.

Then I read this Twitter thread by Michael Seibel, a partner and director at Y Combinator. The TL;DR is that, at least in certain categories, Google search results are of very low quality with the top results dominated by “clickbait sites riddled with crappy ads”. Later in the thread, Tanay Jaipuria points to one of his Substack posts in which he shows the results of a Google search for “health insurance”. The first page has only one result that is not an ad.

Seibel speculates—and Jaipuria concurs—that Google may be ripe for some disruption. Paul Graham picked up on the idea with a thread of his own on the idea of going after a niche overrun with SEO spam. Seibel posits that these dismal results are not the result of sudden bad engineering but of short term bottom line obsessed executives who are insisting on ever more ads in the results. It wouldn’t be the first time suits overly concerned with the next quarter results have made bad decisions.

Betteridge’s law mandates that the headline’s answer should be “no” but Seibel and Jaipuria make a pretty compelling case. Happily, I have no direct experience to make my own determination.

Posted in General | Tagged | Leave a comment

Germany Gets It Right

Tutanota is a Germany-based secure email provider. As you would expect, they are very interested in privacy-affecting legislation, especially in Germany, so they were quick to announce a change in government policy regarding data retention on their blog.

The TL;DR is that the new German government would like to do away with data retention not required for business purposes except when presented with a legal warrant. There’s the usual bureaucratic wrangling but it looks like it’s going to happen. For years, the government kept passing data retention laws and the courts kept striking them down. Now, maybe, Germans can rest assured that the Government isn’t willy nilly snooping on their communications without a warrant supported by a finding of probable criminal activity.

It’s easy to take a “Meh, BFD” attitude about this but it’s not often I get to report such an improvement. Certainly here in America things are getting worse, not better. The Fourth Amendment seems pretty clear on the issue but the courts apparently have special glasses that allow them to read the tea leaves in a way that we hoi polloi don’t have access to. Still, Irreal will take its victories where it can find them and celebrate this step forward for privacy. I just hope that my own government will do likewise. For health reasons, I’m not holding my breath.

Posted in General | Tagged | Leave a comment

Draft 4 Revisited

It’s New Years day and a lot of you are probably in no mind for an over stimulating rant on one of Irreal’s hobby horses or perhaps even a technical discussion so, instead, I offer a reprise of one of my favorite posts from back in 2015. That post was about James Somers’ wonderful article on why you are probably using the wrong dictionary. Someone just reposted a pointer to the article and I enjoyed reading it again just as much as I did the first time.

Somers tells the story of John McPhee’s New Yorker article Draft No. 4. The article describes how McPhee, an acclaimed essayist, “punches up the language” of his essays after the creative work is done. He does this by looking for words that aren’t quite right or that can be improved and looks them up in the dictionary. But not just any dictionary. Somers says that most dictionaries offer dry, bureaucratic definitions but, he discovered, McPhee uses Webster’s Revised Unabridged Dictionary (1913 + 1828). Happily this dictionary is freely available and Marcin Borkowski discovered a way to make it accessible from within Emacs. This is perfect. You can just point at a word in an Emacs buffer and get Webster’s definition. I don’t use it all that often but when I do it’s really a life saver. If you write prose, you really need this.

I have long thought that Somers’ article was a beautiful paean to McPhee and his process for making his prose as perfect as possible. Even those of us who aren’t in his league can learn and benefit from how he does things.

Posted in General | Tagged | Leave a comment

Emacs 28, Menus, and Mice

Philip Kaludercic has an interesting post on the new Emacs 28 context menu feature. It has some useful information on how to use and configure the feature. The TL;DR is that you can configure menus to be context sensitive. For example, if the point is on a file path, the menu can add an entry to open that file. Kaludercic gives several other examples and provides some demonstration code to show how the capability can be used.

Emacs 28 will soon be with be officially upon us—the first pretest has already been released—so it’s worth taking a look at Kaludercic’s post if you have any interest in this sort of functionality.

But my interest in his post really concerns a meta-issue that he raises: that of using a mouse and menus with Emacs. As I said just the other day, I’m content to let people find the workflow—Emacs-based or not—that works best for them. That includes using a mouse and/or menus with Emacs. Kaludercic feels the same—sort of—but is suspicious of those of us who avoid using the mouse and menus.

Contra Kaludercic, I’m don’t have a fear, irrational or otherwise, of the mouse and use it all the time in, say, the browser or others apps where it makes sense. But the thing is, in my estimation, it doesn’t make sense in Emacs. I don’t care what Kaludercic and Rob Pike say, I’m faster and more efficient in Emacs without the mouse. The same goes for menus. I always have them enabled because it’s hard to do otherwise in macOS but the only time I ever invoke them is for seldom used commands that I can’t remember and know is on a currently available menu. That happens no more than once every couple months at most.

Again, do whatever works best for you but grant leave to those of us who have other workflows to do the same.

Posted in General | Tagged | Leave a comment

Finite Automata State Diagrams With Tikz

I’ve mentioned before that one of my favorite implementation techniques is finite state machines. I started using them for communication protocol implementations but soon discovered that they could be applied to several sorts of problems. It’s easy enough to sketch out a state diagram on paper and code from that but what happens when you want to document the FSM?

I’ve always used the Graphviz dot command language to draw high quality digital versions of the state diagrams but it’s hard to get the placement exactly right and looking good. Alexander L. Hayes, a Ph.D.Student at Indiana University Bloomington, has a short guide on using Tikz to draw the diagrams.

The good news is that the diagrams look really great and don’t seem very hard to specify (although you can fine tune the results). Take a look at the link to see what I mean. The bad news is that neither Hayes’ guide or the relevant chapter of the TikZ and PGF Manual that he points at does a very good job of explaining the language and how to use it. They are, rather, a set of examples. Fortunately, state diagrams aren’t very complex and you can probably figure out what you need to do from those examples.

If you need to typeset some state diagrams, take a look at Hayes’ guide and section 19 of the manual. Tikz seems like an easy way to get the job done.

Posted in General | Tagged | Leave a comment

A Nice Example of Emacs Keyboard Macros

Just a quickie today. Bill over at ATMakers has a short video on Why He Uses Emacs. It’s actually a nice example of using keyboard macros to convert raw data into the required form.

I like it because it’s a realistic example. Very often when we want to convert a data set to some other format, we have the problem that the source data is not completely regular. Theoretically, this means we can’t write a quick and easy macro to do the conversion but, of course, that is not how we work. If there are one or two outliers in the data, we just convert everything according to the canonical data and fix up the outliers by hand afterwards.

That’s exactly what Bill does in his video. Most of the data is converted perfectly but the two outliers are easy to fix by hand and the entire process is much more efficient than converting each datum by hand or writing an app that does the right thing for each entry. Instead of an hour or two of tedious work or programming, Bill converts the first entry while recording his keystrokes and then applies that to all the other entries. The fact that it doesn’t work on a couple of irregular entries doesn’t matter; they are easily fixed by hand.

The video is only 6 minutes, 15 seconds long so it should be easy to find time for it.

Posted in General | Tagged | Leave a comment

Emacs Markdown Mode

Timothy Unkert is an Emacs user but prefers to use Markdown over Org-mode. He’s posted a video that describes using Markdown in Emacs. I’m very much a “different strokes for different folks” type of guy as the Hippies used to say so I’m perfectly happy for people to use whatever software works best for them. That said, after watching the video I’m at a loss as to why anyone would prefer to write in Markdown. Sure, sometimes you need to write in Markdown for various reasons but to prefer it? Karl Voit has explained at length why Org-mode markup is the best of class.

The first issue is inserting links. Unlike Org-mode the link isn’t displayed nicely as a link but instead shows the hard to read markup. Worse, Markdown-mode allows you to enter only a single word for the link description. I almost always want more than a single word (as the two links in this post show) so that’s deal breaker for me. Unkert fixes it by editing the actual link markup but that’s lame. I suspect that the real problem here may be configuration issue on Unkert’s machine or at worst an artifact of the Emacs Markdown implementation.

The issue with link display carries over to other text styling. If you want to italicize a word or phrase, you surround it with a single stars but the result is just the word or phrase surrounded by stars unlike Org that will actually produce italics.

Watch the video. Almost every aspect that Unkert demonstrates suffers in comparison to Org-mode. In one sense, this is unfair to Markdown because these problems are specific to the Emacs implementation but if you’re an Emacs user I can’t see any reason, other things being equal, to prefer Markdown to Org-mode.

Posted in General | Tagged | Leave a comment

Running Asynchronous Processes in Eshell

Nacho Barrientos has an interesting video in which he explains how to run an eshell process in the background. Barrientos illustrates this with the sleep command. Normally, if you enter

sleep 4

in Eshell, Emacs will hang until sleep completes in 4 seconds. Barrientos’ idea is to use the Emacs compile mechanism to run the command in the background. The output is redirected to the *compile* buffer and the Eshell prompt returns immediately.

That’s a nice way of starting a long running process from Eshell and being able to continue working in Emacs. He also has a way of burying the *compile* buffer and getting a message when the process completes.

There’s not a lot of code needed to implement this. You can see the relevant function in Barrientos’ init.el. If you use Eshell regularly and sometimes want to invoke long-running processes, it’s worth taking a look at this video. The run time is only 4 minutes, 21 seconds so it should be easy to fit it in

UPDATE [2021-12-31 Fri 13:03]: In the comments, Niklas Eklund writes that he has a package that does the same sort of thing. You can read his post about it here. Elkund’s package works with any shell so it may be a worthwhile addition to your configuration.

Posted in General | Tagged | Leave a comment

The Sam Editor

I’ve used most of the traditional editors. By “traditional” I mean editors like ed, ex, vi/vim, Emacs, Acme, and even—back in the day—brief. One editor I’ve never tried is Sam. Sam, like Acme, was written by Rob Pike so if you know anything at all about the Unix milieu it’s entitled to automatic respect.

You don’t have to take my word for it. It’s reportedly the editor of choice for Ken Thompson, Brian Kernighan, Doug McIlroy, Bjarne Stroustrup, and others. That’s a lot of world class programmers voting for Sam.

If you want to get a flavor of what working with Sam is like, Matthew D. Miller has a post that recounts his experiences with it. Miller is not really a Sam user but he wanted to see what it was like. You can read the post to get his impressions but the thing that stands out to me is how mouse-centric it is. That’s not surprising because Pike is a believer in the superiority of the mouse over the keyboard for speed and efficiency.

We Emacsers (and Vi users for that matter) are having none of that and will forever forswear the mouse in favor of the keyboard but there’s room for everyone. You can even use the mouse with Emacs and Vim if you like.

Regardless, if you’ve ever wondered what using Sam was like, take a look at Miller’s post to get a feeling for it. If it sounds good to you, download it and try it out. You can always come back to the one true editor.

Posted in General | Tagged | Leave a comment