Zamansky: Learning Elisp 2

Mike Zamansky has posted his second Learning Elisp video. In this episode, he briefy discusses defining variables, both global and local. The rules are a bit different from most other languages but still simple enough to understand easily.

In keeping with his taking things slowly, he doesn’t mention the closely related concept of closure but presumably that will come after he’s laid a bit more groundwork. If you have any experience at all with Elisp, nothing in this video will be new but it’s just what a n00b needs to get started.

He was originally going to include functions in this video but decided it would be too long so he decided to defer functions to the next video. Once that’s done, his plan is to move into the “interesting stuff” and show how to use Elisp to write interesting and useful functions.

The video is 11 minutes, 58 seconds long so plan accordingly.

Posted in General | Tagged | Leave a comment

Red Meat Friday: Once More Unto The Breach

You can talk about your Vi versus Emacs, spaces versus tabs, or any of the other religious wars that infect tech but none are so widespread as the proper number of spaces at the end of a sentence. I’ve seen a lot of discussion of this lately, both on Irreal and elsewhere. The debate is evergreen.

The typewriter—or more specifically, monospaced fonts—is to blame. Generations of typists were taught to put two spaces after a sentence as a way of helping to visually separate one sentence from another. That doesn’t make sense with proportional fonts so the conventional wisdom now is that double spaces are not only unnecessary but the spawn of the devil. It seems like a nobrainer but, of course, it isn’t.

In the first place, there are a bunch of those typists still around who are loath or unable to give up their years of training. It’s ingrained and they can’t see any reason to change. After all, modern word processors and typesetting systems will automatically provide the correct spacing between sentences regardless of input so why should they change? This argument is taking place outside of the tech arena as well. People who would rather die than admit to being a geek are invested in the debate.

The argument rages within geekdom too. Even younger engineers who have never used a typewriter sometimes champion the two space rule. Their argument is that it’s easier to write scripts that parse sentences and distinguish between the end of a sentence and constructs such as “Mr. Jones” and “e.g.” if sentences end with two spaces.

That brings us to Emacs. Emacs, being infinitely configurable, lets you have it either way. You can set it to have sentences end with one or two spaces. The default—probably honoring the convention at the time—is to use two spaces. Of course, having a choice is the same as having a controversy so even Emacs users are caught up in the debate. And they’re really opinionated.

Partisans on both sides are giving no quarter. The single spacers can’t understand the revanchist attitude of the two spacers and the two spacers can’t understand the dogmatism of the one spacers. The truth, as usual, is that it doesn’t really matter: any decent typesetting software will do the right thing regardless of the input and Emacs will also do the right thing.

I was for years a two spacer but only because of years of using a typewriter. After a while I became convinced that a single space was better if only for parsimonious reasons so I changed. Emacs continues to do the right thing and I can’t remember suffering any adverse consequences.

There are lots of debates that matter. This isn’t one of them.

Posted in General | Tagged , | Leave a comment

A Notmuch Workflow

As most of you know, I’m a Mu/Mu4e user and have been very happy with it. It has, I think, the correct paradigm for handling stored email: everything goes into a single repository and emails are retrieved with its outstanding search capability. Stored messages are indexed so these searches are very fast. You can, of course, use the normal method of multiple mailboxes but why would you?

Another of Mu’s benefits is that it runs in Emacs. That’s a benefit that it shares with Notmuch a similar package that has excellent search and indexing too but also implements a tagging workflow.

Michał Sapka was tired of using Webmail because of its inflexability. He used Neomutt for a while but decided he’d like to fold his email into Emacs. He quickly settled on either Mu/Mu4e or Notmuch and—apparently randomly—chose Notmuch. That was a good choice for him because his workflow includes working with GitHub Pull Requests and he brilliantly leverages Notmuch’s tag system to automate it as much as possible. He goes into detail on how his workflow functions so be sure to take a look at his post.

Another nice thing about his post is that gives an excellent explanation on how to configure Mbsync. If you’ve been around Irreal for a while, you may remember that that was the thing I had the hardest time with when I moved to Mu4e. It’s definitely a worthwhile post if you want to move your email to Emacs.

Posted in General | Tagged | Leave a comment

Emacs Calendar Navigation

