Sed

In the days before GUIs, Unix users depended on a suite of command line tools to do their text manipulation. One of those tools, sed, is still used and useful today but many younger engineers are unfamiliar with it. The basic idea is that it will read each line of a file, perform a series of transformations on it, and write the result to stdout. Hence the name: stream editor.

If you’re a vi/vim user, the sed command structure will be familiar to you but even if you’re not, it’s easy to learn. Daniel Leary over at Theodo has a nice introduction to sed that shows how to perform a series of changes to a CSV file. It covers only a small part of sed’s functionality but that part is probably the most used and useful part.

Once you’ve read through Leary’s tutorial, you’ll be able to make basic changes to a file and read the sed man page to figure out the other functionality. Sed is one of those utilities that you—or at least I—don’t need that often but when you do, it’s just the thing. Emacs users will say, “But I can do that easily in Emacs,” which is true but what if you have to do it repeatedly, say on a daily basis? With sed you can record the commands in a file and then just run sed on a file as needed. It’s really very handy and worth spending a few minutes getting familiar with. Leary’s tutorial is a good place to start.

If you want more information, The Unix Programming Environment by Kernighan and Pike has an excellent section on sed that covers more of the details.

Posted in General | Tagged , | Leave a comment

RMS on Data Collection

RMS has an article in the Guardian that discusses the safety of your on-line data. With the recent exposure of Facebook surveillance practices and their consequences, reporters have been asking him if he thinks it could be a turning point in the battle to regain some of our privacy. He has an interesting proposal that he says would help accomplish that.

That proposal boils down to not collecting data unless it’s really needed for the application. The emphasis on “really” is to prevent the inevitable cheating that would otherwise occur to gather too much information. RMS gives the example of London’s oyster cards, which are used to pay for trips on London’s trains and buses. Those cards link the user with the trips that they take. But as RMS points out, there’s no real need to collect the user’s identity. The cards are simply a convenient proxy for cash that make using the transportation system a bit more seamless.

The authorities counter that by linking the information, they allow the user to review a list of past trips but that is not an essential part of the application—which is providing a convenient way of paying for transportation—and therefore the information should not be collected.

I like the idea but it’s hard to see how it could be effectively enforced. The data collectors will simply declare that, for example, providing a list of past trips is an essential part of the service so they need to collect the data. It’s possible that Europe will move in that direction but, sadly, I see little chance of that happening in the US. Maybe after a few more Facebook-like debacles.

Posted in General | Tagged | Leave a comment

Blogging with Hugo and Org Mode

Over at ZCL.SPACE there’s an informative post about blogging with Hugo and Org mode. The post serves as a reasonable go-by for setting up and using Hugo for an attractive, static blog. Although Hugo now supports Org markup natively, the post recommends exporting to Hugo compatible format using ox-hugo.

The ZCL blog is a bit unique because it is divided into distinct sections. Each section has its own Org file in which each level-one heading is a post. If you’re looking for a way of writing a static blog with Emacs and Org mode, take a look at this post for some good ideas.

While I still prefer to blog with WordPress, my ongoing problems org2blog and the XML-RPC interface to WordPress that it uses are tempting me to consider switching over to a simpler static blog. There’s a lot to be said for a blogging platform in which pushing a post amounts to transferring a file to the site.

Posted in General | Tagged , | Leave a comment

The Job from Hell

Imagine it’s Friday afternoon and you’re sitting in the local bar with a bunch of other developers bitching about how your company and its management is the worst ever. Then the guy from Project Failures stands up and says, “Hold my beer.”

The tale he tells is the most horrific story of project mismanagement and employee-hostile policies that I’ve ever heard. The project itself is bad enough:

  • 6,000,000 lines of code,
  • 50,000 C++ classes,
  • 48 hour build time using 32 parallel machines,
  • 15 minute startup time,
  • 30 second to 30 minute mean time between crashes,
  • 45 minutes for a context menu to popup,
  • 7 days to load 700 MB from a CD
  • and much, much more.

There’s probably plenty of projects with a similar profile. It’s the rest of the story that’s so horrifying.

