Applying defadvice to Several Functions at Once

One of the distinguishing—and most useful—features of Lisp is the macro. Sadly, we don’t often see them discussed in the Emacs blogosphere so I was happy to see Bozhidar Batsov over at Emacs Redux give a beautiful example of macro use. The problem he addresses is to save the current buffer whenever you switch to a different window1. You can switch windows in a number of ways, of course, so several functions need to be advised to first save the current buffer.

The result is that six statements of the form

(defadvice switch-to-buffer (before switch-to-buffer-auto-save activate)
  (prelude-auto-save))

are replaced with the single statement

(advise-commands "auto-save"
                 (switch-to-buffer other-window windmove-up windmove-down windmove-left windmove-right)
                 (prelude-auto-save))

using the advise-commands macro that Batsov wrote.

This neatly illustrates one of the main uses of macros: rather than writing almost identical code over and over, you abstract the common code into a macro. Be sure to read Batsov’s post to see the concept in action.

Update: Inserted missing “of.”

Footnotes:

1 It’s another question as to why you’d want to do this. As long-time Irreal readers know I was a Vi(m) user for many years before seeing the light and switching to Emacs. One of the things I really hated was that I couldn’t switch to another file without first saving the current file (I think this was fixed with the Vim multiple window commands). Still, as I’ve said before, Emacs lets you have it your own way.

Posted in Programming | Tagged , | Leave a comment

EFF

The Electronic Frontier Foundation (EFF) has filed suit in Federal Court on behalf of 19 organizations. The suit asks that the court rule that the NSA mass surveillance violates the first, fourth, and fifth amendments to the U.S. Constitution and seeks relief in the form of an injunction ordering the NSA to cease their over-broad data collection and return the illegally obtained data to its owners. It’s worth reading the actual filing to help understand the issues at stake as the EFF sees them.

But that’s not why I’m writing this. Concomitant with the suit, the EFF is having a membership drive and I’d like you to consider joining. Membership starts at $25. If you can’t afford that, send them $5 or $10 to help them carry on their work.

You hear a lot about the EFF so it’s easy to believe that it’s a huge organization but, in fact, they have only about 20,000 members. That means that every member counts and that they are probably always short of funds. Still, for 23 years they’ve been doing a lot of heavy lifting to help safeguard our Internet rights and freedoms. If the recent NSA snooping troubles you, please join. You’ll be on the side of the angels. If you don’t live in the U.S., consider donating or joining the equivalent organization in your country.

Posted in General | Tagged | Leave a comment

A Random Emacs Wiki Page

Here’s a nice little trick to help you waste time on the Emacs Wiki. As the Redit post explains, if you navigate to http://www.emacswiki.org/emacs/?action=random you get a random page from the Emacs Wiki. It’s easy to imagine building a simple app that lets you explore an Emacs Wiki page every time some event takes place (login, hourly, starting Emacs, whatever). Or just bookmark it and take in a random Wiki page whenever you feel the urge. It’s an easy way to learn a bit more about Emacs.

Posted in General | Tagged | 1 Comment

A Second Jekor Emacs Video

I was alerted by this Magnar Sveen tweet that Jekor has another Emacs video up on YouTube. As I mentioned in my post about the first video, these videos are extraordinarily well done and worth your time.

This episode discusses the Emacs customization system. Jekor shows how to use it to get rid of the status and tool bars. Then he changes the default face and demonstrates how to set a theme. Again, this is a great series for Emacs n00bs and even experienced users may learn something new. As I said in my previous post, I’m looking forward to more posts.

Posted in General | Tagged | Leave a comment

The Other Side

In my The Good Guys and Bad post, I had harsh words for Microsoft’s collaboration with the NSA and FBI. I still find their actions over the top and inexcusable but there is another side to the story. Declan McCullagh over at CNET explains how the government forces Internet companies to cooperate on surveillance.

The big threat is that the government will install their own equipment on the company’s network if they don’t get cooperation. No one wants that, of course, so they provide the targeted account details using internal mechanisms. Companies that resisted have consistently lost in court.

This, however, does not exonerate these companies, at least not completely. Companies are only required to provide what they can provide. If they don’t keep logs for longer than required for engineering purposes, they can’t tell the government when someone was logged on. If they keep user data encrypted on their servers in such a way that only the user can decrypt it, they can’t give it to the government. None of this is impossible. We can’t expect Google, for instance, to do this because their business model is all about mining their users’ data but other companies can and do.

If you want to keep your business your business you should seek out these companies. I’ve been accumulating a list of such services for my own use and will blog about them occasionally. Realistically, if you become a target of the NSA or FBI1, they are probably going to get your data but most of us aren’t and won’t be such targets so we can take steps to avoid having our data vacuumed up wholesale. This will also prevent companies like Google and Facebook from building a profile of our Net activities—a profile that itself could easily become a target of government interest.

Footnotes:

1 Or, if you’re not an American, whatever the appropriate Three Letter Agency is that takes care of such things in your country.

