Shift Select Mode

I’m probably the last Emacs user to discover this but here’s a nifty trick that I learned today while trawling through some of Magnar Sveen’s .emacs.d files. If you hold down the shift key when moving the point, the region is extended. For example, if we have

the region is extended. For example,
      ^

with the point at the g in region and we type 【Shift+Meta+f】 3 times, we will have

gion is extended

selected. This is really handy for selecting a range of text, although to be fair, Sveen claims that true Emacs Knights don’t use this mode. He apparently prefers to use some of his finer grained extensions such as the expand-region package. I’ve also loaded that package and will write about it after I’ve used it for a while.

In the meantime, shift-select-mode seems like a handy feature to me. It’s enabled by default in Emacs 24 (at least) so you can try it out on any buffer you have open. You can read the documentation by asking for help on shift-select-mode.

Posted in General | Tagged | 1 Comment

Moving and Returning

Xah Lee asks what’s the best way to jump to another position in a buffer and then return to the original point? Emacs users know a lot of ways of doing this. We can, for example, use 【Ctrl+s】 to move the new point and then 【Ctrl+x Ctrl+x】 to return or we can use any of the push and pop mark tricks that I and many others have written about.

Lee says he tried all those but that the thing that works best for him is to simply split the window, move to the new position in the window that still has focus and then close that window when he’s done. That way he’s back to where he started quickly and easily. What I like about that method is that it’s easy to remember. In theory I like the other methods but the 【Ctrl+x Ctrl+x】 sets a new region that has to be turned off and unless I use the push/pop mark methods all the time I tend to forget how to do it.

For small jumps, ace-jump-mode and then popping the mark with【Ctrl+u Ctrl+Space】 to return works well. A similar method using【Ctrl+s】 or【Ctrl+r】 followed by a【Ctrl+u Ctrl+Space】 also works for me. Those work because they push the mark before the jump. Methods that don’t do that are harder for me to use effectively. In those cases, Lee’s method feels like a win. What do the rest of you do?

Posted in General | Tagged | 5 Comments

Linum-mode

This is another note to myself. Recently I was examining the internal structure of the decimal expansion of a number. In order to do this, I put the decimal representation of the number in a buffer and did a query-replace-regexp substituting <digit><space> for each <digit>. Then I set the fill column to 2 and did a refill. That gave me the number with each digit on a single line. I wanted to know the position of each digit. It’s easy to find that out by moving the point to the relevant line and, given that line-number-mode is on, just reading the line number from the mode line. But I wanted to see the positions for all the lines at once.

I knew there was a command to put each line’s number in the left fringe and had even used it but I couldn’t remember what it was. Furthermore, I couldn’t find it in the documentation. I tried things like apropos line and apropos number and other similar constructions but couldn’t find it. Eventually I gave up and started thinking about where I had first seen the command. It seemed to me that it was in an old Emacs-Fu post so I went to DJCB’s blog and did a search on “line number” and the correct post popped right up.

The right answer is linum-mode. The command name is suggestive of its function but it’s still hard to go from the functionality to the command’s name so I am documenting it here. It’s not a command that I use very often so it’s hard to remember its name but when you need it, nothing else will do.

Posted in General | Tagged | 3 Comments

Remote SUDO Access With Tramp

I was reading some of the old posts from the excellent emacs-fu when I came across this post describing how to access root-owned files as a regular user. It was a nice post and cleared up an arcane piece of syntax that I never understood. In order to edit a root-owned file on the local host you enter something like:【Ctrl+x Ctrl+f/sudo::<path-to-root-owned-file>. The double colon seemed different from other similar constructs but all that’s happening is that /sudo:: is really just a shortcut for sudo‘s default, which is /sudo:root@localhost:.

That’s interesting and cleared up something that never made sense to me but the interesting lesson from the post occurred in the comments. One of the commenters complained that this still didn’t help with the common case of wanting to edit root files on a remote machine. If you try to do this, Emacs (Tramp, really) complains that sudo can only be used on the local host. However, it turns out that you can use the Tramp multihop facility to enable this functionality. This is explained in detail in the info page at Tramp > Configuration > Multi-hops, but the TL;DR is to add the three commands