After several years they instituted version control. It was so complicated that they had 4 people assigned to work on it full time. Doing a first checkout required an appointment with the version control folks and usually required a week to get. Before a file could be edited, permission was needed from a manager and then coordination with version control, which took another 2 days. Management, of course, had no software experience.

The development team was 20 engineers but there were 35 managers. At one point they fired all the engineers but kept all the managers. Engineers were required to be in at 9:00 and were fired on the spot if they were even one minute late. They regularly turned off the coffee pots so engineers wouldn’t waste time drinking coffee. At one point they even tried to coerce the engineers to give up smoking so they wouldn’t waste time on smoke breaks.

There’s a lot more. You really have to read the post to get the full flavor. It will make your job seem like paradise.

Posted in General | Tagged | Leave a comment

<t> Is Undefined

Is anyone else seeing the error message <t> is undefined when using Emacs? Occasionally Emacs will respond to a keypress with that error in the echo area and Messages buffer. The key is otherwise discarded but pressing it again will result in the correct action.

I’ve been seeing this error since Emacs 25. I vaguely remember seeing somewhere that it was a known error and was already fixed (it was probably this Emacs Stack Exchange question). I was disappointed to see the error still occurring under Emacs 26, although it doesn’t seem to happen as often.

I’m getting ready to file a bug report and am trying to gather as much information as I can. If you have any information on this bug or even if you’ve seen it please leave a comment. If you’ve seen the error, please include the Emacs version and your OS.

Posted in General | Tagged | Leave a comment

Update: One Down

Those of you who read Irreal on mobile devices or who just have a heightened sense of aesthetics will be happy to know that I’ve developed a workaround for the formatting problems that I wrote about yesterday. The problem, I believe, is that the WordPress editor interprets newlines as a request for a line break and inserts the line break tag (<b />). That only happen when you’re using the editor so it doesn’t come up unless I’m trying to paste HTML into the Text tab of the editor.

Although there are plenty of articles on the Internet explaining how to force a line break in WP, I couldn’t find any explaining how to inhibit them. So I looked at the problem the other way around and eliminated the newlines that WP was misinterpreting as a line break request. I have a local function called blog-post that calls org-html-export-as-html with a parameter asking it to only export the <body>…</body> portion of the HTML. I added a couple of lines of Elisp to replace singleton newlines with a space. That appears to make WordPress happy. For anyone interested, here’s the code:

(defun blog-post () 
  "Export an org buffer as HTML but only export the body.
 Remove all singleton newlines so the
 WordPress editor doesn't insert break tags (<b />)."
 (interactive) 
 (org-html-export-as-html nil nil nil t)
 (goto-char (point-min))
 (while (re-search-forward "\n\\([^\n]\\)" nil t)
   (replace-match " \\1"))) 

That’s one problem down. Now all I have to do is to get org2blog working again and things will return to what passes for normal around here. Please let me know if you’re still getting formatting problems.

Posted in Blogging | Tagged | Leave a comment

Reminder and Update

Back on March 2, I posted that org2blog was suddenly not working. I
was certain that it was something my host provider was doing but that
turned out to (probably) not be right.

In order to push posts to WordPress, org2blog uses XML-RPC to talk
to the WordPress server at the Irreal site. Any attempt to access the
server through XML-RPC returned a 400 (Bad Request) error. I was
pretty sure that the hosting provider was blocking XML-RPC for some
reason but they swore they weren’t. I threw together a bit of Python
to make a test post using XML-RPC and that did work so my provider
was provisionally off the hook. In the meantime, my provider got
acquired and the new owners are blocking XML-RPC so now I have to
argue with them about not doing that.

I’ve been able to continue posting by converting the Org mode source
for a post to HTML and manually pasting it into the WordPress editor.
That’s a pain but it does get the job done except that the formatting
of the posts is wonky. In the last two or three days, I’ve received
email from a couple of readers complaining about line break tags in the
posts. It turns out that the line breaks are what makes the formatting
look bad. It’s annoying enough that they make the posts look funny in a
browser but, as you can imagine, it causes real headaches for those
trying to read Irreal on a small screen such as a mobile device.

