Grepping Git Repositories and Other Collections

My current workflow has two ways of grepping collections of files. For
grepping Git repositories, I use counsel-git-grep. It uses the fast
grep built into Git as a backend. For other collections, I use
counsel-ag, a recursive grep that uses The Silver Searcher for a
backend. I usually prefer to use counsel-git-grep because I can be
in any directory of the repository and still search everything; I
don’t have to worry about starting in the top directory.

Then I read this recent post from abo-abo. In it, abo-abo says that he
now uses counsel-rg, which uses ripgrep as a backend, for everything
because it is the fastest of the generally available greps. That
sounded pretty good but I was confused. As far as I could tell from
the documentation, ripgrep doesn’t treat Git repositories in a special
way. It will simply do a recursive search from the current directory
(or the one you explicitly specify, of course). So I queried abo-abo
about that and it turns out that counsel-rg (as well as
counsel-ag) now explicitly check for a Git repository and will start
from the repository’s top directory unless you specify some other
starting point.

What that means to me is that I don’t need the two ways of grepping. I
can simply use counsel-ag and it will do the right thing if I’m in a
Git repository. That leaves the question of whether I should
install ripgrep and use counsel-rg to do my greps. Ripgrep does
appear to be considerably faster than the other methods but unlike
abo-abo, I’m not dealing with 2G repositories and counsel-ag seems
more than fast enough. Still, it’s always nice to be faster so I installed
ripgrep so that I could try out counsel-rg anyway.

Be sure to read abo-abo’s post. It has some other information on his
workflow and handling such things as ignore files. You might also
enjoy this abo-abo post on ripgrep: he explains why he switched to it
and some of its advantages. And if you aren’t already using the
Ivy/Counsel/Swiper suite, stop what you’re doing and install them
right now. You will, I promise you, be glad you did.

Posted in General | Tagged | Leave a comment

Mind Mapping with Org-brain

If you like to visualize your projects and tasks with mind-mapping, like
to work with an interactive GUI, and don’t mind proprietary software,
you may like The Brain. You can see how it works in this video. It
appears to be an excellent and well thought out product.

But I’m not here to shill for The Brain. I mention it because it’s the
inspiration for a very nice package by Erik Sjöstrand: org-brain. It’s
a concept mapping application built on top of Org mode and Emacs. It does
the same sorts of things as The Brain but from inside Emacs. If you
prefer keeping your hands on the home row to clicking and dragging on
a GUI you should check out org-brain.

You can get an idea of how org-brain works by watching Sjöstrand’s
video demonstration of it. To get the most out of the Sjöstrand’s
video I recommend watching The Brain video first because it helps
clarify the problem both applications are trying to solve and how they
go about it.

I don’t think my mind works in a way that makes mind-mapping a natural
fit for me but lots of people I know and respect make it an important
part of their workflow. If you’re one of those people, you should
definitely take a look at org-brain.

Posted in General | Tagged , | Leave a comment

Zamansky 45: Autocomplete and Company Mode

Mike Zamansky has a new video up in his Using Emacs Series. After
commenting on what a great time it is to be an Emacs user, Zamansky
considers Autocomplete and Company mode. These, of course, are
completion packages for Emacs. They’re both “intelligent” in the sense
that they use individualized backends to be language aware.

Until recently, Zamansky was an Autocomplete user. He mostly used it
with the Jedi package for Python completion. This semester, though,
he’s teaching a C++ course and decided to try out Company mode because
it uses Clang (through Irony mode) to provide syntax aware completion
for the C, C++, and Objective C languages.

He’s just started his experimentation so the video represents his
preliminary findings. For me, though, the video reinforced a
long-standing prejudice against either one. I use the “dumb”
completion built into Emacs that basically looks at what’s in your
buffer and what you’ve typed recently to choose completion targets.
You have to explicitly invoke the completion so it never gets in the
way. Autocomplete and Company mode, on the other hand, are always
popping up buffers offering suggestions. I find that annoying and
distracting. Perhaps it’s because of my horrible experience with
Word-like word processors
but whatever the cause I don’t want my
editor doing that. Some languages—I’m looking at you Java—can benefit
from auto-completion, I suppose, but I don’t use those languages so I
have no need to put up with its downsides.

Of course, not everyone is as curmudgeonly so it’s worth taking a look
at the video to see if one or the other works for you. The video is just
short of 18 and a half minutes so it should be easy to fit it in.

Posted in General | Tagged | Leave a comment

Radio Buttons and Devops in Org Mode

Regular readers know that I am very enamored of Howard Abrams’
excellent post and video on literate devops. It’s not that my duties
include devops; rather it’s that the methods he demonstrates are
applicable to a wide range of problems that we encounter in the
technical fields. The idea of maintaining a little “notebook” that
describes a problem and its solution—along with any code used in that
solution—is a very powerful technique. It’s one I’ve been trying to
apply in my day-to-day tasks.

