PDF-Tools: Setup and Annotation

I installed PDF-tools a few months ago and really like it. Their site has warnings about using it with macOS but the installation on a Mac is easy and it works perfectly. Recently, I have seen two posts that address PDF-tools. The first, by Ben Maughan over at Pragmatic Emacs, discusses setting it up on the Mac and a couple of tricks for making annotations to a PDF. If you’re an Ivy user, pay particular attention to his advice about mapping Ctrl+s back to isearch-forward when in pdf-view-mode because Swiper doesn’t work with PDFs.

Whereas Maughan’s post gives some hints for adding annotations to a PDF, Marcin Borkowski over at mbork.pl talks about ways to review and follow annotations already in a PDF. As Borkowski points out, that’s perfect for blending in changes to a paper from an editor or a reviewer but also useful anytime you’re working with collaborators and using PDFs as your lingua franca.

If you work with PDFs and are an Emacs user, you definitely should check out these two posts. They’re full of good ideas and are sure to improve your workflow.

Posted in General | Tagged | Leave a comment

Good News for Mu4e Users

DJCB (Dirk-Jan C. Binnema) has announced the release of mu/mu4e version 1.0-alpha0. The NEWS file hasn’t been updated yet so it’s hard to tell what’s changed except by looking at the commit log.

I really, really love mu4e for handling my email so I’m eagerly looking forward to the final release of Version 1.0. The current release is still at the Alpha stage so it’ early days yet but the new version is now in sight.

Posted in General | Tagged , , | Leave a comment

Howard Abrams on Eshell

Howard Abrams has another excellent video up. This one, given to The London Emacs User’s Group, is on eshell. Like me, Abrams has moved as much shell work as possible into eshell. Unlike me, he’s learned how to take maximum advantage of it. One example of that is learning to make effective use of the Zshell-like glob filters that are built in to eshell. Every time I see them used, I think to myself that I really need to start using them myself but I never followup. Perhaps this video will provide me with a tipping point.

About half the video is a demonstration of eshell’s capabilities and some of the ways it differs from a “regular” Unix shell such as Bash or Zshell. One of the major differences is that eshell effectively has two command parsers. One parses “normal” shell input and the other parses lisp. Interestingly, you can combine the two syntaxes in one input string in useful ways. This part of the video is really interesting and if you’re new to eshell, it’s probably the most important part. Watching it a couple of times will help jump start your eshell use and mastery. Abrams has provided a complete transcript of the talk (including the output of the commands he demonstrates) so you don’t have to worry about copying them down from the video.

The second half of the video considers ways of hacking on and extending eshell. He shows how to do things like writing your own glob filters and leveraging the way pipes are implemented in eshell. This part is a bit more advanced but necessary if you really want to master eshell.

The video is 42 minutes so you’ll have to schedule some time. My only complaint is that the international connection made it difficult to hear to audience’s questions at the end but it’s otherwise a great video and very much worth your time.

Posted in General | Tagged | Leave a comment

Technical Problems with Today’s Post

Today’s post featured a Kontra tweet but when I published it, the tweet didn’t display. The HTML markup for the tweet showed instead. I spent a little time troubleshooting but couldn’t get it to work.

Thus, you’ll have to enjoy a beer rather than the usual Irreal ramblings.

Posted in Blogging | Tagged | Leave a comment

Using the dash Library to Work with Org Tables

The other day, I wrote about building and exporting tables from Org code blocks. I used Elisp but, of course, you can use any of the languages supported by Org Babel. In one of the examples, I showed how to build an output summary table with the low and high values from a couple of columns but didn’t bother to show the code to calculate those values. I just put in a comment about “routine code to calculate the values.”

Heikki Lehvaslaiho took that as a challenge and a chance to extend his Elisp skills to working with tables. He has a very nice solution leveraging Magnar Sveen’s dash library. I especially like his use of the -select-column function to extract a column from the table. There’s nothing magic about the function, of course; it does pretty much what you’d expect. The nice thing about it is that it saves you from having to write the tedious extraction code yourself.

There are several functions in the library that make working with tables (in the Org mode sense) easier. If you process Org tables frequently, you should definitely take a look at the library; it will make your life a little easier.

Posted in General | Tagged , | Leave a comment

AWK Examples

Before Perl and other such scripting languages, there was AWK. AWK is a great language for doing text manipulation chores. It has regular expressions, associative arrays, automatic splitting of input lines into fields, and other features to make working with text easy. The traditional reference for the language is The AWK Programming Language. It’s out of print now but you can still get a copy if you don’t mind spending an exorbitant amount. There are, of course, PDF copies available but I have no idea of their legal status.

Even if you can’t get a copy of the book, there’s the excellent The GNU Awk User’s Guide that serves as a reference manual for the GNU’s AWK implementation. If you’re looking for a quick go-by or set of recipes, Sundeep Agarwal has a nice set of AWK examples. The examples make it easy to get going and use AWK in your everyday work.

AWK excels in “one-liners” and is therefore often used in pipelines. It can also be used to build larger programs. Before Org mode, I used an AWK program to take a list of tasks and the times spent on them to typeset a time sheet with Groff. I still prefer it to Perl for most jobs that I can’t do with Org mode and Emacs. If you’re looking for a quick and easy introduction to AWK, take a look at Agarwal’s examples.

Posted in General | Tagged , , | Leave a comment

Tables and Org Mode Code Blocks

