Some Oldies but Goodies Updated—Part 1

About 15 months ago, I wrote a post, Some Oldies but Goodies, that talked about some of the packages that I found most useful in my day-to-day work. On rereading that post, I find that it’s aged well in the sense that the packages I talked about are still important parts of my workflow. In particular, abo-abo’s define-word and Steve Purcell’s whole-line-or-region packages remain two of my most used packages. Each of them gets invoked several times a day.

Of course, there’s always more to learn about Emacs and new packages are being added everyday so I thought I should talk about some of the packages I’m using now that have become important for my workflow. This time I have 9 packages to discuss so I’ll break the post into two parts. As I did in the original post, I’ll point back to the post that originally discussed them.

By far, the package that’s had the most impact on my workflow is the Ivy/Swiper/Counsel suite. I really love these packages. They’ve completely replaced isearch, ido, and smex in my workflow. The modified regular expression selection that Ivy implements takes a day or two to get used to but I’ve found it’s much more useful than normal regular expression search (which is still available, of course). If I could have only one package—suite really—this would be it. If you’re not using it, you owe it to yourself to check it out. Mike Zamansky’s post and video is a good place to start. I show my current configuration below but I also use other counsel functions by calling them with Meta+x.

(use-package swiper
  :ensure t
  :diminish ivy-mode
  :bind (("C-s" . swiper)
         ("C-c C-r" . ivy-resume)
         ("M-x" . counsel-M-x)
         ("C-x C-f" . counsel-find-file)
         ("C-M-i" . complete-symbol)
         ("C-." . counsel-imenu)
         ("C-c 8" . counsel-unicode-char)
         ("C-c v" . ivy-push-view)
         ("C-c V" . ivy-pop-view)
         ("M-y" . counsel-yank-pop))
  :config
  (ivy-mode 1)
  (setq ivy-use-virtual-buffers t)
  (setq ivy-count-format "%d/%d "))

For years I’ve been taking Steve Yegge’s advice and using search for navigation. My use of isearch for that has almost entirely been replaced by abo-abo’s Avy library that provides (or, really, powers) a replacement for ace-jump-mode. I tend to edit as I write so I’m always jumping around in the buffer. Avy makes that almost painless. This is another package that I use constantly everyday. Avy also provides ace-window, which is just what you need if you have more than two windows open and need to switch among them easily. The Avy library powers other useful tools as well. If you’re not already using it, take a look at its GitHub page.

If you’re using Emacs for coding, something like TAGS is really useful for quickly jumping to a function or variable definition even if it’s in another file. I’ve never been able to warm up to TAGS systems because they are hard to maintain. You have to take steps to regenerate your TAGS file every time you make a change to any of the covered files. Then I found dumb-jump. It’s just perfect for me. There’s nothing to maintain and it’s very fast. If you’ve resisted using a TAGS system because of the hassle of dealing with the TAG file, take a look at dumb-jump.

Another package I resisted installing for a long time is PDF Tools. I finally decided to give it a try after reading Piotr Limanowski’s post on Reading for Programmers. I really liked the way he used the Interleave package to take notes while reading a PDF paper. Even without Interleave, PDF Tools is a substantial improvement on the default DocView. It’s fast and you can make annotations directly to the PDF. If you interact with PDFs, this package is definitely worth a look.

In the second part, I’ll take a look at 5 other packages that are making my workflow easier.

Posted in General | Tagged | Leave a comment

Decouple Your Phone from Sensitive Accounts

Laura Shin over at Forbes.com offers some excellent advice for safeguarding your sensitive accounts such as bank accounts, Dropbox, cloud storage, and the like. Some of it is the usual sensible advice such as using a password manager that generates long high entropy passwords, using two-factor authentication, and lying about the answers to security questions1.

But as Shin points out, a weak link for most accounts is your phone. If a criminal can get access to your phone account and forward calls to his account, two-factor authentication can be largely bypassed and password reset protocols can be compromised. Shin recommends that you

  • Disable online access to your phone account
  • Add a password or pin to your phone account
  • Use a phone account specific email address for your phone account
  • Tell your phone carrier to allow changes only in person with a photo ID
  • Try Google Voice
  • Don’t associate your main phone number with any sensitive accounts
  • Use biometric authentication

Shin explains how you can implement the above steps. She’s got a lot of good advice and it’s definitely worthwhile implementing as much of it as you can. Don’t think you’re safe because you’re not important or rich; criminals will be just as happy to steal your money as anyone else’s.

Footnotes:

1

I like to use UUIDs for this (on macOS you generate them with uuidgen) but of course this make sense only when you’re using a password manager.

Posted in General | Tagged | Leave a comment

An Emacs Tutorial Series

Mickael Kerjean has an interesting series of Emacs tutorials over at his blog. He approaches the tutorials from the point of view of the learning path that he would have liked to follow when he learned Emacs.

The tutorials are not how-tos on the fine points of using Emacs but instead offer pointers to resources along with commentary on why a given facility is useful. There are 5 tutorials covering:

  1. Basics
  2. Org Mode
  3. Built-in packages
  4. Adding packages
  5. Elisp and documentation

If you’re new to Emacs you can use these tutorials as a way to organize your study and learning.

Posted in General | Tagged | Leave a comment

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