Over at the Emacs Elements Channel there’s an interesting video on navigating the Emacs calendar. I was excited when I saw it because although I seldom or never interact with the Emacs calendar, I often use its Org mode lookalike. While they appear to be identical, their user interface is different.

It’s possible to move around in the Org mode calendar by using the Shift and arrow keys. It works just like you think it would and, of course, you can always just click on your desired target. The thing is, as much as I make fun of true believers in our community, I really, truly, believe that you should avoid using the arrow keys when you can and, of course, the mouse is a heresy of the first order. I always feel a little queasy when I use it.

The Emacs calendar, on the other hand, uses the normal navigation keys to move around the calendar in very intuitive ways. Take a look at the video to see what I mean. That’s why I was excited: I thought maybe I could use the right™ keys to navigate the Org calendar. Sadly, that didn’t work because focus is in the minibuffer and keys such as Ctrl+f move the point in the minibuffer instead of the calendar display. Even if you move focus to the Calendar buffer, the normal keys still don’t work.

In a confounding irony, the Shift and arrow keys will work with the Emacs calendar. So if you’re looking for a unified method to moving about the calendars and don’t mind using the arrow keys, Emacs has you covered.

The video is only 5 minutes 14 seconds so it should be easy to fit in.

Posted in General | Tagged , | Leave a comment

Emacs For Common Lisp

Susam has a very nice Githup repository that contains an Emacs configuration for working with Common Lisp. The nice thing is that the README contains a complete explanation of what the configuration is doing and has a line-by-line exegesis of it so that you can understand how it works and how to modify it to suite your individual needs.

I don’t use this configuration—having started with Common Lisp long before I saw it—but my configuration is almost identical to Susam’s. The main difference is that I don’t use rainbow delimiters. I’ve found that Paredit keeps track of parenthesis nesting for me but you may find rainbow delimiters useful.

Susam thinks of his configuration as being for Emacs/Common Lisp n00bs and therefore has some introductory material on using Emacs itself but even if you’re experienced with Emacs but not with Common Lisp, you will find it useful for getting started.

The main features of the distribution are:

  • Slime
  • Paredit
  • Rainbow Delimiters
  • Quicklisp

Some of these require a bit of configuring to invoke them for the appropriate modes so Susam’s configuration is a good place to start. You can, as I did, figure all this out for yourself but Susan’s configuration provides an easy starting point.

The README for the repository is fairly long but worth at least skimming through if you’re interested in setting up a Common Lisp development environment.

Posted in General | Tagged , , | Leave a comment

Media Progress

Dmitriy Pshonko has an interesting project for those of us who like to (a) stay in Emacs and (b) use the mpv media player. The idea is that you can list your media files with dired and it will tell you where you left off in the file if you started but did not complete it. Files that you’ve completed are marked done and the rest are simply listed.

I almost always consume these files in one sitting but sometimes I get interrupted and it would be nice to have a way of picking up where I left off. I don’t use mpv so I haven’t installed this package but if I did use mpv, I certainly would. It’s in MELPA so installation is simple and configuration consisted of setting a hook. The README explains how to do this directly or with use-package and is in any event a one liner.

If you’re an Emacs and mpv user, this package seems like a very nice addition.

Posted in General | Tagged | Leave a comment

Duplicating Dired Files

I ran across a post by James Dyer, Dired Duplicate Here Revisited, that was interesting and I thought was worth writing about but I wasn’t sure there was enough there for a post. Then I saw this post by Álvaro Ramírez and thought they complemented each other and together can serve as the basis for my own post.

It turns out that Ramírez had the same thought and that his post was inspired by Dyer’s. It started with Dyer wanted a quick way to duplicate a file in a Dired buffer. His workflow results in a frequent need to do this so it made sense to make it as frictionless as possible. His code to do this is simple and straightforward.

Ramírez, of course, extended the idea by including it in his dwim-shell-command framework. He uses Bozhidar Batsov’s crux-duplicate-current-line-or-region that duplicates a line or region. It’s similar to Joe Casadonte’s and Steve Purcell’s whole-line-or-region that I use. In any event, he leveraged his muscle memory for that by using it to invoke his dwim-shell-command template to duplicate one or more files in a Dired buffer.

