Elisp Tutorial Videos

Daniel Gopar is working on a series of video tutorials for Elisp. It’s definitely for n00bs so if you want to understand the basics of Elisp, you might want to take a look. Right now there are 4 videos but Gopar says he will be adding others.

These videos won’t make you an Elisp master but they will give you enough background to continue your studies or to be able to understand simple Elisp and work on your init.el. If you find the tutorials useful you can subscribe and Youtube will let you know when others are added. Or, of course, you can just check back periodically.

Posted in General | Tagged , | Leave a comment

Org Babel and Applescript

Grant Rettke over at Wisdom and Wonder points to an interesting project that integrates Org Babel and Applescript. If you’re a Mac user and sometimes work with Applescript (or even if you want to play around with it) you should check out ob-applescript.org.

I don’t really know Applescript but I have figured out enough to allow me to grab links to the URL for the current page in Safari. If you want to play around with Applescript or try implementing little helper functions, this is a nice way to do it while taking notes on your progress.

Posted in General | Tagged , | Leave a comment

Reevaluating Local Variables

An odd but very useful feature of Emacs is (file) local variables. This allows you to specify certain Emacs variables either on the first line of a file or at the end in a special Local Variables block. Typical uses include specifying line lengths, indention amounts, and other formatting features and specifying how to compile the file so that the compile command will work correctly.

I described it as odd because I first encountered the Local Variables block before I became an Emacs user and I thought it was very odd to see that sort of thing in a C source file. Regardless, local variables can be very useful.

One problem with them is what happens if you change a value or when you first add them to a file. How do you get Emacs to recognize the new value? I always solved this problem by reloading the file with Ctrl+x Ctrl+v (find-alternate-file) but there are other, better ways.

Grant Rettke over at Wisdom and Wonder points to two methods for reevaluating local variables. One method re-runs the hooks associated with the file and the other method doesn’t. Hop on over and take a look; it will take you less than a minute.

Posted in General | Tagged | 1 Comment

Tramp and cd

I try to use ehsell as much as I can when I need to drop into the shell. That way, I stay in Emacs and still have the power of Emacs available. The other day in a post about something else, I saw this powerful use of cd mentioned.

You can cd into a directory on another machine like this

cd /ssh:aineko:org

This logs me into my iMac in the ~/org directory using tramp. Something like

cd /ssh:aineko:

is the same as connecting to aineko with SSH. If you need to log into the remote server as a different user, use something like

cd /ssh:different_user@aineko:

It’s not quite completely transparent but it does make remote machines seem like they’re mounted locally. Very nice. And powerful.

Posted in General | Tagged | Leave a comment

Is Emacs Really Hard to Learn/Use?

J. Pablo Fernández has another one of those posts that drive me crazy.
His thesis is that Emacs is hurting Clojure because it’s hard to
learn and use or something. It’s a silly, even risible, argument.
His complaint is almost exactly the same as Ray Dillinger’s that I
wrote about
almost four years ago.

Fernández says that Clojure n00bs are forced by the community to use
Emacs and that learning Emacs and Clojure at the same time is too
hard. Of course, no one is forced to use any editor in particular and
lots of Clojure folks are not Emacs users. It’s hard to see how Emacs
can have much effect on Clojure uptake one way or the other.

“But,” as Arlo Guthrie famously said, “that’s not what I came to tell
you about.” Rather, I’d like to address the notion that Emacs is hard
to learn and use. To be sure, every long term Emacs user has
experienced the joy of learning some new Emacs feature even after
years of use but that’s not the same thing as being hard to use.
Anyone who’s willing to spend an hour or two with the tutorial can
obtain a reasonable facility with Emacs.

There’s still a lot to learn, of course, but you can do basic editing
and if you leave the menus on, you can take advantage of many of the
advanced features as well. After a month or two of everyday use you’ll
be well on your way to journeyman status. That, at least, was my
experience. Really, folks, it’s just not that hard to learn.

Even more ridiculous is the idea that Emacs is hard to use. What
exactly is hard? Once you learn the common keystrokes, you can edit
quickly and easily from the keyboard. No messing with mice or menus,
just typing.

It’s fun to joke about the weird shape of the Emacs learning curve but
it’s still a joke. My suspicion is that most of the people whining
about how hard Emacs is to learn and use haven’t bothered to put in
the minimal effort required to become effective users.

Posted in General | 6 Comments

Version 2 of Mastering Emacs is Out

Just got my Mastering Emacs update. Mickey has put out version 2 to incorporate new material reflecting changes in Emacs 25.1. The upgrade is free to current owners; You should be getting an email from Mickey. If you don’t already have a copy and you’re an Emacs user, you’re in luck. Mickey is making the new edition available for just $25. That’s a 37% discount so follow the link and get yours now.

Posted in General | Tagged | Leave a comment

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.

Footnotes:

1

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.
Perfect.

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))))
    (kill-this-buffer)))

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

PSA: SSH Suddenly Asks for Passwords in OS X

Background

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 id_rsa.pub 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.

Summary

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