Ads by Google

Wednesday, April 23, 2008

What did they have in mind....

when a variable called track-eol is created which you can set as

(setq track-eol t) ?
Apparently if you set this to a non-nil value and if you're at the end of a line, C-n and C-p will track up or down to the end of the line you just moved to.

I've enabled it in the past and I can't say I found it tremendously useful and wondering if anyone has ever seen some good use for it. It's mentioned in the manual. Drop me a line if you ever think of a good use for it. I have a nebulous thought it might be useful for fixed width data files?

*shrug*

Copy it to the scratch buffer, eval it and open a few text files and see whether you like it all.

Monday, April 21, 2008

Increase your productivity with Minor Modes

One of the features that increases your productivity are the minor modes that can be enabled to help your work. Abbreviation mode, Foot note mode, flyspell mode are some of the minor modes that allow you to correct typos, add footnotes and do spell check.

In addition there are lots of other minor modes have been added to the main branch of Emacs that can complement the existing ones.

Like Table, that allows you to create ASCII tables to align text and also create spiffy text based tables. It also provides a LaTeX export function that helps in creating a LaTeX table. Frankly, I've been using the table-insert function to create all my LaTeX tables. Saves me the repetitive edit-view-correct cycle by a huge margin.

Another simple one is ruler-mode that puts a ruler on top of the text area. If you do a M-x find-file RET ruler-mode, the commentary will explain what are the features you can use enabling the minor mode. Tremendously useful when working with fixed width data; slightly better than following the mode line for the column position, I dare say.

And one other under appreciated mode for newbies and intermediate Emacs users is outline-mode. Found in org-mode and one that can be set in LaTeX mode (with AucTeX), the showing and hiding of the sections allows one to navigate large documents quite easily. Instead of scrolling up and down the document, it's easier to fold the arbitrary sections to focus on the section at hand.

Saturday, April 19, 2008

The closest to text intellisense in Emacs

Emacs users know that M-/ is used to the expand the text at point for possible completions. One good thing is that it searches all the buffers for possible completions. While this is not the same as programming language intellisense stuff you find in programming editors from Microsoft, Sun and Eclipse, it's still a better choice than a language specific offering.

Why? Because it gives the same consistent behaviour in whatever buffer you're in. You can be sure that if you had typed it before, it can be plugged into the current buffer in whatever mode it is in with a minimal of keystrokes. This is in contrast to other specialised editors which can offer the feature for Java, C or C++, say.

OK, the choice of M-/ is not exactly great for those who are not good typists.

But this is Emacs; there is a way to use TAB as the more natural keystroke to expand the text at point. Plugging in the code given at this link will make text expansion or completion a lot more natural. Having done that, I've pretty much stopped using M-/ for text expansion.

One other way to do text completion is to use Predictive mode which learns from your typing style; Having used it before, I could see the benefits but I ran into some resource usage errors with the dictionary and hence stopped using it.

I'd encourage people to try predictive mode if only to see the possibilities that might arise for you. A typing session that is customised to the way you write. It might be very useful for people who are in some specialised fields with limited but large words usage.

Thursday, April 17, 2008

LaTeX tip: Always use small fonts for Verbatim environment

On the TeX newsgroup, this was a nice tip to use. Indented code tends to move off the paper with normal fonts and the only way was to wrap the verbatim environment under \small.

But you'd have to do that for every verbatim listing.

Making the change in the document preamble makes the code listing simple.

For those interested in more sophisticated LaTeX pretty printing, the listings package is pretty good and comes with support for a number of languages. For anything fancier than the normal verbatim environment, that is a very good package to use.

Tuesday, April 15, 2008

Cleaning up or Deleting LaTeX intermediate files using AucTeX

Anyone using LaTeX knows that there are a number of intermediate files that are generated in the course of compiling the document. After the final file is generated, there is no need to keep those files around. But one has to delete them manually or plug the extensions in a shell script to delete them.

Fortunately AucTeX provides a simple interface to clean the files. Hitting C-c C-c and typing 'Clean' or 'Clean All' deletes the intermediate files associated with the current .tex in the buffer.

That's right, it ONLY deletes the intermediate files with respect to the current buffer where C-c C-c is called.

The difference between 'Clean' and 'Clean All' is that, in the latter case, the output files are also deleted. And the files can also be deleted by calling M-x TeX-clean.

So, what intermediate files are deleted? Depending on the type of file being edited, it varies. For example, for LaTeX files, it's

