Pretty Printing and Macroexpanding the Last Sexpression

As Emacs users, we’re always discovering some new feature of our favorite editor. Here’s one that’s so obscure not even John Wiegley was aware of it.

Over at the Emacs subreddit, glyfo was showing off a bit of elisp that he wrote to macroexpand the last sexpr. Kaushalmodi noted in the comments that there’s already a command for that, pp-macroexpand-last-sexp. That nice to know because it can often be useful. At bit later John commented that he hadn’t been aware of the command but had often needed it.

If you’re writing Elisp or just trying to read and understand some code that uses a macro, this is a command worth knowing. The name is pretty easy to remember and even if I forget, I can find it again by searching Irreal.

Posted in General | Tagged , | Leave a comment

Should We Abandon PDFs?

Robert Zaremba thinks we should; at least for publications that aren’t going to end up printed on paper. His argument is that PDFs don’t work well on digital screens. He has a point about PDFs not working very well on Smart Phones. I don’t agree that they’re bad on, say, iPads or many other digital display devices.

I disagree very strongly with Zaremba about retiring PDF. I’ve seen his arguments before and wasn’t persuaded then either. As far as I’m concerned, it remains the best portable document format available. The idea that it can be replaced by something like EPUB is a nonstarter for me.

What do you think?

Posted in General | Tagged | 3 Comments

Nicolas Petton on GTD with Org Mode

Nicolas Petton over at Emacs Café has an excellent post on how he uses Org Mode for Getting Things Done (GTD). You can find many articles that cover this material but I like Petton’s because he shows in detail how he configures Org Mode for GTD, covers his workflow, and, along the way, explains why he made the decisions he did.

If you’re interested in using the GTD method, Petton’s post is a good place to start. You probably won’t want to do everything exactly the way he does but the post provides a good framework to build your own system.

Petton says he’s been using the system for four years and has over 39,000 lines in the Org files devoted to GTD. If you have the discipline for GTD, it’s an excellent way of arranging your time and making sure that things get done when they should. Even if you don’t want to become a GTD disciple, Petton has some good ideas that you may want to emulate in your own workflow.

Posted in General | Tagged , | Leave a comment

Indenting and Pretty Printing a Sexpr

Over at the Emacs Stack Exchange, Jue asks if there’s something equivalent to fill-paragraph for S-expressions. Part of the problem is that paredit redefines Meta+q so fill-paragraph appears not to work.

It turns out, though, that there is a command specifically intended to reflow sexprs. That command is indent-pp-sexp, bound to Ctrl+Meta+q. It won’t break up lines but it will reindent them properly, something I, at least, often need. If you specify the universal argument, it will pretty print the sexpr, including breaking lines up and properly indenting the expression.

Posted in General | Tagged | Leave a comment

Some Common Items for Your Emacs Configuration

Xah Lee has a nice page describing some common configuration settings that you can add to your init.el. It covers such things as how to show line numbers, have sentences end with a single space, and many others (see below). They should be especially useful for n00bs as I often see questions on Twitter or Reddit asking how to do some of the things he demonstrates.

Here is the list of things he shows how to do:

  • How to startup emacs without loading any customization?
  • How to have standard keyboard shortcuts for Copy and Paste?
  • How to have standard keyboard shortcuts for {Open, Close, Save, Save As, Select All, …}?
  • How to have redo?
  • How to make the copy key copy the current line when there’s no selection?
  • How to automatically insert right bracket when left one is typed?
  • How to make cursor movement stop in between camelCase words?
  • How to make typing delete/overwrites selected text?
  • How to have cursor line always highlighted?
  • How to have matching parenthesis highlighted? (when the cursor is on one)
  • How to remember cursor position?
  • How to set default file encoding?
  • How to change the default font?
  • How to show line numbers?
  • How to show the cursor’s column position?
  • How to disable emacs’s automatic backup~ file?
  • How to disable emacs’s “#auto-save#” backup?
  • How to set emacs so that all backups are placed into one backup folder?
  • How to stop emacs’s backup changing the file’s creation date of the original file?
  • How to refresh file automatically?
  • How to open recently opened file in emacs?
  • How to restore opened files from last session?
  • How to re-open last closed file?
  • How to setup tabs, space, indentation?
  • How to turn on ruler?
  • How to show tabs as in web browser?
  • How to have the down arrow key move by screen lines?
  • How to have lines soft wrapped at word boundary?
  • How to adjust margin?
  • How to make lines NOT soft-wrap?
  • How to set the spacing between lines?
  • How to reformat paragraphs so that lines are not longer than 70 chars?
  • How to unfill-paragraph? I want to remove line-break in a paragraph.
  • How to have fixed scroll?
  • How to save/store minibuffer history?
  • How to make sentence ending by single space?
  • How to save/store cursor position?
  • How to stop cursor blinking?
  • How to set cursor to i-beam?
  • How to set up emacs so that each file opens in a new window?
  • How to set color theme?
  • How to show CSS hex color spec in color?