(require 'tramp)
(add-to-list 'tramp-default-proxies-alist
             '(nil "\\`root\\'" "/ssh:%h:"))
(add-to-list 'tramp-default-proxies-alist
             '((regexp-quote (system-name)) nil nil))

to your .emacs or init.el file. Then you can edit remote root files with 【Ctrl+x ctrl+f/sudo:root@remote-host:<path-to-root-owned-file>.

Posted in General | Tagged | 3 Comments

Hiring Writers

Hitesh Sarda has an amusing post on How I Hire Writers. Much has been written recently about the dysfunctional madness that is the tech hiring process. Sarda imagines the same process applied to writers applying, say, to a newspaper or magazine. Once you know the premise you can almost write the post yourself:

  • Offload the initial screening to HR by giving them relevant keywords such typing speed.
  • Have an initial screening phone interview in which they ask questions such as
    • Spelling of conscientious
    • Explanation of the Oxford comma
    • Asking the candidate to recite tongue twisters
  • Those candidates who pass the screening interview are invited to an on-site interview in which the interviewers dig deeply into
    • Knowledge of the Elements of Style
    • Spelling and grammar
    • Obscure facts about the areas in which they will be writing
    • Questions about word roots

When you see these tactics in an unfamiliar context their absurdity becomes obvious. Sadly, hiring managers are not apt to read Sarda’s post and if they do you can already imagine their explanations as to why they have to do things this way. No wonder so many people are starting their own businesses—anything would be better than going through this silliness.

Head on over and enjoy Sarda’s post. It will make your day.

Posted in General | Leave a comment

Emacs 24 ELPA Update

In my ELPA With Emacs 24 post, I documented some of the problems I was having getting ELPA to work with Emacs 24 and showed some Elisp to work around the problem. Fortunately, my readers are a lot smarter than I am and suggested better ways of getting things to work.

The answer turns out to be pretty simple. I replaced all my special code for setting paths and requiring package with:

(package-initialize)
(add-to-list 'package-archives
             '("marmalade" . "http://marmalade-repo.org/packages/"))

and left everything else the same. So far that seems to be working perfectly. The documentation isn’t really clear on this and, in fact, hints that putting

(package-initialize)

in your .emacs or init.el file can cause problems with other packages. I haven’t seen that and neither have any of my commenters so unless I run into problems later, my recommendation is to simply add the package-initialize near the top of your .emacs or init.el.

None of this means, of course, that you won’t have to configure some of the packages you load with ELPA but at least Emacs won’t throw an error during startup because of missing packages. Thanks to Seth, Philipp, and Foo for their helpful comments.

Posted in General | Tagged | 1 Comment

You Can’t Make This Stuff Up

Just when you think you’ve heard it all, we get a story like this. Scum spammers, masquerading as SEO consultants, have recently been flooding blogs with comment spam for an insurance agency in Australia. We here at Irreal get spam for similar (but not, apparently, the same) outfits on a regular basis.

Now Google has changed the rules a bit and fixed things so that “legacy spam” is actually damaging to the concerns that it was supposed to help. In response, the company has sent out emails asking (demanding?) that the blogs victimized on their behalf now remove these links (because they “may be harmful either to the future marketing and reputation of [our company] or our search results”) and to notify them when said links have been removed. I really wish that I had received one those emails but, sadly, I remove spam from the comments as they come in so I won’t have the opportunity to make a choice reply.

Josh Marshall of Talking Points Memo received one of these emails (see the story like this link) and summarized the situation as the company paying SEO consultants to spam blogs around the globe and then sending cease and desist notices when the scheme backfires. I’m not sure the email rises to the level of a cease and desist notice but it is rather demanding, especially in its insistence that the sender be notified when the links are removed.

If you were under the delusion that shameful behavior has boundaries, this story should disabuse you of the notion.

Posted in General | Tagged | Leave a comment

Line Numbering

DJCB, over at Emacs-Fu, takes note of the new line number command in Emacs 24 that Sivaram wrote about in Got Emacs? and offers up a few suggestions of his own. He shows a very nice trick for accomplishing the same thing and more using replace-regexp. It’s a little more complicated than rectange-number-lines so you probably won’t want to use it except for those cases where rectangle-number-lines (along with its optional FORMAT argument) can’t give you the desired result. Of course, if you’re still using an older version of Emacs it’s a nice way of getting the same functionality that rectangle-number-lines provides.

Posted in General | Tagged | Leave a comment

Magnar Sveen Rocks Emacs

Many (many) years ago when I was a freshman at RPI, we called the weekly Physics mass lecture “The Magic Show” because the lectures were spectacular demonstrations that illustrated whatever principle we were studying that week. This week I had the same feeling as I watched Magnar Sveen (of Emacs Rocks! fame) deliver a talk at Web Rebels in Oslo. The sound quality was a little substandard and the pace was rapid but like those old physics lectures it was a spectacular demonstration. In this case, a demonstration of the power of Emacs and its extensibility.

Sveen started by saying that unfortunately Emacs doesn’t have a slide show capability and then put one together right before our eyes. Then he spent the rest of the 18 minutes showing off some of the micro-optimizations he’s developed to speed up his editing. One of these, his multicursor enhancement, was startling and has to be seen to be believed.

This is a really great video, sort of like Emacs Rocks! on steroids. You won’t learn how to program these enhancements or even how to use them, just what’s possible with Emacs. Fortunately, all of Sveen’s code is available on GitHub so you can download the code and try it yourself. The multiple cursor stuff is still very young but worth playing with. I’m looking forward to seeing it on Marmalade when it gets a little more mature.

If you’re an Emacs user and especially if you enjoy the Emacs Rocks! videos you should definitely spend 18 minutes on this talk. You won’t be sorry.

Posted in General | Tagged | Leave a comment

Common Lisp For Noobs

Lori Holden over at Ghost Opera, Ltd has a nice post with advice for noobs wanting to get started with Common Lisp. As Holden points out, Common Lisp is beautiful and powerful but has some sharp edges and no commonly agreed upon starting point for newcomers.

The post is aimed at getting the neophyte up and running by listing some references and tools and then walking through a (toy) project. For tools she recommends

  • Emacs/Slime
  • SBCL
  • Quicklisp
  • CL-Project
  • Buildapp and
  • ASDF

That seems like a reasonable list, and truth to tell, I use almost that exact set of tools for all my Lisp work. The only difference is that I use Zach Beane’s quickproject instead of cl-project. Part of that is because I discovered quickproject first but it’s also because cl-project uses a method of package management that differs from what I (and, I think, most Lisp programmers) am used to.

The method pushed by cl-project is based on the style recommendations of Ariel Networks, which I find less than compelling. Still, others can and do disagree so it’s worth checking them and cl-project out if you’re inclined. Holden has a direct link to the Ariel style guide so she’s apparently an adherent.

There’s nothing in this post that will be new to anyone who’s the least bit familiar with Common Lisp but if you’re a newcomer and wondering how to get started, this is a valuable post with lots of good information.

Posted in Programming | Tagged | Leave a comment