LaTeX-clean-intermediate-suffixes is a variable defined in `latex.el'.
Its value is ("\\.aux" "\\.bbl" "\\.blg" "\\.brf" "\\.fot" "\\.glo"
"\\.gls" "\\.idx" "\\.ilg" "\\.ind" "\\.lof" "\\.log" "\\.lot"
"\\.nav" "\\.out" "\\.snm" "\\.toc" "\\.url")


To know the exact way things can be customised, see the AucTeX manual, especially Cleaning.

Monday, April 14, 2008

In my previous post, I outlined how to get Auctex to launch Acrobat Reader. Here's a minor change based on the same poster's advice. If the reader is the default application to view pdf files in Windows, you don't even need the acrord32 in the configuration. Just


TeX-output-view-style is a variable defined in `tex.el'.
Its value is
(("^dvi$" "^pstricks$\\|^pst-\\|^psfrag$" "dvips %d -o && start \"\" %f")
("^dvi$" "." "yap -1 %dS %d")
("^pdf$" "." "cygstart %o")
("^html?$" "." "start \"\" %o"))

is enough.

Sunday, April 13, 2008

Making AucTeX launch the Windows Acrobat Reader

When I compile documents using AucTeX, I used to manually open and close the generated pdf by navigating to the file location and opening the file using Windows based Acrobat reader.

The Reader locks the file when in use, so if you recompile the document when the pdf is still open by the Reader, you'd get the "can't write to output file" error.

One workaround I used was, the cygwin based xpdf viewer which doesn't lock the file. But you'd have to refresh the file every time something changed, by hitting 'r' in the xpdf application.

The problem with the default AucTeX install was that it had the start "" %o as the entry for View which didn't do anything. Even though I don't use that feature, I thought, let's get this to point to Acrobat Reader and save it.

Turned out, you need to customise TeX-output-view-style. Setting it to


start "acrord32" %o
acrord32 %o


didn't work. Finally, one poster on the AucTeX mailing list give the answer which made it self evident. Since I was using cygwin, he suggested I use cygstart instead of start.

That worked like a charm and now my TeX-output-view-style looks like

Its value is
(("^dvi$" "^pstricks$\\|^pst-\\|^psfrag$" "dvips %d -o && start \"\" %f")
("^dvi$" "." "yap -1 %dS %d")
("^pdf$" "." "cygstart acrord32 %o")
("^html?$" "." "start \"\" %o"))

Friday, April 11, 2008

Gnus v5.10.10 is released

Just saw this in the Gmane newsgroup. A new version of Gnus has been released. Those using imap would be happy to know that the unread count should be coming out correctly now. At least that's what the Release notes claim. :-)

And the drafts editing has been changed to the more logical 'e', I see.

And there are a whole bunch of other changes. Since I've been tracking the CVS version, I've been thinking that these features were already a part of the bundled Gnus version.

That's the problem with bleeding edge; you think some feature is so obvious and when people ask about a certain feature, you keep wondering why they are not using the obvious menu option.

Why I use Gnus: Reason #1

For the sheer language and wisecracks in the manual. For example

Gnus gives you all the opportunity you could possibly want for shooting yourself in the foot. Let's say you create a group that will contain all the mail you get from your boss. And then you
accidentally unsubscribe from the group. Gnus will still put all the mail from your boss in the unsubscribed group, and so, when your boss mails you "Have that report ready by Monday or you're fired!", you'll never see it and, come Tuesday, you'll still believe that you're gainfully employed while you really should be out collecting empty bottles to save up for next month's rent money.

With entries like that in the manual, even if you don't understand anything in it the first time around, you'll come back for more.

But then I'm one of those weirdos who can happily spend hours reading the manual, sometimes.

Thursday, April 10, 2008

Shell scripting gotchas: value too great for base (error token is "09")

Staring at the screen doesn't help.

Rerunning the code another 5 times doesn't help either.

It's still the same error. And it had been working so well for so many days. The code in question

if [[ $SDAY -eq $EDAY && $SMON -eq $EMON && $SYEAR -eq $EYEAR ]]; then
echo "Data is current for $value_set"
break
fi

You know you're good at shell scripting when you start making elementary mistakes and enter brain freeze territory frequently. I mean, your code can't just stop like that, can it?

And slowly you wrack your brains to see what you should be looking at.

Finally you read the error message and figure out that this is something to do with the base system.

You google and smack your head and realise, the dates were being read as octal and like clockwork it fails on 09th of April. You start to think of all the code to strip leading 0s and suitably chastened you stick to a simpler version which goes like

if [[ "$EYEAR$EMON$EDAY" -eq "$SYEAR$SMON$SDAY" ]]; then
echo "No deltas to be captured"
break
fi

The dates have to match, so it doesn't matter if it is a string or number.

Overconfidence, the bane of a programmer.