Karl Voit captures my feelings about Emacs exactly:
Seeing #Emacs as an #editor is like seeing a car as a seating-accommodation.#PIM #orgmode #informationcentric #vim #editorwar #IDE #opensource
— Karl Voit (@n0v0id) March 4, 2018
Karl Voit captures my feelings about Emacs exactly:
Seeing #Emacs as an #editor is like seeing a car as a seating-accommodation.#PIM #orgmode #informationcentric #vim #editorwar #IDE #opensource
— Karl Voit (@n0v0id) March 4, 2018
I stumbled across the package Auto-YASnippet, by the prodigious
abo-abo, again the other day. I vaguely remember reading about it a
couple of years ago when it was first released. The idea is to create
a temporary yasnippet on the fly without leaving your current buffer.
That can be really useful when you want to create a series of nearly
identical entries in a program that differ only in a term or two.
Abo-abo describes it as a hybrid of keyboard macros and yasnippet.
You can do the same sort of thing with keyboard macros if you can
remember how to invoke the recursive editing features. Abo-abo’s
solution is much easier: you just write the body of your text, marking
the fields that will change by a ~
. Then you can create as many
additional instances as you like, substituting different values for
the marked field(s). Take a look at the README for some examples of
how it works.
I’m not sure why this didn’t register with me more when I first saw
it. It’s probably because I don’t program in languages like Java or
JavaScript where a tool like Auto-YASnippet makes more sense and can
save some time. If you find yourself regularly writing nearly
identical definitions or other boiler plate, take a look at
Auto-YASnippet; it may save you some time.
Postscript: I had originally planned to publish this yesterday but
serendipitously Mike Zamansky scooped me by posting a video
demonstrating Auto-YASnippet in action. As I wrote then, that was
indeed fortunate because now you can see the package in action. If you
haven’t already, be sure to watch the video.
Mike Zamansky has another video up in his Using Emacs Series. This
time he discusses Artur Malabarba’s agressive-indent-mode and
abo-abo’s Auto YASnippet.
In what could be an example of great minds thinking alike but is more
likely simply a quotidian coincidence, I had planed on writing about
Auto-YASnippet today but I got scooped by Zamansky. Actually, that’s a
good thing because now you can see an example of them in action. I’ll
publish my post on Auto-YASnippet tomorrow.
Zamansky’s video is a couple of seconds over 9 minutes so you can
easily fit it in during a coffee break. As with all of his videos,
this one is well worth your time
Eric Raymond (esr) says we should always use UTC instead of local
time in our log messages. Specifically, he says we should use RFC3339
timestamps. Using local timestamps and other ambiguous information in
log entries is a well established practice in the Unix world so esr is
not just complaining about “kids today” when he urges us to use
RFC3339 timestamps.
The problem with local times is obvious when you think about it. With
today’s interconnected world, we’re dealing with events from all over
the world and local times make it hard to compare them. The advantage
of an RFC3339 timestamp is that it is easily distinguishable from
other formats and can be (lexicographically) compared with others of
its kind to determine the temporal order of the timestamps.
An important example of an application where this matters is
distributed version control systems. Commits can potentially come from
anywhere is the world and local times make it difficult to sort the
commits for logging and other purposes. Oddly, Git gets this wrong—or
at least not completely right. While it does store the times in UTC it
displays them in the committer’s local time. That leads to exactly the
type of problems you would expect.
This is, in principal, an easy problem to solve but, of course,
practical considerations will ensure that it probably won’t be anytime
soon. Take a look at esr’s post for more details and for some notes on
how this problem long predates the computer age.
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.
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.
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.
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
: Matus → Matúš.
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.
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 As
→ TeX 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.