I checked the HTML that gets generated when I convert from the Org
mode source and it looks OK. It’s also OK when I display it locally
(without going through WordPress) so apparently WordPress is adding
the breaks when it displays the post. I don’t know why this happens
and I can’t find any solution in the documentation. If you know a
workaround for this please leave a comment.

So the TL;DR in all of this is that yes, I know about the line breaks,
and no, I’m not inserting them just to be perverse. In fact, I’m not
inserting them at all: WordPress is. I am trying to resolve these
problems and hope I can get things back to normal soon. In the
meantime, thanks for your patience and I’m sorry about the lousy
formatting.

Posted in Blogging | Tagged | Leave a comment

Emacs 26.1 RC-1

I just installed Emacs 26.1 RC-1 and am using it as my production
Emacs. Well, actually I installed it last night but I wrote this last
night so, “I just installed it” as I’m writing this. It’s astounding
how easy compiling and installing Emacs from source on macOS has
become. At one time it was finicky and a pain but the last several
releases have been really easy, even on macOS.

If you’re a macOS user and want to install the 26.1 release candidate
to try it out, here is the magic spell:

configure --with-ns CFLAGS="-g3 -O2 -I /usr/local/include/libxml2"
make
make install
make install-info
sudo cp -R nextstep/Emacs.app/ /Applications/

That’s all there is to it. Perry Metzger says you probably don’t need
the --with-ns in the call to configure but it still works and it’s
easier to keep using it than to experiment. You should probably rename
your current Emacs to Emacs-25.3.app or whatever is appropriate for
your setup before you install the new binary.

So far, the only thing I’ve done with it is write this post but it
does seem to be a bit snappier than the 25.3 version I was using
before. If I have any problems, I can always launch my backed up 25.3
version but everyone I’ve talked to says 26.1 has been rock solid for
some time.

If you can, give it try. That way we’ll have a plenty of eyeballs looking
for any problems before the official release. If I find any glitches,
I’ll let you know in addition to filing a bug report.

Posted in General | Tagged | Leave a comment

Mike Zamansky

Regular readers know that I’m a big fan of Mike Zamansky and his Using
Emacs Series
of videos. If you’ve watched those videos carefully or
follow his blog, you know he’s a professor at Hunter College’s School
of Education where he specializes in programs to train current and
prospective high school teachers in Computer Science.

Zamansky was a high school teacher himself for 25 years before moving
to Hunter and helped establish the Stuyvestant HS CS program. One of
his long term goals has been to establish CS as an independent (from
the Math department) program and to provide a way for teachers to
become certified in CS.

His efforts recently came to fruition with New York’s new
certification program in CS for K-12 teachers. Crain’s New York
Business
has a nice article on Zamansky and his work on behalf of the
new program. It’s an interesting look at the man behind one of
Emacs’ most extensive and popular series of videos.

Posted in General | Tagged , | Leave a comment

Elisp Slime Nav

A few months ago, I stumbled across elisp-slime-nav and decided to try
it out. For some reason—lost to the mists of time—I didn’t write about
it at then. That’s too bad because it’s a really useful package
that anyone who writes, or even reads, Elisp should be using.

What it does is take one of the navigation functions from the SLIME
package for Common Lisp and port it to work with Emacs Lisp. Typing
Meta+. will
take you to the definition of the symbol at point. The current point
position is pushed on a stack so typing Meta+,
will return you to where you were.

This functionality is really handy when you’re reading some unfamiliar
Elisp and need to quickly check out a definition or follow the flow of
a program. I use it all the time when I’m reading some unfamiliar part
of the Emacs source. In addition, you can bring up a buffer with the
documentation for the symbol of point by typing
Ctrl+c Ctrl+d d or Ctrl+c Ctrl+d Ctrl+d.

I didn’t realize until I started gathering material for this post that
elisp-slime-nav was written by Steve Purcell. As most of you know,
Purcell is the founder/maintainer of MELPA as well as the author of
many other useful packages. Elisp-slime-nav is one more reason to
grant him Hero of the Emacs Community status.

Posted in General | Tagged , | Leave a comment