It turns out that Matúš Goljer (Fuco1) feels the same way. He has a
really great post that begins by sketching out a typical use of the
technique. He was working on a personal version the app stack where
the problem occurred and wanted to repeat the process on the staging
and production systems. Everything was the same between the systems
except the port number used to access the pertinent database.

Easy enough, just change the port number and rerun things. But that
port number was used in several places so rather than replace them all
he made another code block that returned the port number and accessed
it with org-babel-ref-resolve in every code block that needed it.
Now he simply needed to change the port number in one place to access
any of the systems.

He works with a lot of systems so it became difficult to remember the
port number for any given system. He solved that problem by adding a
list of port numbers above the code block that returns the needed port
number. Then he thought that, gee, that looks just like a set of
buttons that I should be able to click on to choose the right port.
What he really wanted, of course, was a list of radio buttons. Org
doesn’t support that but John Kitchin had a post with some code for
doing it.

Fuco1 refactored Kitchin’s code, packaged it up on GitHub, and then
used it in his notebooks. Now when he wants to run things on a
different system, he just clicks on the target system and everything
else is taken care of. This is a really brilliant solution and his
post is a must read for anyone who want to use Abrams’ techniques in
their own work.

Update [2018-03-11 Sun 14:44]: Matus → Matúš.

Posted in General | Tagged , | Leave a comment

Happy Birthday Dark Side of the Moon

As I do every year on this date, I’d like to wish Pink Floyd’s iconic
album, Dark Side of the Moon, a happy birthday. The album was
released 45 years ago today and went on to be one of the most
successful albums of all time. It spent an astounding 937 weeks on the
Billboard 200 Chart, longer than any other album and one of only three
albums to stay on the chart for longer than 500 weeks. It still
occasionally appeared on the chart in 2014 and maybe later.

Dark Side of the Moon has been sold in every format from
Reel-to-Reel to digital. Wikipedia says that it’s estimated that 1 out
of every 14 people in the U.S. under the age of 50 owns or has owned a
copy of the album. But what really matters, of course, is what a
tremendous piece of work it is.

Posted in General | Tagged , | Leave a comment

MathJax Tips

Over at John Cook’s TeX Tips there’s a pointer to a very nice MathJax
basic tutorial and quick reference
. It’s especially handy for those
who don’t use \(\mathrm{\LaTeX}\) all the time but occasionally want to
include a bit of mathematics in a blog post. It by no means covers
everything but there’s enough there to probably get you through adding
a quick formula or two to a post.

The very first tip is something that I didn’t know. When you’re
looking at a Web site with some MathJax generated mathematics can you
can see the \(\mathrm{\LaTeX}\) source by right clicking on the formula
and choosing Show Math AsTeX Commands. That will open another
tab with the \(\mathrm{\LaTeX}\) source.

The cheat sheet is definitely worth bookmarking if you’re not a
\(\mathrm{\LaTeX}\) expert but sometimes want to include some
mathematics in a post.

Postscript: After writing this, I came across this macOS application
that lets you take a screenshot of an equation and output the LaTeX
source
. If the tip about right clicking on a MathJax-displayed
equation to display the \(\mathrm{\LaTeX}\) appeals to you, you should
check out Mathpix.

Posted in General | Tagged , , | Leave a comment

Ten Tools for Academics

Over at Academia Obscura they have a list of 10 essential tools for
academics and PhD students
. It’s a useful list but my immediate
reaction upon reading it was that you can do all that with Emacs.
Well, you can’t backup your data with Emacs but other than that you
can forget about all those tools and just use Emacs.

Here’s a list of those tools and how Emacs (and Org mode) can do the
same things and often, in my opinion, better:

Citation Manager
Use John Kitchen’s org-ref. Here’s a video that
shows it in action as well as demonstrating using Org mode to
write a paper.
Scrivener
Org mode can export to almost any format and is
infinitely configurable to work your way;
Evernote
Org mode can store and index content seamlessly. You can
attach data to an Org entry including PDFs or links to
HTML. You can even download your Evernote content to Org;
Trello
This is what Org mode was made for. TODO lists and agendas
that can accumulate tasks from multiple lists. John
Goerzen explains why he gave up other tools for this in
favor of Org mode
. If you can’t give up Trello—because of
collaboration, say—org-trello lets you interface it and
Org mode. And, it’s all local. If you’re offline, it’s
still available;
Unroll.me
Elfeed delivers all your feeds and mailing lists to a
single list that can be perused at your leisure. If you
really need to get some of your feeds via email,
open a second, free, account to receive them. Then let
mu4e, or notmuch, or something similar download those
emails whenever you like.
Twitter
You shouldn’t be wasting your time on Twitter but if you
must, Emacs has several Twitter clients that bring
everything into the Emacs environment;
Anti-Social
You don’t need any special tools for this; just
redirect those sites to localhost. If you need finer
grained control, Matt Mite has some suggestions;
Coach.me
You can ask Org to remind you everyday or you can use
any of the several pomodoro applications available for Emacs;
A clipboard manager
Emacs can handle this on its own but you can
make it even better with counsel-yank-pop;
An external drive/backup plan
Emacs can’t do this, of course, but
it is important so get a backup plan that operates in the
background and doesn’t require any action on your part.

