Some RSA Public Keys Are Insecure

According to The New York Times, a team of European and American researchers have discovered that some (about 0.2%) RSA public keys are insecure. The insecurity is the result of using prime factors that aren’t cryptographically random. I’m still reading the paper but it appears that poor random number generation resulted in shared factors between many of the keys and in many cases shared moduli. One group of keys sharing a modulus had 16,489 keys in it.

It’s an interesting paper and worth a read if you’re interested in cryptography and security. One startling fact from the paper is that the authors used “unsophisticated methods” in their work and said they find it hard to believe that their results haven’t already been used for exploits.

Posted in General | Tagged | Leave a comment

UTF-8 Characters In Emacs

I’ve mentioned several times that I use Xah Lee’s excellent HTML/XML Entities List page to look up the code points for UTF-8 characters that I sometimes use in my blog posts. For example, in writing about Emacs Registers I wrote that you can save the point to register ρ with 【Ctrl+x r Space ρ】. My usually way of doing this is to type 【Ctrl+x 8 Return】, lookup the code point on Lee’s page, enter it, and then press 【Return】. That’s a fairly long process but I don’t do it that often so I never really minded all that much.

Now, once again, Emacs-Fu shows us the way. I’ve long been aware of abbrev-mode, of course, but I hadn’t investigated it or thought much about it because, in general, I find automatic abbreviations annoying. They’re always overriding what you type whether or not it’s really what you want. DJCB suggests a nice trick. He adds a 0 to the end of each abbreviation so that you aren’t likely to have it expanded unintentionally. In the unlikely event that I actually wanted rho0 in the buffer I would just type rho0 followed immediately by 【Ctrl+q】 (that is, by quoting the following space or punctuation mark).

As DJCB explains, the easiest way to set this up is to simply type 【Meta+xedit-abbrevs and then add whatever abbreviations you need to either the global section or whatever mode you want them in. Save the file and turn on abbrev-mode if it’s not already on and the substitutions happen automatically unless you quote the following character. It’s probably a good idea to take a look at user level Abbrevs in the Emacs manual too.

Update: mark → point (【ctrx+x r Space ρ】 saves the point not the mark.)

Posted in General | Tagged | 2 Comments

Centering Text In Emacs

I was watching another one of Kurt Schwehr’s Emacs videos and came across something I didn’t know (or at least something I’d forgotten). You can center text on the line with 【Meta+o Meta+s】. By default it will center the line the point is on but you can center N lines by specifying a prefix. Thus to center the next 3 lines you would type 【Meta+3 Meta+o Meta+s】.

That’s handy for those times when you’re producing a text file and want to center text for headings or whatever. The centering respects the fill column so it’s always accurate.

Posted in General | Tagged | Leave a comment

More Org Header Searching

The little Org-mode header searching functions that I wrote about in Finding Org Headers And Links turned out to be pretty useful so I added another one. This function is like find-all-org-headers except that it limits the search to those headers that contain a search term.

(defun find-an-org-header (term)
  (interactive "sSearch Term: ")
  (find-org-markers (concat "^\\*+ .*" term)))

The find-org-markers function is described in the Finding Org Headers And Links post. As before, it’s a very simple function but makes it easy to find the header you’re looking for, especially if the trees are collapsed.

Posted in Programming | Tagged , , | Leave a comment

A Short Coda To Yesterday’s Post

Yesterday I wrote about Finding Org Headers And Links and gave some Elisp functions to aid in searching for them. Today, my bank statement came and I entered information from the statement into my Org tax file. The tax file has several headings and subheadings for various kinds of data. Typically, the subheadings contain an Org table with information on expenses such as the date, check number, expense, and amount.

That gave me a chance to use the find-all-org-headers function. I called the function and the frame split with an *Occur* buffer opened in the other window. The focus was in the *Occur* buffer so I did a 【Ctrl+s】 to search for the proper subheading for the first expense, hit 【Return】 and I was popped right into the tax buffer at the proper place. I typed 【Tab】 to expand the heading, entered the data in the table, and then typed 【Ctrl+x o】 to return to the *Occur* buffer and repeat the process for the next expense. It was much quicker than my old method of hunting around in the tax file by hand.

