Current File and Directory in Emacs and Z Shell

My work environment is the command line (Z shell) and Emacs, bouncing back and forth between the two. The minor, but frequent, annoyance is when I am working on a file (or directory) in one, and need to do something on it in the other, and need to “manually” copy or type the file name between the environments.

This happened moments ago, when I was editing code for Cabin Notebook, and wanted to look at the current Git diff of the file. (Yes, I know I could do that exclusively in Emacs with the vc- functions, but my command line habits are deeply ingrained, and I like seeing the two side by side.)

So I was looking at the file in Emacs, and would have done what I always have, to just type out the name on the command line, probably the 24,000th time that I’ve done that.

I already had a Z shell function, cde, that changes to the directory of the current file in Emacs, with the code:

cde () {
   cd ${(Q)~$(emacsclient -e '(with-current-buffer
                              (window-buffer (selected-window))
                              default-directory) ')}

So that’s the basis of what I wrote. The first function displays the name of the current file (buffer) in Emacs:

ecf() {
    echo ${(Q)~$(emacsclient -e '(with-current-buffer 
                                  (window-buffer (selected-window))
                                  buffer-file-name) ')}

And the function that echoes the directory of the current buffer (yes, this could just be dirname `ecf`, but the below keeps in as all Emacs Lisp code):

ecd() {
    echo ${(Q)~$(emacsclient -e '(with-current-buffer
                                  (window-buffer (selected-window))
                                  default-directory) ')}

So now cde is just:

cde () {
    cd `ecd`

So there you have it, some tighter integration between the almighty Emacs and Z shell. More Z shell blithering of mine can be found here.

How much is (was) a Coke worth?

There is the classic experiment done with young children, making them choose between eating one marshmallow now, or having two if they wait 15 minutes.

A conversation last night reminded me of that.

In our conversation, I mentioned owning $3000 worth of Coca-Cola stock when I was 18, having inherited it from a relative. I recall selling the stock shortly after getting it, but I cannot recall what I spent the money on.

So we did a bit of calculation, and determined that if I’d held onto that stock from 1984 until present, it would now be worth over $240,000.

To see the concept of financial delayed gratification quantified, as above, is instructive and humbling.

Downgrading Subversion from 1.9.3 to 1.8.13, Ubuntu 16.04

I needed to run tests and fix an issue with Subversion 1.8, and on my recently-updated machine running Ubuntu 16.04 (Xenial), Subversion was installed as 1.9.3, which was the only version in the xenial repository.

So, a quick post of what I did, since googling produced no clear answer.

Download the 1.8.13 .deb files for subversion and libsvn1.

Install the latest from xenial repository (probably no changes, if you have Svn 1.9.3 installed):

% sudo apt-get install libapr1 libaprutil1 libsvn1

Remove libsvn1, because it is 1.9.3:

% sudo apt-get remove libsvn1

Remove (uninstall) Svn 1.9.3

% sudo apt-get remove subversion

Install downloaded packages “manually”

% sudo dpkg -i ./subversion_1.8.13-1ubuntu3_amd64.deb ./libsvn1_1.8.13-1ubuntu3_amd64.deb

Check version (should be 1.8.13):

% svn --version

Check the package:

% dpkg -l | grep subversion

And that’s it.

How to Order at a Restaurant

I recently went on a solo road trip (2700 miles), so I was able to practice ordering in a variety of new restaurants.

First, if you’re out, go to places other than what you’re used to. On my trip I avoided all chains (with the lone exception of Culver’s, which we don’t have in my area), so nearly all of the menus were new to me.

There are a few options when ordering. One is to order the dish you are not crazy about, i.e., that is something you might like. And if it’s a dish that that restaurant specializes in, go for it. Like many people, I generally dislike liver and onions, but one of the most memorable dishes I’ve ever had was exactly that, at a place renowned for it.

Try not to order what you make at home, or what you usually get. A million places make hamburgers (and I’ll humbly submit, mine are better than nearly all of them). So no burgers. No spaghetti. No meatloaf, etc. Try oysters, shrimp, and scallops (especially if you’re near the sea, or near a place where they get frequent shipments, i.e., a transportation hub).

The best is to ask the waiter/waitress, and don’t ask “what do you recommend?” First, from what I know of the restaurant business, they often are supposed to recommend certain dishes, often what is selling slowly or which for they have excessive ingredients.

It is recommended that with a doctor don’t ask “What do you think I should do?”. Instead ask “What would you do?” Similarly, ask the wait staff what they like most on the menu, which is different than asking “What do you [i.e., your manager] think I should eat?”

That is also a good approach when going to ethnic restaurants, to avoid being steered toward food that they think people of your (different) ethnicity would like. (I had a bit of an argument with a waitress in a Chinese restaurant, when I ordered pork bellies with Chinese spinach, from the “Chinese” section of the menu, and she tried to dissuade me, insisting on the kung pao chicken, which ironically was the first dish I ever had in a Chinese restaurant, many years earlier. And I quite liked the pork bellies, to her surprise.)

Another of my techniques is the three-finger selection. I splay my hand and drop it onto the menu, and I have to order one of the three dishes my fingers are pointing to.

I also recommend learning your wait staff’s names, and using them. I haven’t worked in that industry, but I’ve read and heard that it is exhausting and literally thankless. Being more personal with them is a great way to connect and converse, and I’ll selfishly admit that it has personal benefits: at an excellent meal on my trip, I talked at length with both the manager and the bartender. On my final bill, they comped me for one beer (Kwak, my favorite beer, and on tap), and dessert (pecan pie made with Gulden Draak, another of my favorite beers).

When eating out, it should be an adventure. After all, that’s one of the main reasons to go out, right?