Using ace-link with Org Mode

I was checking the ace-link page and discovered something I didn't
know. You can also configure ace-link to work in Org mode. When
invoked, ace-link-org will build the typical avy tree—such as you
get with ace-jump and friends—and allow you to quickly choose the
desired link by pressing a single1 key. As abo abo says, choosing
the correct link goes from an O(n) operation, where n is the
number of visible links, to an O(1) operation.

I use ace-link all the time for Info and HELP files and occasionally
for eww. The ace-link-setup-default command sets up many file
types but not Org mode. To do that, abo-abo recommends

(define-key org-mode-map (kbd "M-o") 'ace-link-org)

The【Meta+o】binding is already assigned to something to do with faces. Since I've
used that exactly zero times in my entire Emacs using years, I had no
hesitation in rebinding it.



Or possibly two or three if you have a lot of links visible
in the buffer.

Posted in General | Leave a comment

Kill This Buffer

[Editorial Note: Sorry about the lousy formatting. Org2blog is misbehaving again so I had to paste the HTML into the WordPress editor.]

Ben Maughan over at Pragmatic Emacs has a really nice tip. It's one of
those things that you (or at least I) don't think about but once you
see the tip, you think, “That's just what I need.” The idea is to kill
the current buffer without asking

Maughan asks how many times you've called kill-buffer via
Ctrl+x k】and wanted to kill some buffer other than the one you're in. I can't
ever remember doing that. Maughan provides a one line fix to your
init.el that will just delete the current buffer without asking.

If you think you'll sometimes want the old behavior and don't want to
remember kill-buffer, it's trivial to add a bit of Elisp that
calls kill-this-buffer unless the universal argument is provided in
which case it calls kill-buffer. Bind this to
Ctrl+x k】 and you have the best of both worlds.
Here's some code that does that

(defun jcs-kill-a-buffer (askp)
  (interactive "P")
  (if askp
      (kill-buffer (funcall completing-read-function
                            "Kill buffer: "
                            (mapcar #'buffer-name (buffer-list))))

(global-set-key (kbd "C-x k") 'jcs-kill-a-buffer)
Posted in General | Tagged | 6 Comments

PSA: SSH Suddenly Asks for Passwords in OS X


If you're an OS X user who uses SSH keys to SSH to remote machines and have just updated to Sierra you may have noticed that SSH has suddenly started asking for a password. My situation is that I've upgraded my MacBook Pro but not yet my iMac. I can no longer SSH into the iMac from my MacBook Pro without giving a password. I am able to SSH into a remote Linux machine using the SSH RSA key.

There are two things going on here, I think. The first is that I think Sierra now requires an RSA key rather than a DSA key. This is for security reasons and something that Linux did a while ago. I can't find any mention of this in the Sierra release notes but it's consistent with what I'm seeing.

On the remote Linux host, SSHD will look for the RSA key in either the authorized_keys or authorized_keys2 file but OS X specifically configures SSHD to look for keys only in the authorized_keys file. This means that you have to add your key to the authorized_keys file on a remote OS X machine. Once I did that, everything was back to normal and I no longer had to supply a password.


If you suddenly find yourself needing to supply a password for SSH operations you should check that you are using an RSA key rather than a DSA key. You may have to generate an RSA key if you don't have one. You should then add this key to authorized_keys on any Macs you are trying to access. Other machines may require the key be added to authorized_keys2 instead. If you're not sure which to use, just add the key to both files.

Posted in General | Tagged , | Leave a comment

An Example of pcase-lambda

Over at the Emacs reddit, instant_sunshine has an example of using pcase-lambda. It's not used very often but can be useful if you have to write functions that need to look inside Lisp objects. The documentation for pcase-lambda is a bit obscure so it helps to have an example of its use.

The idea is that it's like lambda except that the arguments can be any pattern accepted by pcase. Take a look at the pcase documentation or John Wiegley's pcase post to understand what those patterns are.

UPDATE 2016-09-22 19:39:09: Added link.

Posted in Programming | Tagged , | 2 Comments

Blogging Woes

I finally got yesterday's post up by generating the HTML from my Org source file and then pasting it into the WordPress editor. I'm still not sure what's happening. Very occasionally I can push a post with org2blog but most times it gets an error and hangs Emacs.

I recompiled org2bog and updated all the packages. Now I'm about to try to push this file. If I have to paste in the HTML again, I'll add an update. In the meantime, if anyone else is seeing this problem, please leave a comment.

UPDATE 2016-09-21 14:06:08: OK, that worked but I'm suspicious that it might have been one of the rare exceptions. If this update pushes too, I'll be more confident that things are back to normal.

Posted in Administrivia | Tagged | Leave a comment

The Five Second Rule

The New York Times has published an article on the five second rule.
You'll be shocked—shocked—to learn that if you drop food on the floor
you get bacteria on it even if you pick it up in less than 5 seconds.
There are a couple of things I don't understand.

First, why would anyone waste time and money studying this issue? It's
not the first time someone's looked at it and guess what: they arrived
at exactly the same conclusion last time. Is there anyone who doesn't
realize that the 5 second rule is meant as a joke? Even as I child, I
understood that it was nonsense and just a humorous way of justifying
picking food off the floor and eating it.

The second thing I don't understand is why the Times thought it was
worth devoting space to this. It's not like we've run out of news.
It's like those cloyingly cute stories we keep seeing on TV news: all
sugar, no nutrition.

As is often the case, Kontra has the final word on the matter

Posted in General | Tagged , | 1 Comment

Problem Posting

I'm have a problem posting today's offering and I've run out of time to deal with it right now. I'll try to get back to it later tonight.

If you're reading this, it means that it's not a problem with Emacs or org2blog so it must be something in the post itself.


UPDATE: have --> having

UPDATE: It looks like the problem is something with org2blog afterall. Every once in a while the post will work but most times not. I doing these updates from WordPress itself. Sigh.

Posted in Administrivia | Tagged | Leave a comment


So true and so often disregarded

Hat tip to Karl Voit.

Posted in Programming | Tagged | Leave a comment

Emacs 25.1

As you surely know by now, Emacs 25.1 is out and available for download at the usual places. Check the Emacs download page for a mirror near you. They also have pointers to some precompiled binaries if you prefer that.

I built and installed the new version with no problems at all. The compile even seemed snappier than I remember. If you're on OS X and want to use eww you need to use a slightly different configure line. I explained how to compile Emacs with eww on OS X for version 24.4 but the procedure is the same.

Meanwhile, Mickey has an excellent annotation of the NEWS file for the new version. You should be sure to give it a read to find out what's new and changed. One thing I learned is that if you want dynamic modules you have to specify that on the configure line. I haven't done that yet but if you want it be sure to add it.

I'm writing this with Emacs 25.1 but I just finished compiling and installing it so I haven't done much with it yet. So far, though, everything seems fine. If you haven't been living on the bleeding edge and using the development version, you can finally install the new Emacs.

Thanks to the many people under the excellent leadership of John Wiegley for this release. I know it was a big change and a lot of work.

Posted in General | Tagged | Leave a comment

Repeating a Command

Zachary Kanfer has a nice post on how to repeat a command with a single keystroke. A familiar instance of this is the old-style keyboard macro execution. After defining the macro, you can execute it with 【Ctrl+x e】 and then execute it additional times by simply typing 【e】. Kanfer wants to be able to do this for his own commands.

The trick is to use a transient keymap. Once you use a key in a transient keymap, the keymap goes away so the key will revert to its old meaning. This is a handy trick that's useful in other circumstances too. For example, here is my code for invoking the ping utility in a full-frame buffer and then restoring the previous window configuration.

 1: (defun net-utils-restore-windows ()
 2:   "Restore windows and clean up after ping."
 3:   (interactive)
 4:   (kill-buffer (current-buffer))
 5:   (jump-to-register :net-utils-fullscreen))
 7: (defadvice net-utils-run-program (around net-utils-big-page activate)
 8:   (window-configuration-to-register :net-utils-fullscreen)
 9:   (let ((buf ad-do-it))
10:     (switch-to-buffer buf)
11:     (delete-other-windows)
12:     (set-transient-map
13:       (let ((map (make-sparse-keymap)))
14:         (define-key map (kbd "q") 'net-utils-restore-windows)
15:         map))
16:     (message "Type \"q\" to restore other windows.")))

After the ping operation finishes and we've inspected the results, we want to restore the previous window configuration by typing 【q】. As shown on lines 1215, we do that by defining a transient map. After typing 【q】 the transient map disappears and 【q】 reverts to simply being a letter.

Posted in General | Tagged | 5 Comments