Posted in General | Tagged , | Leave a comment

Org Mode Video

Looking through the ErgoEmacs Google+ Page, I found this post about Kurt Schwehr’s video on Org Mode. It’s a nice video that covers some of the basics of Org Mode and Babel. It’s just shy of 30 minutes so he covers a good amount of material but it’s still short enough to watch between other tasks.

The video is for a course in Research Tools that Schwehr taught at the University of New Hampshire. All together there are 20 videos, many of them about Emacs. There are also mp3s available for the classes as well as all the other material so anyone who’s interested can take the class on their own. Some of the individual lectures look interesting and appear to stand on their own so even if your aren’t interested in the entire course, you may find parts of it useful.

I haven’t watched the other Emacs videos yet but I plan to. I’ll post about any that I think Irreal readers would enjoy.

Posted in General | Tagged , | 1 Comment

Finding Org Headers And Links

Today I was looking through Xah Lee’s ErgoEmacs Google+ Page (there’s a ton of interesting stuff there—you should check it out) when I came across this post in which someone asks how to find links in an Org mode buffer. Later, in the comments, someone else asks how to locate the headers in an Org mode buffer. Serendipitously, a bit later I came across this post in the Org Mode mailing list that gives a partial answer to the question.

That got me thinking that being able to find these quickly would be very useful. For example, I have all my tax information in an Org Mode file with lots of headings and subheadings for various categories. Being able to show a list of all the headings and then being able to click on one and go right to it is a real time saver, especially when the trees are collapsed. As Marc-Oliver Ihm suggest in his post to the mailing list, the easy way to do this is with occur.

My solution involves 4 functions. The first is a utility function that does all the work:

(defun find-org-markers (regexp)
  (occur regexp)
  (pop-to-buffer "*Occur*"))

It takes a regular expression as input, searches for matching lines with occur, and then pops to the *Ocurr* buffer so that you can choose one.

The next two functions search for Org headers

(defun find-top-org-headers ()
  (interactive)
  (find-org-markers "^\\*[^*]"))

(defun find-all-org-headers ()
  (interactive)
  (find-org-markers "^\\*+"))

The first, find-top-org-headers, finds all the top level headers (those beginning with a single star). The second, find-all-org-headers, finds all the headers.

Finally, find-org-links locates the outbound links in an Org Mode buffer:

(defun find-org-links ()
  (interactive)
  (find-org-markers "\\[\\["))

