Ads by Google

Wednesday, February 13, 2008

Making a presentation on Emacs

Finally got off my chair and did a small presentation on Emacs using this presentation (note PDF file) from a US based LUG. Done at the last minute, I decided to use a presentation along with the demo.

A couple of things that I should have done.

  1. Get an OHP. Last minute request to the facilities resulted in all the OHPs being already booked for the day. Drat!
  2. Inform the audience beforehand. Double drat! I should have given more thought into planning this presentation day, instead of a last minute email and rounding up attendees 10 minutes before start.
  3. Doing it just after lunch doesn't seem be that good an idea. :-)

And, scaring your audience on the difficulty in learning it is not one of the brighter ideas either. Truth in advertising and all that, it was a bit difficult to encourage them to learn Emacs when their ignorance of basics of vi was all too apparent. They use vi regularly but I was initially surprised that they did not know what w, dw, yy does.

That does tend to jar your perception of how you want them to learn Emacs. On the plus side, there is very little to unlearn about vi, isn't it?

And going by the results of my presentation, I don't think I made a very favourable impression either. Came close to being a lead balloon.

The demo would have been better if the projecter had been available instead of getting everyone hunched over the laptop.

All in all, a so-so presentation by me and I have only myself to blame.

Tuesday, February 12, 2008

Monday, February 11, 2008

Good fonts for Emacs

I primarily use Win32 Emacs as I have a company issued laptop. For quite some time, I used "Courier New" as my font by setting

(set-default-font "-outline-Courier New-normal-r-normal-normal-16-120-96-96-c-100-iso8859-1")

Didn't like it much but it served my purpose and importantly being monospaced, the text alignment was clearly a big plus for my use. And on the gnu.emacs.help list there was a request for good fonts to use with Emacs.

Among the suggestions was one to use the "Bitstream Vera" fonts, which, upon use, is quite good in my opinion. Pleasing to the eye and it's pretty sharp and smooth.(To someone who doesn't know much about fonts)

Incidentally, this font is available in the cygwin install and can be easily be enabled for xterm or rxvt by setting it in the .Xdefaults file.

I later found that there was a variation of the above Vera family called DejaVu.

Installing this font is easy; Download the latest fonts version and unzip into a temporary directory. Then go to C:\Windows\fonts and chose the "Install font" from the File menu and that's it.

Use the font in Emacs by setting

(set-default-font "-outline-DejaVu Sans Mono-normal-r-normal-normal-*-*-96-96-c-*-iso8859-1")

To get the above font, use the command M-x display-fonts to list all the fonts installed on the system AND that can be seen by Emacs; plug in the font string of the font you'd like between the double quotes above.

Note it appears that Blogger seems to wrap the code around, it's all supposed to be a single line.

The Sans Mono seems to be particularly good but YMMV.

Saturday, February 9, 2008

Excluding Directories using tar on Solaris

Moving an application from one directory to another or to another machine, I've simply used tar and been on my way. A few back up shell scripts and temporary files did not matter. Simply tar, gzip and then reverse the sequence at the target directory.

This time, the application creates hundreds of temporary sql, srt and ctl files in one of its temp directories. And that was a serious bloat on the code size.

Get them removed, keep the directory structure and plug them on to another machine was the order.

ummmm....man tar give -X option.

tar cvfX temp.txt b_proc_and_load.tar ./load

That didn't work.

Reread the manual. Still doesn't work.

Stumped.

Let's break this down.

1. How do I get a list of files to exclude?
That is easy, you use find, like so

find ./p/bin/temp -print |sed '1,1d' > /tmp/exclusion.list
find ./p/m/data -print |sed '1,1d' >> /tmp/exclusion.list

you delete the first line using sed because you want to preserve
the directory structure but not have any files within. The first
line output of the find command is the directory path name.

2. Work out the command to use the exclusion list.
Well, this took some time till it was mentioned that the arguments
and flag order are important. Finally got it working and it
turned out to be

tar cvfX ../b_proc_and_load.tar /tmp/exclusion.list . (note the
period at the end)

Also notice that the created archive is one level higher? So that, it
does not come in the archive too. Though Solaris tar warns you about
it.

Thus endth the lesson on excluding directories using tar on Solaris.

Friday, February 8, 2008

Getting people to use emacs, an update

Seems like I spoke too soon. At least for the part of people willing to learn a little bit of Emacs.

Today, had a request for shell editing mode help. Naturally

set -o emacs

is way preferable to vi mode. Not that they were experts in vi mode. Using the emacs mode on the shell command line is definitely more natural than hyper thrashing the ESC key for every move on the command line.

And this was a good find to help them in using it. Particularly Ctrl-r which searches history; much faster than vi's.

Now, the next logical thing is to convince the sysadmins to install emacs somewhere on the Solaris box.

Thursday, February 7, 2008

Learning Git or rather how not to learn it

Seems like it's not a good idea to have a pre-conceived notion of CVS SCM model in mind while learning Git.

Going through the kernel.org links, especially this one, I kept waiting for the explanation of the central repository.

Kept reading and kept waiting.