Take a look at the list and see if there’s something there that you’d like to have your Emacs do.

Posted in General | Tagged | Leave a comment

Fallout From the NSA’s Loss of Hacking Tools

The New York times has a fairly complete rundown on the debacle resulting from the NSA losing control of their hacking tools and the subsequent disclosure of those tools by the Shadow Brokers.

Remember this the next time they tell us, “You can trust us with a backdoor into your smartphone and other encryption services.” How long do you think it would take before the Shadow Brokers or some other group releases their “golden key?”

Posted in General | Tagged | Leave a comment

Get in the Flow!

Via Karl Voit, here’s something you can post on your office door or outside your cubical. Of course, as we all know, it won’t do any good but you’ll feel better.

Posted in Programming | Tagged | Leave a comment

Tutorial on Ivy, Counsel, and Swiper

Michael Hunsinger has a very nice tutorial on using Ivy and the associated packages Counsel and Swiper. I’ve been an ardent user of these packages ever since Mike Zamansky turned me onto them with this video.

In addition to user-level interactions with Ivy, Hunsinger shows how to use them to provide powerful commands using an absolute minimum of Elisp. Even someone who’s not a Lisp programmer can probably program up a custom command by following Hunsinger’s template.

The only thing I’d add to Hunsinger’s post is how select the input text rather than one of the suggestions. That happens fairly often for me when I want to open a new file whose name matches one or more existing files that Ivy is suggesting. The answer (Ctrl+Meta+j) is simple but definitely not obvious.

If you’re not already using Ivy/Counsel/Swiper, take a look at Hunsinger’s post. It may convince you to give them a try.

Posted in General | Tagged | Leave a comment

Five Org Mode Features

Aja Hammerly has a post that those trying to decide whether or not Org mode is for them may find useful. Hammerly is a developer advocate for the Google Cloud Platform. As such, she writes tutorials, gives talks, and even writes code. Her post looks at 5 useful Org features that help her prepare her tutorials and talks.

The 5 features that she looks at are

  1. Table and Spreadsheets
  2. Todos and Checklists
  3. Tags
  4. Code Blocks
  5. The fact that everything is just text

Hammerly is a self-described Org n00b and admits that she isn’t using its full power. Still, just using its outlining and checklist capabilities improves her workflow. If you’re new to Org and trying to decide if it’s worth learning, you should take a look at Hammerly’s post. Among other things, it shows that you can start slowly—indeed, that’s the optimal approach—and learn the more complex features as you need them. As you can see from Hammerly’s post, the features she describes are simple to understand and use.

Later, you’ll probably find yourself using more and more of Org’s capabilities. Eventually, you may find that, like me, you’re using it for the majority of your writing.

Posted in General | Tagged , | Leave a comment

Zamansky 35: Blogging

I discovered Mike Zamansky’s blog about a year ago when I wrote about his transition to Nikola as a blogging platform. Shortly afterwards, he began his Using Emacs Series. His latest video has, in effect, come full circle as he, once again, looks at blogging with Nikola.

I always enjoy seeing other people’s workflows and particularly their blogging workflows. The video details Zamansky’s efforts to bring the entire blogging workflow under Emacs. After his transition to Nikola, a lot of the workflow was conducted on the command line. His latest improvements involve using Prodigy to manage the non-Emacs part of his workflow. He’s now at the point where virtually everything can be done from within Emacs.

Watching the video makes me appreciate anew the wonderful org2blog/wp that I use for blogging. Everything is completely contained within Emacs; I simply write my post as an Org mode file and call org2blog to post it to my WordPress site. Of course, many folks prefer static pages and don’t want to bother with a heavyweight CMS like WordPress. For them, a solution like Zamansky’s makes a lot of sense. You can do everything from within Emacs and the process is pretty much automated. There are, of course, solutions other than Nikola and I’ve written about some of them but since I don’t use them those posts could only describe what others said about them. If you’d like to start (or switch to) a statically paged blog, Zamansky’s video is a good place to start. The video is 14 minutes long.

Posted in General | Tagged , | Leave a comment