I’m not completely satisfied with this function because it just searches for the [[ that begins a link. I would rather use the regexp \\[\\[.*\\]\\] but occur won’t match over more than one line and links frequently span two or more lines. Still, it works well enough to be useful.

These are very simple functions but useful nonetheless. Perhaps you will find them useful too.

Update: Jonathan notes that it’s a good idea to add a \\b to the end of the regexps in find-top-org-headers and find-all-org-headers so that they won’t match, for example, bold text that comes at the beginning of a line.

Update 2: Well that seemed like a good idea but the \\b doesn’t work. Instead, replace the [^*] in find-top-org-headers with a space and add a space after the + in find-all-org-headers.

Posted in Programming | Tagged , , | 4 Comments

Lexical Binding In Emacs

A while ago in Lexical Scoping In Emacs Lisp I wrote that Emacs 24 will (finally) introduce lexical binding. Trawling through the EmacsWiki today I came across a page, Dynamic Binding Vs Lexical Binding, that describes the differences between the dynamic binding that Emacs Lisp currently has and the (optional) lexical binding that’s available in Emacs 24.

It’s a good introduction for Elisp programmers who aren’t familiar with lexical binding. It looks at the advantages of dynamic binding and lexical binding and when it’s appropriate to use each. The big win with lexical binding is that it allows us to write closures. There’s an example of a closure on the page but I’m not sure it really makes clear how big a win they can be.

Suppose you need some counters in your program. You’d like to be able to give them an initial value and then increment them by any amount. You could write something like this (given that you have lexical binding):

(defun make-counter (initial-count)
  (let ((count initial-count))
    (lambda (n) (setq count (+ count n)))))

A call to make-counter will return a counter that you can use to track some count. If you call make-counter several times, each counter will have a separate count field so they won’t interfere with each other.

That’s a very simple example, of course, but it’s easy to imagine more complicated examples. The astute reader will notice that the counter is actually a sort object (in the OO sense) that has a single method. It’s easy to provide additional functionality–displaying the count, for example–so that you could have an object with several methods (loosely speaking). This fact is one of the reasons that I don’t use eieio (or CLOS in CL) very much. I get most of the benefits with a simple closure.

In any event, if you are an Elisp programmer and confused about lexical versus dynamic binding, this page is an excellent introduction and well worth a read.

Posted in Programming | Tagged , | 6 Comments

The Solution To Piracy

Paul Tassi has a nice aritcle in Forbes entitled You Will Never Kill Piracy, and Piracy Will Never Kill You. In it, he makes an observation that I think, while common, is right on the mark. That observation is that the vast majority of people who illegally download content do so because either the content providers will not sell it to them in the desired format or make it so hard to get it that it’s just easier to get it from Pirate Bay. The majority of people, he says, would be happy to pay for the content if the providers would just make it available. Consumers have become use to easy access to content and resent friction to their obtaining it. They don’t want, for example, to have to go to Best Buy to get a DVD; they want to be able to rent or buy a movie from their computer or home entertainment center.

He makes a pretty persuasive case that the only thing standing in the way of convenient tools for content delivery is that content providers are stuck in the last century and refuse to adjust their business models. They want to continue to continue to overcharge their customers for content in formats that their customers don’t want. To protect these business models they offer us SOPA and PIPA.

It’s a thoughtful piece and well worth a read. It’s too bad that the people who really need to understand its message will ignore it. While we’re at it, Julie over at Samurai Knitter makes much the same points but in a far more colorful way.

Posted in General | Leave a comment

Does Elisp Suck?

One of the links from the CategoryCode page that I wrote about yesterday is the Why Does Elisp Suck page. The idea is to give people a place to be grumpy about Elisp. My first thought was that, really, Elisp doesn’t suck—it’s a pretty nice language. I’d like to explore this question a bit more.

The answers to the “Why does Elisp suck?” question fall into two classes: the silly and the substantive. The silly answers are “because it’s not Scheme”, or “because it’s not Common Lisp”, or “because it’s not X” for your favorite language X. Are there better Lisps than Elisp? Of course. I’d argue that Scheme and Common Lisp are both better Lisps but that doesn’t mean Elisp sucks. If your X is something like Python or Ruby I’d wager that you aren’t really comfortable in Lisp but you’re certainly entitled to your opinion. On the other hand, preferring Python or Ruby or whatever also doesn’t mean Elisp sucks. In short, the fact that you’d rather code in a language other than Elisp doesn’t have very much to say about Elisp.

Of the substantive answers, only 3 are really of any concern to me. First and foremost is the lack of lexical scoping. That’s fixed (for certain values of fixed) in Emacs 24. The second problem is the lack of tail call elimination. Technically, Common Lisp doesn’t have this either—in the sense that it’s not in the standard—but as a practical matter all serious implementations of CL do eliminate tail calls. This matters to me because it enables a style of iteration that I prefer: see my rpl function for instance. Finally, there is no threading or concurrency. This bothers me less than the first two but it does mean that packages like gnus can slow things down.

Some of the other substantive problems with Elisp are no object system (a feature not a bug in my opinion), no module system (a pain because of name collisions but I can live with it), clumsy regular expressions (especially if what you really want are Perl regexps), and the API sucks.

Someone also noted that the Elisp implementation is slow. That’s true, I guess, but doesn’t really speak to whether or not Elisp sucks. It would be nice if things were snappier but on modern machines it seems fast enough to me. I’d guess that font locking and things like that have more to do with performance problems than the Lisp engine.

All-in-all, I find Elisp to be a comfortable language to write in. Not as powerful as Common Lisp and not as well designed as Scheme but still nice. What does everyone else think? Is Elisp something you put up with or do you like the language? I’d be surprised if very many people said it was their favorite language but I’d also be surprised if many Elisp users really do think the language sucks.

Posted in Programming | Tagged , | 12 Comments