Unique Emacs Features

Over at the Emacs reddit, Gink0 asks What dev feature is available in emacs but not in the current mainstream IDEs? It’s sort of like the usual question of “What makes Emacs so great?” or “Why do you recommend Emacs?” but with the added constraint that it has to be things that other editors don’t have.

For me, the salient feature is that Emacs provides the closest thing we have to a modern light-weight Lisp Machine. It’s not the “Lisp Machine” part that matters, of course, it’s what “Lisp Machine” is shorthand for: a complete, totally, configurable, and even reprogrammable operating environment. That means that can do just about anything you do on a computer in Emacs and do it with a unified interface.

Many of the responses to Gink0 hinted at this but emphasized the configurability that Emacs has far in excess of other editors. Other responses mentioned Org mode and its enabling of literate programming. Other editors may support literate programming to varying degrees but Org mode’s code blocks are special. Not only can you have traditional literate programming in the Knuth sense but you can also embed executable code in an Org file and have the results of running that code appear in the file. It’s tremendously powerful regardless of whether or not you like Knuth’s version of Literate Programming.

Those are the big things. Some of the commenters mentioned smaller things such as narrowing, rectangular editing (although lots of editors have that), the best Vim emulation, undo tree, Eshell, and the notion of modes.

What’s on your list?

Posted in General | Tagged | Leave a comment

Zamansky: Learning Elisp 3

Mike Zamansky has the third video in his Learning Elisp series up. As promised, this one is about writing functions. As Zamansky points out, Elisp functions are pretty much the same as function in other languages except for the lack of a return statement and, of course, the syntax.

There are a couple of interesting aspects to Elisp functions. The first is the Doc String. Lots of languages have something similar but in Emacs the Doc String is automatically imported into the Help system so a user’s own functions are documented just like the built-in functions.

The second aspect is the interactive declaration. Including it makes the function “interactive”, which means that you can call it from the keyboard with Meta+x or by assigning it a key binding. My goal for writing Elisp is to write an interactive function where I remember to add the interactive declaration before I try to run it from the command line.

The video covers just the very basics of writing functions. Zamansky is planning on getting into some of the deeper aspect in later videos. This video is 12 minutes, 36 seconds long so you’ll probably have to schedule some time.

Posted in General | Tagged | Leave a comment

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