If you’re like me, your initial reaction is probably that Emacs is the
obvious choice for STEM folks but that maybe Emacs is too much for
those in the Liberal Arts. Really, though, that’s just snobbery. Many
people in the “soft sciences” and liberal arts have shown themselves
able to learn and use Emacs just as effectively as their brethren in
the sciences and engineering. Just like for the rest of us, Emacs has
a steep learning curve and takes a concerted effort to master but I
doubt it’s harder than learning those other 9 tools.

Posted in General | Tagged , | Leave a comment

The Smartphone as Part of Your Mind

Karina Vold over at the Sigularity Hub has a thought provoking article
on the extent to which your smartphone is part of your mind. At first,
it seems like a silly idea except in a trivial sense. But as Vold
observes,

No other piece of hardware in history, not even your brain, contains
the quality or quantity of information held on your phone: it ‘knows’
whom you speak to, when you speak to them, what you said, where you
have been, your purchases, photos, biometric data, even your notes to
yourself—and all this dating back years.

This idea is not new and is not being pushed just by techies. In 1998,
the philosophers Andy Clark and David Chalmers published a paper, The
Extended Mind
, the explored the idea.

These days, the issue comes up mostly in law enforcement settings in
which questions of privacy are raised regarding gaining access to a
suspect’s smartphone. The courts, oddly, have taken the lead in
examining the issues. Several rulings, some even from the U.S. Supreme
Court, have acknowledged that smartphones have a unique relation to
our minds in a way that, say, paper records don’t.

Those that are looking at the idea seriously raise a number of
interesting questions such as should our phones be treated as part of
our remains when we die? Or, if our phones are really an extension of
our minds, should destroying or wiping them be considered a form of
assault the way injuring someone with a blow to the head is?

Be sure to take a look at Vold’s article. It’s full of interesting
ideas, especially for those of us trying to live digital lives.

Posted in General | Tagged , | Leave a comment

A Return to Emacs

John Goerzen has returned to Emacs after a decade of being a Vim user.
His reason for doing so is Org mode. If all you want from your editor
is to edit, Vim is hard to beat: it’s fast, loads in a flash, and its
composable command set make it flexible and easy to learn. If
you use Vim, however, you’re going to need a bunch of other tools to
handle things like your agenda and TODO lists.

Emacs, of course, has Org mode, which nicely integrates these
functions into the editor and lets you easily link all your data
together under the Org aegis. Goerzen does a nice job of explaining
how Emacs and Org mode make tying together your data and data
collection tasks easy.

He mentions, for example, recording a task to answer an email sometime
in the future. With many tools, this is difficult or impossible but
Org makes it easy to tie an email to a TODO item so that when the time
comes to deal with it, you can simply click on the link and bring the
email up in your email client. I do this all the time and even have a
special template to automatically capture the email link.

Goerzen’s post is the first of a series of planned posts on his use of
Org mode. The second and third are already done and more are planned.
This is a great series for Org beginners. It’s written from the point
of view of a developer trying to streamline his workflow. If you’re an
Org user or thinking about becoming one, be sure to check out this
series.

Posted in General | Tagged , | Leave a comment

A Sound Investment

How much would you pay for Org mode? $10? $25? $100? More? Well
fortunately you don’t have to pay anything at all because, of course,
Org mode is free software in all senses of the word “free.” Still,
free software does have a cost even if we aren’t the ones paying. Most
often that cost is the significant free labor that the implementers
and maintainers provide.

Sometimes the cost includes more than the free labor. Bastien Guerry
is one of the principal maintainers of Org accounting for, according
to Karl Voit, more than 20% of the commits. But now Bastien’s computer
is dying and he can’t afford to get a new one:

I don’t know what computer prices are like in Paris but whatever they
are, if every Org user chipped in a small amount, Bastien would be
able to replace his dying machine with a new and powerful computer so
that he could continue his vital work. Of course, not every Org user
can afford to help but if you can, please chip in a few Euros. I’ve
sent him €20; that’s only about $25 US. If even 100 people do the
same, Bastien will probably have enough for a decent replacement.

Posted in General | Tagged , | Leave a comment