Ivy, Counsel, and Swiper

As regular Irreal denizens know, I’m a huge fan of the Ivy/Counsel/Swiper suite and consider it one of my two most important packages (along with Org mode, of course). If you aren’t already using it, you should stop what you’re doing and install it right now.

If you’re not decided, Michael Hunsinger has an excellent introduction and tutorial. It by no means covers everything the suite can do but it does show the basic operations, complete with animated gifs. If you want to whole picture, take a look at the Ivy User Manual. It shows all the shortcuts and explains the wonderful regex interface. If you’re an Ivy user and not familiar the alternative regex modes, be sure to take a look at the Completion Styles section of the manual. With the later versions of the suite you can change the method on-the-fly so, for example, if you want to search for several terms in any order, it’s easy to do.

Take a look at Hunsinger’s post and see if you aren’t convinced. Really, it will make your workflow much more efficient.

Posted in General | Tagged | Leave a comment

Writing LaTeX with Org Mode

Writing in \(\mathrm{\LaTeX}\) produces beautiful documents but there’s a pretty steep learning curve. If you’re writing technical documents with lots of mathematics, it’s worth climbing that curve and if you’re an Emacs user, you’ll certainly want to become familiar and adept with AUCTeX.

If you’re a more casual \(\mathrm{\LaTeX}\) user and just want to write a nice looking report or even a letter, there’s an easier way: Org mode. With Org mode, you simply write in the usual Org markup and then export to \(\mathrm{\LaTeX}\) or PDF. You can embed \(\mathrm{\LaTeX}\) commands in the document and add headers to the Org source so that you have pretty much complete control over the look of the final document. It’s even possible to produce journal ready \(\mathrm{\LaTeX}\) or PDFs as John Kitchen has shown (click to see the list):

Sachin Patil has a nice post that shows how easy it is to produce \(\mathrm{\LaTeX}\) with Org mode. You can produce nice looking documents from a completely vanilla Org file that doesn’t mention \(\mathrm{\LaTeX}\) at all. Of course, you can also export that same Org file to HTML or any of several other formats.

I do almost all my \(\mathrm{\LaTeX}\) document preparation through Org mode. I still have some things in \(\mathrm{\LaTeX}\) format but those are mostly older or documents with a lot of mathematics in them. If you want to produce nice looking documents, Org mode is an easy way to do it and Patil shows you how.

Posted in General | Tagged , | Leave a comment

Emacs Lisp Bytecode

Very few Emacs users—no matter how advanced—ever need to worry about the specifics of the Elisp bytecode, or even, for that matter, that it exists. Still, as guys like Chris Wellons have shown, it can sometimes be useful to have a basic understanding of the bytecodes.

R Bernstein has put together a comprehensive, book-length documentation on Elisp bytecodes. After a short introduction, the documentation considers the bytecode environment including the compiler, interpreter, and bytecode optimization. Then there’s a long section on the individual bytecode instructions.

Finally, there are sections on the changes in bytecodes between Emacs versions, a table of opcodes, and a reference section. There’s also a GitHub repository of the document source.

As I said, you probably will never need this but if you do, you’ll be very glad to have Bernstein’s documentation. It’s another example of the vibrant Emacs community.

Posted in General | Tagged | Leave a comment

What Cursor Position

You may or may not know about what-cursor-position (bound to Ctrl+x =) that displays the current position of the point in the echo area. It’s probably not too useful if you have the row and column displayed in the mode line although it does give additional information.

Wilfred Hughes’ Emacs Command of the Day offers a handy tip about it:

All that information is the same as what you get with describe-char but it’s conveniently bound to a shortcut, which decribe-char isn’t by default.

Posted in General | Tagged | Leave a comment

File Name Conventions and Tagging Trees

A couple of days ago, Karl Voit gave a really great talk at Grazer Linuxtage 2018. It was entitled The Advantages of File Name Conventions and Tagging, which is pretty much self-explanatory except for the tagging part.

The first part of the talk discusses Voit’s fine naming conventions and the tools he uses to make dealing with them easier. A typical file in his file system has the form

 2013-05-09T16.17 file name with time stamp -- tag3 finance.csv 

Note that there are several parts to the name. First there’s the date or date/time section that gives the date—and perhaps time—of a file. Next there’s a brief description of the file’s content followed by one or more optional tags separated from the description by “ -​- ”. Finally, there’s the file extension, as usual.

Notice how that convention makes it easy to search for files in any number of ways. If you’re searching for photographs taken on 2018-04-29, you might use something like

find . -name "2018-04-29*.jpg" 

to locate them no matter where they’re stored. Similarly, you could search for one or more tags.

The meat of the talk for me is the notion of Tag Trees. The idea is that the files are kept in a single storage area and then indexed by their tags. If we’re trying to find the file 2013-05-09T16.17 file name with time stamp -- tag3 finance.csv, we can look for all the files in the Tag Tree with the tag tag3 or for all the files with the tag finance but there might be many such files. In the branch of the Tag Tree for tag3 there’s a subtree for finance, which has all the files with a tag of both tag3 and finance. Similarly, the Tag Tree branch finance/tag3 contains a link to the file.

I’ve given a very brief description here, so be sure to take a look at the talk for the details. The video is 45 and a half minutes, so plan accordingly. If you’d like to get your file system organized and make files easy to find, you really need to watch this video.

