Ads by Google

Saturday, August 23, 2008

Understanding Emacs Mark and Point

Another terminology which brings some form of confusion to newbies is the term Mark and Point used in the manual and in descriptions of Emacs editing actions. Truth to be told, I too just had a fuzzy idea what mark was all about when I first started and took point to be where ever the cursor was currently.

Well, point is exactly that; it is the current position of the cursor on your Emacs buffer. And it's there in the Emacs Tutorial too.

The location of the cursor in the text is also called "point". To paraphrase, the cursor shows on the screen where point is located in the text.


So, what is mark, then?

Mark is the equivalent of dropping anchor or "marking" the start of a position in a buffer. One marks a position in the buffer and then moves the cursor to another point, delimiting a region. Thus, mark is primarily used to delineate a contiguous region of text in conjunction with point. The text between the mark and the point is the region where one can operate Emacs commands if needed.

Is there an order to mark and point?

No, from the manual

The ends of the region are always point and the mark. It doesn't matter which of them was put in its current place first, or which one comes earlier in the text--the region starts from point or the mark (whichever comes first), and ends at point or the mark (whichever comes last). Every time you move point, or set the mark in a new place, the region changes.

Now, I suggest you hit the manual link above to know everything one needs to know about mark, mark ring and traversing marks.

Friday, August 15, 2008

Emacs Frames and Windows

For those of you who are new to Emacs and it's terminology, here's something that you need to grasp.

A frame in Emacs is equivalent to your window in normal Windows terminology. Well, sort of. An Emacs invocation can instantiate any number of frames and you'd see it in your taskbar as individual application instances.

A window in Emacs is the one that holds a buffer. An Emacs frame can have any number of windows. At any instant, there will be one window that will have focus or be the "selected window".


In the above picture, there is one frame with three windows. Two of the windows are showing the same help screen and the third is the scratch buffer. So you could open any number of frames using C-x 5 2 and within each create any number of buffers with C-x 2 or C-x 3. Depending on your working style and screen real estate, you could do one file on one frame or one file per window in one frame or combination thereof.

For a more detailed, see the manual sections, frames and windows.

Monday, August 11, 2008

An interesting post on keyboards and use of certain keys

I'm pretty sure, this is going to be a normal thing in a few years if Microsoft disappears from the IT scene. There will be a whole bunch of keys on the keyboard that no one will know what they are for because no one ever heard of Microsoft. The explorer and windows keys will be vestigial artifacts of a different computing era.


Why?


Take a look at this interesting thread and take a look at this post. That should keep you thinking on how systems evolve and how people understand them in the long run. From OSes, hardware to application software, we will be saddled with weird artifacts that are from another computing era but have no useful application now. And if the rate of technology change increases, barring a big shift, this will only accelerate.

Wednesday, August 6, 2008

Jpgfdraw: drawing PGF figures

If you find PGF too difficult to learn and use, then Jpgfdraw may be the tool for you. It exports the drawn picture as a file containing a pgfpicture environment which can then be included in your LaTeX document.

The drawback as I see it, it requires java 1.5 or later to run the application. That's way too much HDD storage needed for a bit of laziness in learning pgf. But if you already have it installed, then this should be ideal for those quick drawings that need to included into your LaTeX document.

Monday, August 4, 2008

Latest Builds of the PGF manual

The pgf package which is one of my favourite LaTeX packages for drawing pictures is released rather infrequently. Meaning, you get to wait a pretty long time for new features that are added, tested and then bundled for a release.

In case you want to the latest, you need to check out the CVS code and the prebuilt manual is available from Kjell's site.

Kjell recently posted on the pgf mailing list about the availability of the latest pgf manuals.

Saturday, August 2, 2008

The SPAM's getting better but it's still getting binned

Every once in a while, I check my Spam folder on on my gmail mail account to see whether there has been any legitimate mail binned, as a result of a false positive match. So far I've rarely had any mail flagged apart from the marketing material sent in by the Mutual funds that I buy.

While scanning the folder, I noticed that the social engineering aspect of spam emails are getting better. If it had not been for the spam filter and my lack of interest in the same spam emails, I think there'd been a bunch of saps who'd got infected with malware or some dreck of some sort.