If you also have a need to duplicate one or more files in a Dired listing, take a look at these two posts. They present two excellent solutions.

Posted in General | Tagged | Leave a comment

Emacs Defaults

Charles Choi has another thought provoking post: this time it’s about Emacs defaults. He begins by noting that Emacs exemplifies the idea that you should separate policy and mechanism by providing a mechanism but leaving the actual policy to the end user. Put another way, Emacs allows the user to determine how certain functions will behave. That’s tremendously powerful and liberating.

The problem, he says, is the default policies. For any given action—whether or not it’s configurable—Emacs has to something and that something is the default policy. Choi’s complaint is that the default very often violates the principal of least surprise. I’d screw down on that by saying it violates the principal of least surprise for today’s users. Things like the CUA conventions are what new users might expect but not what long term Emacs users expect. The right thing for new users is probably to enable the CUA bindings by default but that would confound and anger long term users. My point is that it’s not as easy as doing “what people expect”.

The majority of Choi’s post is devoted to default choices with which he disagrees. Most are hard to argue with. There’s no reason, for example, why bookmarks shouldn’t be saved immediately rather than risking them in an Emacs crash.

Some, such as the number of spaces ending a sentence are not as straightforward as he and others imagine. Yes, we are no longer using typewriters and the original rationale for using two spaces no longer applies but, again, old time users may expect the two space rule. Even those who’ve never used a typewriter can make a coherent case for it: it’s easier to write scripts and distinguish end of sentences from things like “Mr. Jones” if sentences end in two spaces. This is a raging question even outside the Emacs community.

In others, such as Magit prompting you if you have an unsaved buffer that might effect the current operation, I think he’s just plain wrong. Almost every time I see that prompt it’s because I have, in fact, neglected to save a buffer. Of course, we all have different work flows so you may disagree.

Finally, his suggested defaults includes some useful things that I didn’t know about. For example, I run Emacs in full screen, which means that when I run Ediff the control panel is not visible. Choi explains how to fix this. similarly, when you invoke Man, the focus stays in the current buffer making it hard to negotiate the man buffer. Again, this is configurable and it seems to me to make more sense to do as Choi recommends.

It’s a good post and you may even learn something useful like I did.

Posted in General | Tagged | Leave a comment

Zamansky Elisp Video #1

The first video in Mike Zamansky’s promised series on Elisp has dropped. This video serves as an introduction to the series. It mostly positions Emacs as a Lisp interpreter that comes with an editor. Or as Irreal is fond of saying, a recapitulation of the original Lisp Machines. Emacs is not really a Lisp Machine, of course, but I’ve found that it helps my understanding of it to think of it that way.

Zamansky’s central point is that everything you do in Emacs amounts to running one of it’s commands. The obligatory example is what happens when you type a character into a buffer. That results in the command self-insert-command being run. Zamansky shows how you can run any s-expression in a buffer by putting the cursor at the end of it and running eval-last-sexp (bound to Ctrl+x Ctrl+e) and uses that to open a file and to change to another buffer.

Zamansky takes the material slow and easy. Even though he described it as just a short introduction to the series, the video ran 19 minutes, 49 seconds so he’s making sure to cover each point carefully and illustrate it with examples. Obviously, at almost 20 minutes, you’re going to have to schedule some time but as with all of Zamansky’s videos, it’s time well spent.

Posted in General | Leave a comment

A Nice Dark Theme

The Minions aren’t going to like me saying this but I’ve stumbled upon a nice and actually legible dark theme. idlip Dilip has a new, high-contrast theme, Haki, that started with Prot’s modus-vivendi and some of Daniel Mendler’s packages to design a theme that was perfect for him.

Take a look at his screenshots to see what it looks like in a number of Emacs modes. Notice how everything is legible. There is no dark blue on black or other unreadable hideousness. Just sharp, high-contrast colors. And I love the irony of the top post in his Elfeed screen being Irreal’s Red Meat Friday: Dark R Sessions in ESS.

Even though it’s relatively new, Haki is already available in MELPA. The README has installation instructions and a use-package recipe. I will not, of course, be abandoning my light mode non-theme but if you’re in the intersection of people who (1) like dark themes and (2) like being able to read the text in the buffer you should definitely take a look.

Posted in General | Tagged | Leave a comment