Posted in General | Tagged | Leave a comment

Last Chance

By way of a public service announcement, Google will be deleting all Google Reader information tomorrow. This is your last chance to get your subscription (and other) data out of the system. It’s easy to do so. Just go to Google Takeout and click on Create Archive button.

Posted in General | Leave a comment

GPG Tutorial

If you aren’t already using GPG (or one of its OpenPGP brethren) you should start. Happily, Alan Eliasen has a nice tutorial on how to set up and use GPG. The tutorial covers everything you need to use GPG in a secure way. Definitely worth a read. You may also want to bookmark it as an easier to read man page.

Posted in General | Tagged , | Leave a comment

A Beginning Emacs Tutorial

Jekor (aka Chris Forno) has an excellent beginning Emacs video up on YouTube. It’s the first in a planned series so it just covers the very basics. The video has great production values. Jekor highlights items he’s discussing so it’s very easy to follow. It’s a great video for n00bs.

I’m looking forward to subsequent installments. If you know someone who is thinking of trying Emacs this is something to point them to—especially when other videos are added so that there’s a series to get a n00b up to speed.

Posted in General | Tagged | Leave a comment

The Good Guys and Bad

There’s a tiny ISP in Utah, USA. It has a sole proprietor and very limited resources. Still, it does what few others are willing or able to do. For the last 15 years, Xmission has refused to honor any request for user data unless it is accompainied by a court-issued warrant.

In those 15 years, it has only once provided data and that was when it was presented with a warrant from FISA. For owner Pete Ashdown it’s simple: if you don’t have a court-issued warrant, the request is unconstitutional and he’s not going to honor it. He has maintained that stance even in the face of a local law passed a few years ago that law enforcement could request data without a warrant. Ashdown says it’s easy to get a warrant and if you don’t get one you don’t get the data. The fact that he has only once acquiesced shows how easy it is to resist government extra-legal snooping if you have the courage and will.

Then there’s Microsoft1. A huge company with practically unlimited resources and substantial political clout. Unlike Xmission, they are only too happy to sell out their customers and then lie about it. Think that’s hyperbolic? Think I’m just Microsoft bashing? See for yourself2.

How can a company that provides the NSA with a backdoor to the Outlook encryption function before it’s even released be said to be looking out for their customers? How can a company that worked with the NSA to provide them easier access (through the Prism program) to their SkyDrive cloud service be said to respect their customer’s privacy? How can a company that, at the same time, provides the NSA with the audio and visual content of Skype calls and claims that “Skype is committed to respecting your privacy and the confidentiality of your personal data, traffic data and communications content” be said to be being honest with their customers?

If all that seems shocking, you’ve seen nothing yet. Go read the article. Microsoft’s whoring for the NSA is disgusting beyond words. They say, of course, that they have to obey the law, which is fair enough, but the thing is, there is no law requiring vendors to build in back doors for government snooping. We know this because the FBI has been whining for years about their sources going dark and asking Congress to pass laws requiring such back doors.

If you think it’s only about national security, think again. As the article makes clear, the NSA shares this data with the FBI and the CIA. They call it “a team sport.” Read, if you can stomach it, the effusive praise for Microsoft’s cooperation from the FBI and NSA.

This affects us all. If you’re an American, your fellow Americans are conspiring to spy on you. If you’re not an American, you don’t have even the presumption of rights so your situation is worse. If, after reading the Guardian story linked above you’re still using Microsoft products, you have only yourself to blame for the inevitable loss of privacy.

Footnotes:

1 Perhaps the other tech giants are equally guilty; we’ll have to wait to see. For now, this is the only specific information we have.

2 What follow assumes, of course, that the Guardian story is correct. Given their track record on the NSA story, I’m willing to give them the benefit of doubt on this.

Posted in General | Tagged | Leave a comment

AT&T: All Your Data Are Belong To Us

Editorial Note: In the aftermath of the NSA revelations, I’ve been writing more and more posts on privacy and ways to help secure it. From this post on I will use the tag “Privacy” to mark these.

AT&T, my wireless carrier, has joined other large communication companies in deciding that our data really belongs to them and that they are going to sell it to advertisers. It’s OK, they say, because everyone is doing it. There’s the usual “no personal identification will be given to advertisers; we just want to give you better ads” nonsense. This is basically what Google is doing but this time we’re paying the carriers and they still feel free to appropriate our data and sell it. Really, it’s despicable.

Anyone with a clue already knows that cell phones—especially smart phones—are tracking devices but that doesn’t mean that our carriers should get to sell that information to anyone willing to buy it. Ideally, it would be illegal to collect and store this information (except maybe for engineering purposes and then only with identifying information removed). Of course, the usual 3-letter agencies would run screaming to Congress about the Four Horsemen of the Infocalypse so that probably isn’t in our immediate future.

Fortunately, at least for AT&T, you can opt out of this program as this Forbes article explains. I urge everyone to take the time to do this. If we don’t push back—now and hard—it will only get worse.

Posted in General | Tagged | Leave a comment