Take a look at the above screen shot. Topical, covering entertainment, Politics, Tech and Business, it should be enough to pique someone's interest. All he has to do is open the email to get infected with the attached payload or get directed to a website that will install some malware.
Spammers seemed to have moved on from the "inadequate body part/function" mails though there are lots of that too, in my spam folder.

Gmail seems to be doing a fairly good job at identifying and binning them, so that's one strike against the spammers.

But these scum will keep trying, you can bet on that. If only they spent their time on more productive enterprise.

Saturday, July 26, 2008

A graphical Tutorial of Emacs Rectangle commands

The Emacs rectangle commands operate on rectangular blocks of text. (Surprise?) This is useful when you're working on columnar text and you need to work on columns of data much like Microsoft Excel. Here, I'm going to show you how to use them using a few contrived examples. Let's say we have following text entered in the scratch buffer.












Mark a rectangular block of text using C-SPC from column 1 to the 4th column in line 3. You should see something like this.











Now, this is a rectangle of 4Cx3R. On this you can operate any rectangle commands. The first is obviously kill-rectangle, bound to C-x r k. Applying that on the above state of the buffer you should see the following.

As you can see, the remaining text has been shifted to the left after killing the rectangular block of text. Since the text was killed as opposed to deleted which is bound C-x r d, the rectangular text is available to be yanked(pasted) in another place if required. C-x r y will yank the rectangular text back at point as shown.

The difference between kill-rectangle and delete-rectangle is that the former stores the killed text in kill rectangle ring while the latter doesn't.

Right, what happens if you don't want to shift the text to the left but just clear out a block of text? Well, that's when you use clear-rectangle bound to C-x r c.

But if you want to push text to the right as opposed to clearing it, you'd use open-rectangle bound C-x r o.

Note how the entire block of text is shifted rightward without anything getting deleted. So, if you wanted to enter text in the space, toggle the Overwrite key(to prevent the existing text from moving further rightward), fill in the text and toggle the key back again.

But, you say, I don't want to enter the same text in the columns over and over again. In fact you just want some standard text to be plugged in. No worries, you have C-x r t STRING to do that for you.
Mark the rectangular region as shown,

press C-x r t zzzz and you should see the above result. Useful for chunks of repeated columnar text when data is sorted by nationality, sex,currency etc. (which is pretty representative of textual data)

Oops, you forgot to insert an x in front of all the lines starting with z's?



No problem, just follow the above instructions, you should see this then.

Notice that even though a 4x3 block was marked, the inserted text was only 1 character and still everything came out correctly? The same happens with text which is more than 4 in this case, the columns shift to the right.

The most common uses of the rectangle commands are those that involve aligning columnar data, inserting and deleting columns of data, applying standard texts and the like.

Hopefully, this tutorial addresses the existence of rectangles in Emacs and how to use them. The Emacs manual has a little bit more on rectangles and how to use them with registers too. The canonical place to refer is the manual when things deviate from what I've mentioned above.

Thursday, July 24, 2008

Using TikZ graphics in Powerpoint

Came across an useful thread on the comp.text.tex newsgroup on how to get your Tikz graphics into Powerpoint. This should be useful to those who are forced to use the Office tools even if the graphics output from Tikz is superior.

So, there are ways to get the pics into Powerpoint. The only drag is of course, editing it if there is a blooper in the picture. You'd have to go through the edit, compile, check, export and paste into Powerpoint every time to fix things.

Which is not exactly ideal.

Saturday, July 19, 2008

Leslie Lamport recepient of 2008 IEEE John von Neumann Medal

Leslie Lamport of LaTeX fame has been awarded the IEEE John von Neumann medal.

Couldn't have happened to a more deserving person.

Maximizing your screen real estate

One thing that you'd notice as you become more proficient in Emacs, is that how rarely you use the menus and tool bars. Depending on how frequently you use Emacs, a lot of the basic commands get hard wired into you.

And after a sufficient level of proficiency you tend to dive into the help system or the info manual to learn about of version control or ediff, say.

Then, it makes sense to use the real estate occupied by the tool bars and menu for editing. You'd get an extra 2 lines of editing text; golden, if you're using a cramped laptop or small desktop screen. On my laptop, I could always use more space,as I tend to use larger fonts in Emacs.

Adding

(menu-bar-mode -1)
(tool-bar-mode -1)


to your .emacs will nuke your menu and tool bars. Though, it does appear that Emacs looks a bit naked or like a badly designed application.

Don't worry, you'll get over it.