Posted in General | Tagged | Leave a comment

Emacs Video: Play Emacs Like an Instrument

Alain Lafon gave an excellent talk on using Emacs like a virtuoso, which, happily, was captured on video and is available for everyone to enjoy. The talk isn’t really an introduction to Emacs for n00bs—although it could be used for that—rather it’s a demonstration of how a master uses Emacs as the center of all his computing.

Lafon’s inclination, like mine, is to do everything from within Emacs. He thinks of Emacs not as an editor but as a Lisp REPL. That’s similar to my thinking of Emacs as a sort of light-weight Lisp Machine. The impetus for both points of view is that Emacs is the hub of our computing, not just an editor.

This talk is definitely worth watching. I learned about generating thumb nails of pictures from Emacs, picked up an idea for a “code snippet” capture template, and several other Emacs capabilities that I either didn’t know about or didn’t know the details of. The subject matter is much too extensive to cover here so I’ll just refer you to the talk. The only thing that surprised me about his Emacs environment is that he’s still using Ido and Smex rather than the far superior Ivy/Counsel/Swiper suite.

The video is a bit over and hour and 50 minutes so you’ll definitely need to schedule time. You may want to download the slide deck first so that you can get an idea of what Lafon covers but be warned that the slides don’t cover some of the most interesting material he discusses.

Again, even though the video is lengthy, it’s well worth your time. You’ll almost certainly learn some new Emacs techniques and it’s just enjoyable to watch a master show his work flow and what he can make Emacs do.

Posted in General | Tagged | Leave a comment

Documents and Presentations with Org Mode

John Goerzen has another post in his coming back to Emacs series. This time he looks at writing documents and preparing presentations with Emacs and Org mode. It’s an elementary discussion but there’s plenty that will be useful to newcomers to Org.

He starts with an explanation of the Org exporting system and how easy it is to export an Org document in many different formats. In addition to the “standard” export formats provided out-of-the-box by Org, there are several 3rd party packages that allow exporting to additional formats.

One of those export options is to Beamer. Although it’s just another export choice, it feels like a separate functionality. You can write your presentation in an easy and natural way with Org and then export it to a set of slides suitable for a presentation. Although he doesn’t mention it, there is also the org-reveal package for presentations. If you have presentations to give and want slides to go with them, either Beamer or org-reveal gives you an easy way to generate them from the comfort of Emacs and Org.

If you’re new to Emacs, Goerzen’s series on his return to Emacs is worth reading. It’s a good overview of Org mode and Emacs and what they can do for you.

Posted in General | Tagged , | Leave a comment

Org 9.1.12

Bastien Guerry tweets that there’s a new version of Org available:

If you’re tracking the Org repository, the new version is already there.

Posted in General | Tagged , | Leave a comment

Happy Birthday Irreal

Today is the 7th anniversary of Irreal as a WordPress blog1. Irreal started out as a way to make occasional posts about Scheme, Common Lisp, and a couple of other Lispy subjects. It’s evolved into a daily blog that considers a broad range of technical areas and, occasionally, a rant about privacy and government spying on its citizens.

A lot of readers think of Irreal as an Emacs blog, which isn’t surprising given that the majority of my posts are on Emacs. I didn’t expect that but I suppose it’s a logical outcome of my interest in Lisp and my yearning for a Lisp Machine-like environment.

As Irreal enters its eighth year, I expect things to stay pretty much the same: daily posts featuring a lot of Emacs, some Lisp, and the occasional venting of my fury about government surveillance abuses. If there’s something that you’d like to see me write about more, feel free to leave a comment.

Footnotes:

1

The original Blogger version of Irreal started in 2009.

Posted in General | Tagged | Leave a comment

Programs that Program

I’ve written before about Eric Raymond’s (esr) UPSide project that aims to build an open source UPS that has reasonable performance and sensible operation. Esr’s latest post is especially interesting to me because it uses one of my favorite techniques: having programs write programs.

The control logic for UPSide features a state machine that listens for events—loss of AC power, say—and performs the required action based on the current state of the system. The traditional way of documenting state machines (at least for reasonably sized ones) is with a state transition diagram. Here’s the state transition diagram for UPSide. It’s straightforward and easy to understand. Spend a couple of minutes with it and you’ll understand the broad view of how UPSide works.

The diagram itself is produced with the Graphviz dot language. Dot is pretty simple to use but there’s a lot of boilerplate and it can be hard to read. Rather than deal with the grunt work, esr wrote the states and their transitions (what he calls “actions”) in a pseudocode that he shows at the bottom of the state diagram. I almost always do something like this when I’m dealing with a nontrivial dot graph because it lets you think about the diagram you’re producing rather than the dot language.

Esr took this one step further. He realized that he could use that pseudocode to generate the Go source code for the state machine too. That’s a big win because it’s much easier to understand and debug the state diagram then it is the Go code. Indeed, within an hour of posting the diagram, people were already reporting a bug in the state machine. Did you see it? Fixing it was easy: Esr simply changed a single action in the pseudocode and regenerated the diagram and Go code.

Generation of the diagram and code are both done with this small Python program. Everything that’s needed—including the pseudocode—is contained in the source for that program. It’s easy to understand and worth studying if this technique is new to you. Or even if it isn’t, you may learn some useful ideas.

Esr talks about using this technique in this UPSide progress report.

Posted in Programming | Tagged | Leave a comment