Till I read this which left me nonplussed. Especially this part

Git differs from CVS in that every working tree contains a repository with a full copy of the project history, and no repository is inherently more important than any other.

Ack!

OK, now it appears I have to unlearn a couple of things before I can fully grasp Git. (There goes my perception, you know one SCM tool, all others are a variation of that)

Let's see how much I get sorted out.

Wednesday, February 6, 2008

The power of lists

You know the emacs kill ring? Well, I just had a look at it. considering the operations you can do with the kill ring, the data structure is simply a list!

In it's simplest form, working with plain text, it looks like

kill-ring is a variable defined in `simple.el'.
Its value is
("glgjglkg" "ggjjkg")


You get this by entering some text in a txt buffer and killing some lines of text. C-h v kill-ring will bring up the list.

Of course, for different modes it becomes a little more complex than that but essentially it's just a list.

In case you were wondering whether Emacs was using some difficult, arcane data structure. All the more reason for me to start learning Lisp sensibly. I've been starting, putting it off for quite some time now.

Should. start. it. some. time. soon.

Monday, February 4, 2008

Mea culpa. Listen to Emacs

If Emacs warns you about something, please stop what you're doing and understand what it's trying to say.

"File on disk has changed, do you want to save?"

This while remote editing the file. Blithely continuing, I hit C-x C-s and managed to corrupt the file.

In the split instant of saving the file and going "hmmm...who could be editing the file?"

ack! my colleague who was fixing a small typo .

Desperately pounding C-g, C-g, C-g.


No dice. I had a truncated file!

Good thing I had taken a backup the day before. A few calls and sheepish explanations later, sanity was restored.

If Emacs ever tells you something, listen.....carefully.

Sunday, February 3, 2008

Getting people to use Emacs

How easy has it been for you?

In my 10 years of using Emacs and talking to people about it, I think (the emphasis is on 'think') I managed 2 converts. But those were already Unix experts and probably don't count. :-)
Even the 2 converts, took about a couple of years, one decided to plunge in and the other a couple of half hearted attempts and then took a deep dive into it.

Like, decided to use Emacs for 6 months without using any other editor.

I really find it hard, to understand why this is difficult for someone. Not that Emacs is easy to learn. I meant the apparent decision in making up one's mind that indeed Emacs does things better than notepad or vi.

I can understand that if someone agreed that Emacs is the way to go but gave up due to the learning issues; for whatever reason. But what I don't get is the complete disinterest when your work involves things that Emacs does in a jiffy. Apparently I just showed you that in Emacs editing database columnar data is easy (you don't have switch from pasting between notepad and MS Excel to align the data) and you still show a complete lack of interest in knowing how that is done?

Leaving aside the Emacs learning part, wouldn't anyone be interested in that 'cool', 'neat' way of solving a simple text issue? Using vi to review large code bases versus using Emacs and bookmarks? Using htmlize? Helping someone with applying code changes using ediff? Simple word wrapping using M-q?

I tried across the aboard, people in the early twenties, late twenties and even my age group.
Not a single chap has come back to ask where, how and what to learn about Emacs?

Depressing.

Without evangelising, I've shown people how to do stuff in Emacs and the results have been....let's say diplomatically.....bloody disaster.

I must be getting old. That's all I can think of. or Ugly. or Stupid.

Using bookmarks...finally

Using Emacs for so long I never used bookmarks at all. Nada, not even once in almost 9-10 years. Sure I had read the documentation and knew that it existed. But using it?

Nope.

Bit like ctags. Know what it is about but since I don't program in C, I don't use it all.

Till about a few months back. Told to fix an application written in ksh, Oracle PL-SQL and Syncsort scripts. About 11KLOC lines of code in all.

The first few days I spent time opening many frames and buffers of the same file and it was clunky. I mean, there was a wall of Emacs frames on the taskbar.

There had got to be a better way. Since I had a RSS feed to the RecentChanges page on the Emacswiki site, I got a link about the bookmarks page.

A quick look at the page and then the manual, whipped up the one line change to my .emacs.


(global-set-key (quote [f9]) (quote bookmark-jump))


Setting bookmarks is done by C-x r m and entering a label using a mnemonic. Hint: Use the label latest for the most frequent or current focus of analysis. Then I use F9 to make Emacs prompt for a bookmark, which, by the way, allows tab completion in the minibuffer.

Bookmarks works in Dired buffers too AND tramp setup. Pressing F9 and Emacs prompting me for the password for the remote server is nice. Very nice (Yes, I know I can set the .authinfo or .netrc setup for the passwords)

With bookmarks, my analysis speed went up by an order of magnitude. I was using considerably less buffers, with less screen splitting and was going hither and thither through the code. Not only was my work done faster, I also bookmarked the frequent folders that I used to edit files in.

All in all, bookmarks WILL increase your productivity when you're looking at large code bases.

Those used to ISPF editors on the mainframe will not find this new, as it's very similar to labels. But the bookmarks on the mainframe is limited to the file you're currently editing or viewing. And I don't recollect whether the bookmarks are remembered across session; I think one cannot store those across sessions.