I have lots of Org files that collect data and have an embedded code block to generate a summary table. Here are a couple of examples that others may find useful. The first thing to know is that tables are stored as a list of rows with each row being a list of the row’s elements. If we think of a table as an \(m \times n\) matrix, the table is stored as

\begin{matrix}
((T_{1,1} T_{1,2} \cdots T_{1,n})
(T_{2,1} T_{2,2} \cdots T_{2,n})
\cdots
(T_{m,1} T_{m,2} \cdots T_{m,n}))
\end{matrix}

It’s pretty easy to build a table from scratch and make it the output of a code block. As a simple example, suppose you have a long table of 3 columns that tracks data over time. You don’t want to export the whole table when you output the document because a lot of the data is old and not that interesting anymore. Let’s suppose that the table is named (via #+NAME:) “data-table”. Here is a code block to output the last 3 entries.

#+BEGIN_SRC emacs-lisp :var tab=data-table :exports results :results table
  (cons '("Col. 1" "Col. 2" "Col. 3") (cons 'hline (last tab 3)))
#+END_SRC

The (last tab 3) generates a list of the last 3 rows. The two cons’s put the header and horizontal line on the front of the table. The result is

Col. 1 Col. 2 Col. 3
1 2 3
4 5 6
7 8 9

As a second example, suppose we want to use the entire input table for our calculations. Org mode is especially intelligent about this. By default, if you have a header (indicated by the horizontal line), Org will remove the header before sending the table to your code block. It’s Emacs so of course that’s configurable. You can control what happens to the header with the :colnames header argument but most of the time you’ll want the default action.

Now suppose we want to build a summary table containing the low and high values of columns 2 and 3. We can do something like

#+BEGIN_SRC emacs-lisp :var tab=data-table :exports results :results table
  (let (col2-low col2-high col3-low col3-high)
    ;; routine calculations to set col1-low, etc.
    `((" " "Low" "High") hline
      ("Col. 2" ,col2-low ,col2-high)
      ("Col. 3" ,col3-low ,col3-hi)))
#+END_SRC

Assuming the Low and High values are as shown, the last quasiquoted expression is output as the table

  Low High
Col. 2 2 8
Col. 3 3 9

The nice thing is that the “routine calculations” don’t have to worry about the header when accessing the data; it’s as if it didn’t exists.

Posted in General | Tagged , | 3 Comments

EXWM

I mentioned the Emacs X Window Manager (WXWM) in a previous post but didn’t say very much about it. Now, Phil Hagelberg has a post in which he explains his use case for EXWM. Like me and many other Emacs users, Hagelberg likes to stay in Emacs as much as he can. He even remaps his Firefox keys to be consistent with Emacs. Sadly, the next Firefox version will not support the plugin that he uses to accomplish this and he was wondering what he should do.

He discovered that EXWM has a feature called “simulation keys” that allows him to do the same thing. So, even though he had always thought of EXWM as something of a toy, he installed and started using it. He’s been very happy with it and other Irreal readers who like staying in the Emacs experience as much as possible should read his post. Perhaps it will work for you too.

As I said in my previous post, I’m a macOS user so EXWM isn’t available to me but macOS has built-in key remapping so Emacs keys work globally for me. Still, I’d like to try EXWM just to see what the experience is like. If you’re using an X-based GUI front end, you can try it out if you’re curious.

Posted in General | Tagged | Leave a comment

The Unix Philosophy

For many people, the Unix Philosophy is captured by the aphorism, “Programs should do one thing well.” That’s an important part of the Unix philosophy but the actual philosophy is much richer and more subtle. Actually, there’s no formal philosophy but rather it comprises a series of zen-like mandates contributed by several people over a series of years.

The other day I wrote about an excerpt from Eric Raymond’s The Art of Unix Programming that discussed Unix history. Today, I want to mention another section from that book that discusses the basics of the Unix philosophy. It’s a really excellent distillation of the wisdom gained by the early Unix developers. It’s still important today because it points to ways to write simpler, more robust programs—ideas that are needed more than ever in today’s environment.

Esr abstracts 17 rules from the writings and practices of the Unix elders. If you’re writing software, I urge you to spend 10 minutes reading the section from esr’s book. If you take its lessons to heart, you will write better, more easily maintained programs.

Posted in General | Tagged , | 1 Comment

Fraud in Digital Advertising

I’ve written many times (1, 2, 3, 4) about adtech and the associated fraud. The sooner the advertising industry stops tracking us the better it will be for them, the advertisers, and us. A recent BuzzFeed article indicates that the problem is much more widespread and serious than most of us believed. It turns out the fraud is rampant in digital advertising and even “legitimate” players are aware of and profiting from it. The article is long but it’s worth a read.

Tracking is infuriating and needs to end but this article calls digital advertising itself into question. In addition to the fraud, many advertisers are finding that digital advertising is largely ineffective. Proctor and Gamble, for example, recently decided to forego an large advertising buy and found it made little difference to its business.

All this got me thinking about what happens if advertisers give up on digital advertising altogether. Will the content that we enjoy and have come to depend on disappear too? Probably not because the Internet is eating all the other content delivery systems so advertisers don’t have anywhere else to go. What has to change is that the advertising agencies have to clean up their act and provide ads that consumers are willing to watch or read and to provide real value to their clients, the advertisers. It’s pretty clear that that means—just for starters—no more tracking and no more fraud.

Posted in General | Tagged | Leave a comment